jQuery(document).ready(function(){
	
	// unobtrusive youtube
	$('body #content').youtubeLinksToEmbed();
	
	// stupid IE doesn't support last/first selectors so...
	$(":first-child").addClass("first");
	$(":last-child").addClass("last");
	
	// autoclear
	$(".autoclear").each(function(){
		$(this).attr("title", $(this).attr("value"));
	});
	$(".autoclear").focus(function(){
		if ($(this).attr("title") == $(this).attr("value"))
			$(this).attr("value", "");
	});
	$(".autoclear").blur(function(){
		if (!$(this).attr("value") || $(this).attr("value") == "")
			$(this).attr("value", $(this).attr("title"));
		else
			$(this).removeClass("autoclear");
	});
	
	// zebra stripes
	$(
		"table.zebra tbody tr:odd, "
		+ "table#cart tbody tr:odd"
	).addClass('zebra1');
	
	// add input classes since IE can't do attribute selectors
	$("input[@type=text]").addClass("text");
	$("input[@type=password]").addClass("password");
	
	
	// \/ -------------- ANGELA STONE -------------- \/
	
	$('ul#navlist li').hover(
		function(){ $(this).addClass('hover'); },
		function(){ $(this).removeClass('hover'); }
	);
	
	/*$("ul#navlist li.active ul").addClass("navsub");
	$("ul#navlist li.active ul").appendTo("#nav");
	$("ul#navlist li.active").each(function(){
		if ($(this).parent().parent().attr("nodeName") == "LI") {
			$(this).parent().parent().addClass("active");
			$(this).parent().addClass("navsub");
			$(this).parent().appendTo("#nav");
		}
	});*/
	
	$("form#oss-filter select").change(function(){
		$("form#oss-filter").submit();
	});
	
	if ($("#product-thumbs a").length == 1)
		$("#product-thumbs").remove();
	$("#product-thumbs a.first").addClass("active");
	$("#product-thumbs a").click(function(){ 
		if ($(this).attr("class") && $(this).attr("class").indexOf("active") > -1) {
			alert("This image is already enlarged...");
		}else {
			var xurl = $(this).attr("rev");
			var ximg = $(this).attr("href");
			$("#product-image a").attr("href", xurl);
			$("#product-image img.first").removeAttr("width");
			$("#product-image img.first").removeAttr("height");
			$("#product-image img.first").attr("src", ximg);
			$("#product-thumbs a").removeClass("active");
			$(this).addClass("active");
		}
		return false;
	});
	
	// float clearers
	$("#nav, .sidebar-box").append("<div style=\"clear:both;height:1px;overflow:hidden;\">&nbsp;</div>");

});
