// Javascript

// ------------------------
// On load Event 
// (can use $(document).ready(); from jQuery now)
// Not removing as might be using in other areas
// ------------------------
function addLoadEvent(func) 
{
	var oldonload = window.onload;
  	if (typeof window.onload != 'function') 
  	{
    	window.onload = func;
  	}
  	else 
  	{
    	window.onload = function() 
    	{
      		if (oldonload) 
      		{
        		oldonload();
      		}
      		func();
    	}
  	}
}


function jumpMenu(targ,selObj,restore){ //v3.0
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
	}

function popupWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
	}


/**
 * jQuery to call in supersleight (png fix for IE6)
 * 
 * DOES NOT BREAK OTHER BROWSERS!!
 * 
 */
$(document).ready(function()
{
	$('body').supersleight({shim: '/images/blank.gif'});
});


/**
 * jQuery function to show and then hide the basket feedback
 * 
 */
$(document).ready(function()
{
	$('#feedback-container').delay(500).fadeIn(500).delay(5000).fadeOut(500);
});


/**
 * jQuery function to clear searchbox on click and focus
 * Will automatically add 'search' to the box if it's clear on focusout
 * 
 */
$(document).ready(function()
{
	$('#searchTerm').focusin(function()
	{
		var search = $('#searchTerm').val();
		if(search == "search")
		{
			$('#searchTerm').val("");
		}
	});
	
	$('#searchTerm').focusout(function()
	{
		var search = $('#searchTerm').val();
		
		if(search == "")
		{
			$('#searchTerm').val("search");
		}
	});
	
	$('#searchTerm').click(function()
	{
		var search = $('#searchTerm').val();
		
		if(search == "search")
		{
			$('#searchTerm').val("");
		}
	});
});


/**
 * jQuery function to animate the swatch rollovers
 * 
 */
$(document).ready(function()
{
	// Anything with a class of .swatchtainer with a li inside has a hover event attached
	$(".swatchtainer li").hover(
		function()// Hover over
		{
			// First animate the found li to make it taller and slide it up
			$(this).animate({height: "45px", top: "-28px"}, "fast");
			
			// Find Then animate out the inner span to show the swatch
			$(this).find("span").animate({width: "92px", opacity: "show", left: "0"}, "normal");
		},
		function()// Hover out
		{	
			// First find then slide in the span to hide the swatch
			$(this).find("span").animate({width: "0px", opacity: "hide", left: "0"}, "fast");
			
			// Now slide down and reduce the height of the li
			$(this).animate({height: "17px", top: "0px"}, "normal");
		});// End of sub-functions
});


