$(document).ready(function(){

	$("#PrimaryMenu > ul > li:last-child").addClass("last");
	
	$('#PrimaryMenu > ul > li').each(function() {
		$(this).addClass(function() {
		  return "nav-" + $(this).index();
		});
	});
	
	$('#PrimaryMenu li.nav-6 a span').replaceWith('Jewelry, Gifts<br/> & Wearables');

	$("#cycle").cycle({
		fx: "fade"
	});
	
	$("#ProductReviews > a > img").replaceWith("write a review");
	$("#ProductReviews > a").addClass("button");
	
	$("#tabs-content #SideProductRelated .ProductList li:gt(3), #tabs-content #SideProductRecentlyViewed .ProductList li:gt(3)").remove();
	
	$(".ComparisonTable tr:contains(Brand)").remove();
	$(".ComparisonTable tr:contains(Availability)").remove();
	$(".ComparisonTable tr:contains(Other)").remove();
	
	$(".category .Content .ProductList li:nth-child(3n+1)").addClass("first");
	$(".category .Content .ProductList li:nth-child(3n+3)").addClass("last");
	
	$("#PurchaseGiftCertificate #SaveCertificate").replaceWith('<input type="submit" value="Add to Cart" id="SaveCertificate">');

	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"));	
	textReplacement($("#footer_nl_email"));	

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


	/*
		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');
		}
	});
		
	$('#SideCategoryList').bcNav({classify:true, staticinitlevel:1 }); 
	
	$('.Content img[style="float: left;"]').addClass('alignleft');
	$('.Content img[style="float: right;"]').addClass('alignright');
	
	$(".SubCategoryListGrid ul li.RowDivider, .SubCategoryListGrid ul li:last-child").remove();
	$(".SubCategoryListGrid li:nth-child(3n+1)").addClass("first");
	
	$('#tabs-content').before('<ul id="tabs"><li id="tab-1" class="selected">You May Also Like</li><li id="tab-2">Product Reviews</li><li id="tab-3">Recently Viewed</li></ul>');
	$('#tabs-content').addClass('js'); 
 
    $("#tabs li").each(function() {
 
        $(this).click(function() {
            var tabId = $(this).attr('id');
            var tabId = tabId.split('-');
            var tabContent = document.getElementById('tab-content-' + tabId[1]);
            tabContent.style.display = 'block';
            $(this).addClass('selected');
            $(this).siblings().removeClass('selected');
            $(tabContent).siblings().css('display','none');
        });
 
    });


});

