$(document).ready(function(){	

	$("#Menu li:last-child").addClass("last");
	
	$(".SideCategoryListClassic ul:last").addClass("last");
	
	$("#SideProductRelated li:gt(3)").hide();

	$("#cycle").cycle({
		fx: "fade"
	});

	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"));
	
	$("#ProductReviews a[onclick*=show_product_review_form]").addClass("button");
	$("#ProductReviews a[onclick*=show_product_review_form] img").replaceWith("Write a Review");

	$("#location-btn a").click(function(){
		$("#location-panel").slideToggle("fast");
		$(this).toggleClass("active"); return false;
	});

	// For Side Category List -- Uncomment to use
	// I made some small changes that might be helpful.  It puts a class only on the parent ul - 'ActivePageContainer' and the child li - 'ActivePage'.  There might be some issues to sort out if the menu is more than 1 level deep.
	
	function parseUri(sourceUri){

	var uriPartNames = ["source","protocol","authority","domain","port","path","directoryPath","fileName","query","anchor"],
	uriParts = new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d* <smb://d*>))?)((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\ <smb://?(%5B%5E#%5D*)>\?([^#]*) <smb://?(%5B%5E#%5D*)>)?(?:#(.*))?").exec(sourceUri),
	uri = {};

	for(var i = 0; i < 10; i++){
	uri[uriPartNames[i]] = (uriParts[i] ? uriParts[i] : "");
	}

	/* Always end directoryPath with a trailing backslash if a path was present in the source URI
	Note that a trailing backslash is NOT automatically inserted within or appended to the "path" key */
	if(uri.directoryPath.length > 0){
	uri.directoryPath = uri.directoryPath.replace(/\/?$/, "/");
	}

	return uri;

	}

	var url = window.location; // this gets the current url
	$(".SideCategoryListClassic ul li a").each( function (){ // for each menu item in the UL start processing...

	var href = $(this).attr('href'); // this is an array of the items in the menu item in the loop
	if ( href == url ) {
	// if the current category = the category of the the menu item in the loop...
	// in this case if the url category is NCAA and the menu "a" is NCAA, then proceed below to add the class
	$(this).parent().addClass('ActivePage'); // add class "ActivePage" to the LI of the "a"
	$(this).parent().parent().addClass('ActivePageContainer');
	}

	});
	//end side category list active class

});
