$(document).ready(function(){
	$(".dropshadow").each(function(){
		$(this).width(parseInt($(this).children().width()));
		$(this).height(parseInt($(this).children().height()));
		$(this).append('<div class="shadow topLeft"></div><div class="shadow bottomRight"></div><div class="shadow topRight"></div><div class="shadow bottomLeft"></div>');
		//alert($(this).css("clear"))
		if($(this).attr("id")=="flashMovie"){
			var clear = "both";
			var marginleft = "10px"
		}else{
			var clear = $(this).children().css("clear");
			var marginleft = $(this).children().css("margin-left")
		}
		if($(this).children().css("float")=="right"){
			var position = "3px";
		}else{
			var position = "-3px";
		}		
		$(this).css({
			"clear":clear,
			"float":$(this).children().css("float"),
			"margin-top":$(this).children().css("margin-top"),
			"margin-right":$(this).children().css("margin-right"),
			"margin-bottom":$(this).children().css("margin-bottom"),
			"margin-left":marginleft,
			"left":position
		});
		$(this).children().css({
			"margin":"0 0 0 0"
		});
		$(this).children(":not(.shadow)").css({
			"position":"relative",
			"z-index":"700"
		});
		
	});
	$("a[href]:not([href^='http://www.leontinelinens.com'])").css({
		"background-image":"url('/images/icon_external_link.gif')",
		"background-repeat":"no-repeat",
		"background-position":"right",
		"padding-right":"8px"
	});
	$("#productThumbs li").each(function(i){
			$(this).attr("rel",i);							 
	});
	$("#productImages li").hide();
	$("#productImages li:eq(0)").fadeIn("slow");
	$("#productThumbs li:eq(0)").fadeTo("fast",0.4);
	$("#productThumbs li").click(function(){
		//alert($(this).attr('title'));
		$("#productThumbs li").fadeTo("fast",1);
		$(this).fadeTo("fast",0.4);
		$("#productImages li").fadeOut("fast");
		$("#productImages li:eq("+$(this).attr('rel')+")").fadeIn("slow");
	});
	if($("#productThumbs li").length<2){
		$("#productThumbs").css("display","none");
	}
	$("div.info p:last-child").css({
		"margin-botto":"5px",
		"line-height":"1.4em",
		"font-size":".9em"
	});
	$("#colOne .monogramGallery li a, #colOne .borderGallery li a, #colOne .quiltGallery li a").fancybox({'hideOnContentClick': true});
	$("a.form").fancybox({'hideOnContentClick': true});
	$("#search .textinput").focus(function(){
		$(this).attr("value","");
	});
	$("#search .textinput").blur(function(){
		if($(this).attr("value")==""){
			$(this).attr("value","Enter Keywords Here");
		}
	});
	$("img").each(function(){
		badURL = $(this).attr("src");
		if(badURL.indexOf('/images/uploads/gallery/small/http')!=-1){
			//alert("error");
			$(this).attr("src",badURL.substr(30));
		}
	});
});
