jQuery.noConflict();
jQuery(document).ready(function() {
	init();
});

function init() {	
	//Fix for IE to avoid background 'wobble'
	if(jQuery.browser.msie)
	{
		jQuery(".header-nav-container").css("width", "957px").css("margin", "auto").css("background-position", "-13px 0px")
	}
	
	jQuery("#nav").css("position","relative").css("z-index","501");
	
	jQuery("#nav a").css("border-bottom","none");
	jQuery("#nav a span").css("white-space","nowrap");
	
	jQuery("#nav li").removeAttr("onmouseover").removeAttr("onmouseout").mouseenter( function() {showMenu(this, 1)}).mouseleave( function() {showMenu(this, 0)});
	jQuery("#nav li ul").css("left", "0px").css("display", "none");
	
	jQuery("#nav li ul li").mouseenter( function() { animateSubMenu(this, 1) }).mouseleave( function() { animateSubMenu(this, 0) });
	
	
	//Product listings
	jQuery(".product-image img").removeAttr("width").removeAttr("height");
	jQuery(".product-image img").mouseenter( function() { productEnlarge(this, 1) } ).mouseleave( function() { productEnlarge(this, 0) } );
	//jQuery(".product-shop h5 a").mouseenter( function() { productEnlargeOffset(this, 1) } ).mouseleave( function() { productEnlargeOffset(this, 0) } );
	//jQuery(".product-shop button").mouseenter( function() { productEnlargeOffset(this, 1) } ).mouseleave( function() { productEnlargeOffset(this, 0) } );
}

function showMenu(what, show)
{
	if (show)
	{
		jQuery(what).children("ul").slideDown(200);	
	}
	else
	{
		jQuery(what).children("ul").hide(150);	
	}
}

function animateSubMenu(what, show)
{
	var overkill = false;
	if (!overkill)
	{
		if (show)
		{
			jQuery(what).children("a").animate({paddingLeft: "0px", backgroundColor: "#2168cb"}, 100);
			jQuery(what).children("a").children("span").css("font-weight","normal");
			jQuery(what).children("a").children("span").animate({color: "#ffff00"}, 100);
		}
		else
		{
			jQuery(what).children("a").animate({paddingLeft: "0px", backgroundColor: "#1851a0"}, 300);
			jQuery(what).children("a").children("span").css("font-weight","normal");
			jQuery(what).children("a").children("span").animate({color: "#ffffff"}, 300);
		}
	}
/*
	{
		if (show)
		{
			jQuery(what).children("a").animate({paddingLeft: ".5em", backgroundColor: "#2168cb"}, 100);
		}
		else
		{
			jQuery(what).children("a").animate({paddingLeft: "0px", backgroundColor: "#1851a0"}, 300);
		}
	}
*/	
	else
	{
		if (show)
		{
			jQuery(what).children("a").animate({fontSize: "1.25em", backgroundColor: "#2168cb"}, 100);
			jQuery(what).children("a").children("span").animate({color: "#ffff00"}, 100);
		}
		else
		{
			jQuery(what).children("a").animate({fontSize: "1em", backgroundColor: "#1851a0"}, 300);
			jQuery(what).children("a").children("span").animate({color: "#ffffff"}, 300);
		}
	}
}

function productEnlarge(what, show)
{
	if (show)
	{
		jQuery(what).animate({width: "150px"}, 50);
	}
	else
	{
		jQuery(what).animate({width: "135px"}, 200);
	}
}

function productEnlargeOffset(what, show)
{
	what = jQuery(what).closest(".listing-item").children(".product-image").children("a").children("img");
	productEnlarge(what, show);
}

