$(document).ready(function(){

// if user is signed in, show YouAreSignedIn menu, if user is signed out, show NotSignedIn menu
	if (
		$('#AreYouGuest').html() == '') {
			  $("#YouAreSignedIn").css('display','none');
			  $("#YouAreSignedIn").remove();
			  $("#NotSignedIn").show();
			}
			else {
			  $("#NotSignedIn").css('display','none');
			  $("#NotSignedIn").remove();
			  $("#YouAreSignedIn").show();
			}

//Last Child on Primary Nav	
	$("#PrimaryMenu > ul > li:last-child").addClass("last");
	
// loads the cycle or whatever on specific url in this case the home page
  //GET URL	
	 var url = window.location.pathname;
	 url = url.toLowerCase();
  //READ URL
	if (url == '/' || url == "/index.php") {
  //RUN CYCLE
		 $("#cycle").cycle({
			 fx: "fade"
		 });
	 };

//jQuery Dropdown for Brand List
    $('.dropdown_container').anyDropDown({
        dropDownElem: '.dropdown', //the class name for your drop down
        dropDownMenuElem: '.dropdown_menu', //the class name for the drop down menu
        slideDownEasing: 'easeInOutCirc', //easing method for slideDown
        slideUpEasing: 'easeInOutCirc', //easing method for slideUp
        slideDownDuration: 200, //easing duration for slideDown
        slideUpDuration: 200, //easing duration for slideUp
        closeMessage: 'Click to close menu...' //message shown when drop down is opened
    }); 
	
//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;
	}
	
//Text replacement in inputs
	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"));	

//	jCarouselLite Featured Products
	$(".home #HomeFeaturedProducts .ProductListContainer").jCarouselLite({
        btnNext: "#featured-next",
        btnPrev: "#featured-prev",
	      visible: 3,
	 	  scroll: 3,
		  speed: 800
   });
   
//	jCarouselLite New Products
	$(".home #HomeNewProducts .ProductListContainer").jCarouselLite({
        btnNext: "#new-next",
        btnPrev: "#new-prev",
	      visible: 3,
	 	  scroll: 3,
		  speed: 800
   });

//Shorten blog excerpt
$(".blog .FeedContent").each(function() {
    var characterlimit = 500;
    $(this).find('img').remove()
    $(this).find('span').removeAttr("style")
    var string = $(this).html().substr(0, characterlimit)
    $(this).html(string+" [..]")
});


	/*
		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');
		}
		});
});


