$(document).ready(function(){

//bcNav
	$('#SideCategoryList').bcNav();
		 
//Apply last child to main nav
	$("#Menu 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")
		.before('<div id="cycle-nav">')
		.cycle({
			fx: "fade",
			speed:   800,
			timeout: 6000, 
	  	pager:  '#cycle-nav'
		});
	 };
	
//Replace input field text	
	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"));	


//Apply last child to main nav
	$(".product #SideProductRelated .ProductList li:gt(2)").css("display","none");

//Add active class to categoy menu
	var loc_href = window.location.pathname;
		$('.Left #SideCategoryList ul li a').each(function () {
		if (loc_href == $(this).attr('href')) {
			$(this).parent("li").addClass('ActivePage');
		}
	});

//Custom Product page tabs
$('#tabs-content').before('<ul id="tabs"><li id="tab-1" class="selected">Description</li><li id="tab-2">Womens Size Chart</li><li id="tab-3">Mens Size Chart</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');
		});

	});

});
