/*
Title Home Page Categories
Purpose: code to expand and collapse category links
Written by: Sergei Filippov
Date: 17 February  2010
*/

	//when doc loads
	jQuery().ready(function(){
		jQuery('.expander').addClass('hide');	//hide the drop down
		jQuery('.switch').removeClass('hide');	//unhide button
		
		
		//bind,.hover action
		jQuery(".switch").hover(function(){
			jQuery(".expander").addClass("hide"); //hide any open boxes
			jQuery(".switch").removeClass("hover");
			var $_mItem = jQuery(this); //ref anchor obj
			var $_ddItem = $_mItem.next(); //what to dropdown obj
			
			var $_mPos = $_mItem.position();//get position of the anchor
			var $_ddPos = $_ddItem.position();//get position of the dropdown item

			//calculate the coordinates based on offset and height of item
			var ddTop = $_mPos.top + $_mItem.height();
			var ddLeft = $_mPos.left + 3;
			
			$_mItem.addClass("hover");
			$_ddItem.css({top: ddTop, left: ddLeft}).removeClass("hide");

		}, function() {
			//what happens when you exit
			jQuery(this).next().hover(function(){},function(){ jQuery(this).addClass("hide").prev().removeClass("hover"); }); 
		});
		
	});
