// JavaScript Document

// nivo banner

$(window).load(function () {
    $('#slider').nivoSlider({ effect: 'fade', //Specify sets like: 'fold,fade,sliceDown'
        slices: 12,
        animSpeed: 500, //Slide transition speed
        pauseTime: 5000,
        startSlide: 0, //Set starting Slide (0 index)
        directionNav: false, //Next & Prev
        directionNavHide: true, //Only show on hover
        controlNav: true, //1,2,3...
        controlNavThumbs: true, //Use thumbnails for Control Nav
        controlNavThumbsFromRel: true, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav: true, //Use left & right arrows
        pauseOnHover: true, //Stop animation while hovering
        manualAdvance: false, //Force manual transitions
      
        beforeChange: function () { },
        afterChange: function () { },
        slideshowEnd: function () { }, //Triggers after all slides have been shown
        lastSlide: function () { }, //Triggers when last slide is shown
        afterLoad: function () { } //Triggers when slider has loaded});
    })
});




// news ticker


$(function () {
    $('#js-news').ticker({
        speed: 0.10 ,           // The speed of the reveal
        ajaxFeed: false,       // Populate jQuery News Ticker via a feed
        feedUrl: false,        // The URL of the feed
	                       // MUST BE ON THE SAME DOMAIN AS THE TICKER
        feedType: 'xml',       // Currently only XML
        htmlFeed: true,        // Populate jQuery News Ticker via HTML
        debugMode: true,       // Show some helpful errors in the console or as alerts
  	                       // SHOULD BE SET TO FALSE FOR PRODUCTION SITES!
        controls: true,        // Whether or not to show the jQuery News Ticker controls
        titleText: 'Latest news',   // To remove the title set this to an empty String
        displayType: 'reveal', // Animation type - current options are 'reveal' or 'fade'
        direction: 'ltr'  ,     // Ticker direction - current options are 'ltr' or 'rtl'
        pauseOnItems: 2000,    // The pause on a news item before being replaced
        fadeInSpeed: 600,      // Speed of fade in animation
        fadeOutSpeed: 300      // Speed of fade out animation
  });		
	
});	




// nav menu


$(document).ready(function() {
	

	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show();
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$(this).find(".sub").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$(this).calcSubWidth();
			//Set Width
			$(this).find(".sub").css({'width' : rowWidth});
			
		}
	}
	
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}


	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 20, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 5, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#topnav li .sub").css({'opacity':'0'});
	$("ul#topnav li").hoverIntent(config);



});



/********** left menu *******/

function initMenu() {
   $('#nav ul ul').hide();
    $('#nav ul:first').show();
    $('#nav li a').click(
    function() {
		var checkElement = $(this).next();
    if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
    return false;
    }
		$('.currentAncestor').removeClass('currentAncestor').toggleClass('current');
		$(this).removeClass('current').toggleClass('currentAncestor');
		
		
    
	if((checkElement.is('ul')) && (checkElement.parent().parent().not('#nav >ul').is(':visible'))) {
		
		$(this).parent().parent().parent().children(':first').removeClass('current').toggleClass('currentAncestor');
		$('#nav ul ul ul:visible').slideUp('normal');
    checkElement.slideDown('normal');
    return false;
    }
    if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
		
    $('#nav ul ul:visible').slideUp('normal');
    checkElement.slideDown('normal');
	
	
    return false;
    }
    }
    );
    }
    $(document).ready(function() {initMenu();});
	
	
/************** gallery *********/
$(function () {
    hs.graphicsDir = '../App_Themes/En/scripts/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.fadeInOut = true;
hs.dimmingOpacity = 0.8;
hs.outlineType = 'rounded-white';
hs.captionEval = 'this.thumb.alt';
hs.marginBottom = 105; // make room for the thumbstrip and the controls
hs.numberPosition = 'caption';

// Add the slideshow providing the controlbar and the thumbstrip
hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	overlayOptions: {
		className: 'text-controls',
		position: 'bottom center',
		relativeTo: 'viewport',
		offsetY: -60
	},
	thumbstrip: {
		position: 'bottom center',
		mode: 'horizontal',
		relativeTo: 'viewport'
	}
});	
});	


	

