function cycleImages(){
	var active = $('.shoplink .active');
	var next = (active.next().length > 0) ? active.next() : $('.shoplink a:first');
	next.css('z-index',2);
	active.fadeOut(1500,function(){
		active.css('z-index',1).show().removeClass('active');
		next.css('z-index',3).addClass('active');
	});
}

$(document).ready(function(){
	setInterval('cycleImages()', 7000);
	$("#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
	// // uncomment alert to see what the url is in browser if needed
	// //alert(url);
	// if (url == '/' || url == "/index.php") {
	// //RUN CYCLE
		// $("#cycle").cycle({
			// fx: "fade"
		// });
	// };
	
	// // loads only if the cycle selector exists
	// if ($("#cycle").length > 0){	
		// $("#cycle").cycle({
			// fx: "fade"
		// });
	// };
	
	var url = window.location.pathname
	if ($(".Breadcrumb").length > 0) {
		if (url == "/" || url == "/index.php" || $('.Breadcrumb ul li:nth-child(2)').html().indexOf("For Women") >= 0) {
			$('body').addClass('women')
			if ($("#CategoryHeading").length > 0) {
				$("#CategoryHeading .BlockContent").prepend("<img class='categorybanner' src='/templates/__custom/img/womencat.png' alt='' />")
			}
		}
		else if ($('.Breadcrumb ul li:nth-child(2)').html().indexOf("For Men") >= 0) {
			$('body').addClass('men')
			$(".footerimg").attr("src","/templates/__custom/img/menfooter.png")
			$("#Logo img").attr("src","/product_images/uploaded_images/gunfighter-logo-withgg.png").addClass("menlogo")
			if ($("#CategoryHeading").length > 0) {
				$("#CategoryHeading .BlockContent").prepend("<img class='categorybanner' src='/templates/__custom/img/mencat.png' alt='' />")
			}
		}
		else {$("body").addClass("women")}
	}
	else {
		$('body').addClass('women')
	}
	
	if ($(".menlogo").length > 0) {
		$(".footerimg").attr("src","/templates/__custom/img/menfooter.png")
		$("#Logo > a").attr("href","/mens-home/")
	}
	
	if ($(".ProductMain").length > 0) {
		if ($(".productOptionViewRadio").length > 0) {
			$(".productOptionViewRadio li").each(function() {
				var width = $(this).find("span").width()
				$(this).css("width",""+(width+22)+"px")
			})
		}
		$(".AddCartButton .BulkDiscount").prepend("<img class='cartbutton' src='/templates/__custom/img/cart.png' alt='' />")
	}
	
	//$("#PrimaryMenu .First a").html("Women's Home")
	
	/* if (url == "/" || url == "/index.php" || $('.Breadcrumb ul li:nth-child(2)').html().indexOf("For Women") >= 0) {
		$('body').addClass('women')
	}
	else if ($('.Breadcrumb ul li:nth-child(2)').html().indexOf("For Men") >= 0) {
		$('body').addClass('men')
		$(".footerimg").attr("src","/templates/__custom/img/menfooter.png")
	}
	else {$("body").addClass("women")} */
	
	$(".SideCategoryListClassic li").each(function() {
		if ($(this).html().indexOf("<ul>") >= 0) {
			$(this).addClass("hasdropdown");
		};
	});
	
	$(".RowDivider").remove()
	
	$(".ProductList li .ProductActionAdd a").addClass("button")
	
	if ($(".SubCategoryListGrid").length > 0) {
		$(".SubCategoryListGrid").find("li:nth-child(3n)").css("margin-right","0")
		$(".SubCategoryListGrid").find("li a").addClass("catlink")
		$(".SubCategoryListGrid").find("li").each(function() {
			$(this).append("<a class='viewmorecat' href='"+($(this).find(".catlink").attr("href"))+"'>VIEW PRODUCTS</a>")
		});
		//$(".SubCategoryListGrid li:last-child").remove()
		$(".SubCategoryListGrid li br").remove()
		$(".SubCategoryListGrid li a:nth-child(1)").css("display","block").addClass("catimg")
	}
	
	//if (window.location.pathname == '/shop-for-women/') {
//		$(".SubCategoryListGrid li:last-child").remove();
//	}
	
	
	$(".Left #SideNewsletterBox").remove()
	$(".Left #SideShopByBrand").remove()
	$(".Left #SideNewProducts").remove()
	
	$(".nowomen").removeClass("women")
	
	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); }
		});
	}
	
	$(".Right").remove()

	textReplacement($("#search_query"));
	textReplacement($("#nl_first_name"));
	textReplacement($("#nl_email"));	

//	jCarouselLite example -- you will need to add a <div class="ProductListContainer"> around the <ul>
//	in the HomeFeaturedProducts Panel

	$("#HomeFeaturedProducts .ProductListContainer").jcarousel({
	    visible: 4,
	 	scroll: 2,
		speed: 500,
		wrap: 'circular'
   });


	/*
		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).parent('li').addClass('ActivePage');
		}
	});

});
