$(document).ready(function(){

	$("#PrimaryMenu > ul > li:last-child").addClass("last");

//Homepage cycle
	$("#cycle")
		.before('<div id="cycle-nav">')
		.cycle({
		fx: "fade",
		speed: 400,
		timeout: 4000,
		pager: '#cycle-nav'
	});


//Display Cart Contents in Site Header		
	var cartValue = $(".crt").html();
	var cartDigit;
	
	cartValue = jQuery.trim(cartValue); /*Trim whitespace for IE*/
	switch (cartValue)
	{
	case "":
	 $(".crt").html("<span class='item-no'>0</span><span class='item-txt'> items</span>");
	 number = 0;
	 break;
	case "(1 item)":
	 $(".crt").html("<span class='item-no'>1</span><span class='item-txt'> item</span>");
	 number = 1 ;
	 break;
	default:
	 //cartDigit = 3;
	  
	  
	 if(cartValue != ""){
	 splitup=cartValue.split(" ");
	 number = splitup[0].replace("(", "");
	 $(".crt").html("<span class='item-no'>" + number + "</span> <span class='item-txt'> items</span>");
	}
	 break;
	}

//Display Shop Headline on category main page
	var url = window.location.pathname;
	url = url.toLowerCase();
	if (url.indexOf("/categories.php") >= 0) {
		  $('#replace p').appendTo('#CategoryHeading h2 span');
	};

//Replace txt in input fields
	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_first_name"));
	textReplacement($("#nl_email"));	

/*
This is a short and simple script that will create an Active class for your custom pages menu links(if you have to use stuff like Category pages for your main navigation).
Keep in mind that this will also work for any other list (like custom Side Vendors, Side Categories, or Side Brands) by just changing the ID Selector.
**Credit to Krystin Rice
*/
	var loc_href = window.location.pathname;
		$('#PrimaryMenu a').each(function () {
		if (loc_href == $(this).attr('href')) {
			$(this).addClass('activePageLink');
		}
	});

//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: 5,
//	 	  scroll: 5,
//		  speed: 800
//   });

//	$("#cycle").cycle({
//		fx: "fade"
//	});
});
