$(document).ready(function(){

//Activate AnythingSlider on Homepage	
	$('.anythingFader').anythingFader({
			autoPlay				: true,		// This turns off the entire FUNCTIONALY, not just if it starts running or not.
			delay						: 9000,   // How long between slide transitions in AutoPlay mode
			startStopped		: false,  // If autoPlay is on, this can force it to start stopped
			animationTime		: 600,    // How long the slide transition takes
			hashTags				: false,   // Should links change the hashtag in the URL?
			buildNavigation	: true,   // If true, builds and list of anchor links to link to each slide
			buildArrows     : true,      // If true, builds the forwards and backwards buttons
			buildStartStop  : false,   // If true, builds the start/stop button
			pauseOnHover		: true   // If true, and autoPlay is enabled, the show will pause on hover
	});
	
	$("#slide-jump").click(function(){
			$('.anythingFader').anythingFader(6);
	});
               
			
// REWRITE THE OUTPUT OF THE "(X ITEMS)" FIELD TO MATCH THEME
       var cartValue = $("#crt").html();
		var cartDigit;
	
		cartValue = jQuery.trim(cartValue); /*Trim whitespace for IE*/
		switch (cartValue)
			{
				case "":
				  $("#crt").html("0");
				  number = 0;
				  break;
				case "(1 item)":
				  $("#crt").html("1");
				  number = 1 ;
				  break;
				default:
				  //cartDigit = 3;
				   
				   
				  if(cartValue != ""){
					  splitup=cartValue.split(" ");
					  number = splitup[0].replace("(", "");
					  $("#crt").html(number);
					}
				  break;
			}

	$("#PrimaryMenu > ul > li:last-child").addClass("last");
	
	$(".SubCategoryListGrid ul li.RowDivider").remove();
	$(".SubCategoryListGrid ul li:last-child").remove();
	
	$("#ProductReviews > a > img").replaceWith("write a review");
	$("#ProductReviews > a").addClass("button");
	
//Add actice class on primary menu items
	var loc_href = window.location.pathname;
		$('#PrimaryMenu a').each(function () {
		if (loc_href == $(this).attr('href')) {
			$(this).parent("li").addClass('ActivePage');
		}
	});

//Clear inputs on focus	
	function textReplacement(input) {
		var originalvalue = input.val();
		input.focus(function() {
			if($.trim(input.val()) == originalvalue){ input.val(""); }
		});
		input.blur(function() {
			if($.trim(input.val()) == ""){ input.val(originalvalue); }
		});
	}

	textReplacement($("#search_query"));
	textReplacement($("#nl_email"));
	
//Display only 4 related products on prod page
	$("#SideProductRelated .ProductList li:gt(3)").css("display","none");

//	jCarouselLite example -- you will need to add a <div class="ProductListContainer"> around the <ul>
//	in the HomeFeaturedProducts Panel
	$("#HomeFeaturedProducts .ProductListContainer").jCarouselLite({
      btnNext: "#featured-next",
      btnPrev: "#featured-prev",
	    visible: 4,
	 	  scroll: 4,
		  speed: 800
   });

});
