$(document).ready(function() {
	
	// NAV DROPDOWN  *******************************************************************************************/	
	function megaHoverOver(){
		$(this).find(".subNav").stop().fadeTo('fast', 1).show();
	}
	
	function megaHoverOut(){ 
	  $(this).find(".subNav").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}
  
	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 50, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 500, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};
 
	$("ul#menu li .subNav").css({'opacity':'0'});
	$("ul#menu li").hoverIntent(config); 
 
 

	// END NAV LOGIN DROPDOWN  *******************************************************************************************/	

	// HIGHLIGHT LINK'S PARENT DIV  *******************************************************************************************/	
	
	 $(".hoverDiv").click(function() {
        	var thisLink = $(this).find("a");
        	if ( thisLink.attr('target') == '_blank') // If target=_blank then open in a new window
        	window.open(thisLink.attr("href"));
      else
          window.location=thisLink.attr("href");
      return false;
   });

	// END HIGHLIGHT LINK'S PARENT DIV  *******************************************************************************************/
	
	
	// PRESS TABS  *******************************************************************************************/	
	
	//Default Action
		$(".tab_content").hide(); //Hide all content
		$("ul.tabs li:first").addClass("active").show(); //Activate first tab
		$(".tab_content:first").show(); //Show first tab content
		
		//On Click Event
		$("ul.tabs li").click(function() {
			$("ul.tabs li").removeClass("active"); //Remove any "active" class
			$(this).addClass("active"); //Add "active" class to selected tab
			$(".tab_content").hide(); //Hide all tab content
			var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
			$(activeTab).fadeIn(); //Fade in the active content
			$('html, body').animate({scrollTop:680}, 'slow');
			return false;
		});
	    
	    $('a[href=#top]').click(function(){
	        $('html, body').animate({scrollTop:0}, 'slow');
	        return false;
	    });
	
	
	// END PRESS TABS  *******************************************************************************************/	
	
	
});

// WORKSHOPS DEMO IMAGE TRANSITION  *******************************************************************************************/	
	
		function slideSwitch() {
			var $active = $('#demonstrationSlideshow img.active');
		
			if ( $active.length == 0 ) $active = $('#demonstrationSlideshow img:last');
		
			// use this to pull the divs in the order they appear in the markup
			var $next =  $active.next().length ? $active.next()
				: $('#demonstrationSlideshow img:first');
		
			// uncomment below to pull the divs randomly
			// var $sibs  = $active.siblings();
			// var rndNum = Math.floor(Math.random() * $sibs.length );
			// var $next  = $( $sibs[ rndNum ] );
		
		
			$active.addClass('last-active');
		
			$next.css({opacity: 0.0})
				.addClass('active')
				.animate({opacity: 1.0}, 1000, function() {
					$active.removeClass('active last-active');
				});
		}
		
		$(function() {
			setInterval( "slideSwitch()", 3500 );
		});


	// END WORKSHOPS DEMO IMAGE TRANSITION  *******************************************************************************************/	
	






