$(document).ready(function(){

	/* -n- Remove top, root category from side category list */
	var categoryList = $('#SideCategoryList .SideCategoryListClassic').hide();
	var cat = categoryList.find('ul ul').html();
	categoryList.children('ul').html(cat);
	categoryList.show();
	
	// loads the cycle or whatever on the home page
	var url = window.location.pathname;
	url = url.toLowerCase();
	if (url == '/' || url == "/index.php") {
		if ($("#cycle").length > 0){
		$("#cycle").cycle({
			fx: "fade",
			pager: "#cycleNav",
			timeout: 3500,
			speed: 300,
			pagerAnchorBuilder: function(index, DOMelement) { return '<a href=""><span>&nbsp;</span></a>' }
		});
		}
	};

	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');
		}
	});
		
	/* -n- Add no right margin to edge grid items */
	$('#HomeFeaturedProducts .CustProdList li:last-child').addClass('noRightMargin');
	$('#LayoutColumn2 .ProductList.CustProdList li:nth-child(3n+3)').addClass('noRightMargin');
	$('#CategoryHeading .SubCategoryListGrid ul li:nth-child(4n+3)').addClass('noRightMargin');
	$("#PrimaryMenu > ul > li:last-child").addClass("last");
	
	
	/* -n- Remove the first 'none' radio box on the product page.  'none' is not a size option.  Can't seem to remove this on the backend. */
	var radioOptions = $('#productDetailsAddToCartForm .productOptionViewRadio ul li');
	$(radioOptions).each(function() {
		if ($(this).find('label > span.name').text()=="(None)") {
			$(this).remove();
		}
	});
	
	/* -n- The height of .Left should match the height of .Content */
	var contentHeight = $('#LayoutColumn2.Content').height();
	$('#LayoutColumn1.Left').css('height',contentHeight);
	
});
