// JavaScript Document 
$(function(){ 
	
		// jQuery | Mega Drop Down Menu - http://www.sohtanaka.com/web-design/mega-drop-downs-w-css-jquery/
		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: 10, // number = milliseconds for onMouseOver polling interval    
			 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
			 timeout: 20, // number = milliseconds delay before onMouseOut    
			 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
		};
	
		$("#mainNav ul li .sub").css({'opacity':'0'});
		$("#mainNav ul li").hoverIntent(config);
		
					 
	// innerfade - http://medienfreunde.com/lab/innerfade/   
	$('#fader').innerfade({ speed: 700, timeout: 4000, type: 'sequence', containerheight: '383px' });
	$('#sideHeadFader').innerfade({ speed: 700, timeout: 5000, type: 'sequence', containerheight: '120px' });
	$('#imgFader').innerfade({ speed: 700, timeout: 5000, type: 'sequence', containerheight: '220px' });
	
	

	
	// *** Login Panel animation
	$("#open").click(function () { 
      $("#Panel").slideDown(1000); 
    });
	$("#close").click(function () { 
      $("#Panel").slideUp(250); 
    });
	
	// *** Homepage Google Map animation
	$('.google_map_foot').css('cursor', 'pointer') .toggle(
	   function(){
		$('#map').animate({ 
			height: "700px"
		  }, 1000 );
		$('#side_bar').animate({ 
			height: "690px"
		  }, 1000 );
		$( '.google_map_foot' ).css( 'backgroundImage', 'url(images/bg_map_foot1.jpg)' );
	  },
	  function(){
		$('#map').animate({ 
			height: "400px"
		  }, 1000 );
		$('#side_bar').animate({ 
			height: "390px"
		  }, 1000 );
		$( '.google_map_foot' ).css( 'backgroundImage', 'url(images/bg_map_foot.jpg)' );
	  }
	); 
	
	
	
	
	
	
	
	
	

}); 
 
