$(document).ready(function()
{
	$('#quicksearch_form input').click(function(e){
		$(this).val('');
	})
	
	$('.home_cat').click(function() {
		window.location = $(this).find('a').attr('href');
	})
	
	// product image zoom
	$(".jqzoom").jqzoom();
	
	//var width = $(".jqzoom img").attr('width');
	//$(".jqzoom").css('margin-left', (130-width)/2);
	

	$("form.nice_form .checkbox").jqTransform();
	$("form.nice_form .nice_select").jqTransform();
	
	$("fieldset.product_engraving input").focusin(function() {
		$(this).parent('fieldset').addClass('focused');
	})
	
	$("fieldset.product_engraving input").focusout(function() {
		$(this).parent('fieldset').removeClass('focused');
	})
	
	$(".sitemap li .plusicon").click(function() {
		$(this).parent('li').find('ul').slideToggle();
	})
	
	
	
	// show hide engraving fields on the cart
	
	*$(".engraving_btn").toggle(
	  function (e) {
		id = $(this).attr('id').substr(14);
	    $('#engraving_fields_'+id).slideDown('slow');
		$(this).html("<span><span>hide engraving</span></span>")
		// Prevent page jump on click
	    e.preventDefault();
		
	  },
	  function (e) {
	    id = $(this).attr('id').substr(14);
	    $('#engraving_fields_'+id).slideUp('slow');
		$(this).html("<span><span>set engraving</span></span>")
		// Prevent page jump on click
	    e.preventDefault();
	  }
	);
	
	// homepage image rotation
	
	var hpjsIntervalTime = 5000;
	$("#home_feature div").css("display", "none");
	$("#home_feature div:first-child").fadeIn("fast").addClass("active");

	var homepageFeatureJS = setInterval(switchHomeFeature, hpjsIntervalTime);

	function switchHomeFeature(){
		var currentShowing = $("#home_feature div.active");
		if($("#home_feature div:last-child").hasClass("active")){
		currentShowing.fadeOut("fast", function(){ $("#home_feature div:first-child").fadeIn("fast").addClass("active"); }).removeClass("active");	
		}else{
		currentShowing.fadeOut("fast", function(){ $(this).next("div").fadeIn("fast").addClass("active"); }).removeClass("active");
		}	
	}

	$("#home_feature div").mouseenter(function(){
	clearInterval(homepageFeatureJS);				    
	}).mouseleave(function(){
	homepageFeatureJS = setInterval(switchHomeFeature, hpjsIntervalTime);	   
	});

	
})
