(function($) {
	$(document).ready(function() {

		$("#tmenu li").hover(function() { /* top menu hover function */
			$(this).addClass("hover");
			$(this).children("ul").show();
		}, function() {
			$(this).children("ul").hide();
			$(this).removeClass("hover");
		});

		
				
		$("#slider").easySlider({ /* top slider initialize */
                        prevText:       '',
                        nextText:       '',
                        speed:                  800,
                        auto:                   true,
                        pause:                  8000,
                        continuous:             true
                });  
		

		$(".scrollable").scrollable({
			circular:true,
			clonedClass: 'cloned'
		});  /* bottom logo slider initialize */
//		var cloned = null;
//		jQuery('.first-slide').click(function(){
//			var cloned = jQuery('.cloned').detach();
//		});
//		
//		jQuery('.cboxClose')
		
		jQuery('.promo').find('li:last a').css('margin','0px !important');
		jQuery('#h-top-menu').find('li:last a').css('margin','0px !important');
		
		$('#logo-slider-c .items a').cluetip({   /* tooltips for bottom logo slider cfg */
		      local: true,
			sticky: true,
			mouseOutClose: true,
			closeText: '',
			width:'310',
			height:'160',
		    dropShadow: false,
		    attribute: 'rel',
		    positionBy: 'fixed',
		    topOffset: '-77',
		    leftOffset: '-254',
			showTitle: false,
		    fx: {             
				open: 'fadeIn', 
				openSpeed:  'fast'
		    }, 
		    hoverIntent: {    
				timeout: 500
		    }
		});

		$(".promo a[rel]").overlay({
			mask: {
				color: '#5d5d5d',
				loadSpeed: 200,
				opacity: 0.78
			},
			top:'center',
			onBeforeLoad: function() {
				var wrap = this.getOverlay().find(".contentWrap");
				wrap.load(this.getTrigger().attr("href"));
			}
		});
		$("a.popup").overlay({
			mask: {
				color: '#5d5d5d',
				loadSpeed: 200,
				opacity: 0.78
			},
			top:'center',
			target:'#overlay'
		});

		$('#page_text img[align="right"]').addClass("iright"); /* images margins class, add class to images automaticaly */
		$('#page_text img[align="left"]').addClass("ileft");

		$("a[rel='photos']").colorbox({ /* view photo - static */
			transition:"elastic",
			width:754,
			height:480,
			innerWidth:636,
			innerHeight:352,
			scalePhotos:true,
			opacity:"0.78",
			slideshowAuto:false,
			slideshow:false,
			current:"{current}/{total}",
			close:""
		});

		$("a[rel='photos-slide']").colorbox({ /* view photo with slideshow - dynamic */
			transition:"elastic",
			width:754,
			height:480,
			innerWidth:636,
			innerHeight:352,
			scalePhotos:true,
			opacity:"0.78",
			slideshowAuto:true,
			slideshow:true,
			current:"{current}/{total}",
			close:""
		});

		$("#start-slide-show").click(function() { /* activate slideshow */
			$("a.first-slide").click();
			return false;
		});

		$("#public td").hover(function() { /* publications slider td:hover */
			$("#public td.active").addClass("hide-active").removeClass("active");
			$(this).addClass("active");
			_id = $(this).attr("id");
			$("div.active").addClass("hide-active").removeClass("active");
			$("div." + _id).addClass("active");
		}, function() {
			$(this).removeClass("active");
			$("#public td.hide-active").removeClass("hide-active").addClass("active");
			$("div." + _id).removeClass("active");
			$("div.hide-active").removeClass("hide-active").addClass("active");
		});

		$("#public td").click(function() { /* publications slider td:click */
			_url = $(this).find("a").attr("rel");
			window.location.href = _url;
		});

	});
})(jQuery);

