// File: jquery.daihen.js
// 
// Author: Alex Baker / Panyamedia.com
// Date: 10/5/2010
// Contents: Custom menu navigation for Daihen website.
//

$(document).ready(function () {
	
	// Homepage Navigation:
	// Added click behavior to clicking on main divs on homepage.
	$("#products").click(function(event){	window.location.href = "products.php"; });
	$("#service").click(function(event){	window.location.href = "service.php"; });
	$("#sales").click(function(event){	window.location.href = "sales.php"; });
	$("#traininginfo").click(function(event){	window.location.href = "traininginfo.php"; });
	$("#nav_home").click(function(event){	window.location.href = "index.php"; });
	
	var duration = 0; // in milliseconds
	
	// Rollover effects for main menu.
	$('.menu_head').hover(
		function() { 
			// Hide any shown sub-navs, change the active head back to normal color, and remove its class as the active menu head.

			$('.menu_body').hide();
			$('.active').animate({backgroundColor:'#367CA9'}, duration); 
			$('h3.menu_head').removeClass('active');
			
			// Reveal current section
			$(this).next().slideToggle(50);
			$(this).addClass('active');
			$(this).animate({backgroundColor:'#89ACD4'}, duration);	
		
		}, 
		function() { 
			// Reset the background color back to its original state
			$(this).not('.active').animate({backgroundColor:'#367CA9'}, duration);
			
		}
	);
	
	// Rollover effects for sub menu (ie, highlight sub-navs)
	$('.menu_body li').hover(
		function() { $(this).animate({backgroundColor:'#89ACD4'}, duration);	}, 
		function() { $(this).animate({backgroundColor:'#367CA9'}, duration); }
	);
	
	// Rollover effect for main navmenu div:
	// 1. Clear out the coloring on the active menu header.
	// 2. Hide any subnavs.
	$('#navmenu').hover(
		function() { 	}, 
		function() { 
			$('.active').animate({backgroundColor:'#367CA9'}, duration); 
			$('h3.menu_head').removeClass('active');
			$('.menu_body').hide();
		}
	);
	
	/*
	// REMOVED:
	// Behavior to open menu on click:
	// Note: Abandoned in favor of making this automatic for h3 menu header rollovers. 
	//       See h3.menu_head .hover function below.
	
	$('h3.menu_head').click(function () {
		// Hide any shown sub-navs, change the active head back to normal color, and remove its class as the active menu head.
		$('.menu_body').hide();
		$('.active').animate({backgroundColor:'#367CA9'}, 150); 
		$('h3.menu_head').removeClass('active');
		
		// Reveal current section
		$(this).next().slideToggle('fast');
		$(this).addClass('active');
	});
	*/
});
