$(document).ready(function(){ 
	$(document).pngFix(); 
	$(".with-shadow").load(function(){
		$(this).dropShadow({color: "#a8a8a8", blur: 4, top: 8, left: 8});
	});
	$(".left-menu>li a").click(function(){
		$(".left-menu>li").removeClass("selected");
		$(".left-menu>ul").hide();
		$(this).parent().addClass("selected");
		$(this).parent().next("ul").show();
		if ($(this).parent().next("ul").size() == 0) 
			return true;
		else 
			return false;
	});
	$(".colors li a").click(function(){
		/*	$("#item-pic").attr("src", $(this).attr("href"));
			$(".colors li a").css("border-color", "#cbcbcb");
			$(this).css("border-color", "#2281c4");
			$("#color option:contains('"+$(this).attr("title")+"')").attr("selected", "selected");
			images = imgs[$(this).attr("title")];
			if (images) {
				if (images.length >0) {
					$(".next-pic").show();
				} else {
					$(".next-pic").hide();
				}
			}
			return false;*/
	});
	
	$(".colors li img").load(function(){
		$(this).css("margin-top", (97-$(this).height())/2+"px");
	});
	
	$("#otmena_btn").click(function(){
		$(".order-params").hide();	
	});
	$("#ok_btn").click(function(){
		$(".order-params").hide();
		location.href = $("#add2cart").attr("href") + "&color="+$("#color").val()+"&size="+$("#size").val()+"&amount="+$("#buy-amount").val();
		
	});	
	$("#add2cart").click(function(){
		$(".order-params").show();
		return false;
	});
	$(".detail-pic").click(function(){
		images.push($("#item-pic").attr("src"));
		$("#item-pic").attr("src",images.shift());
	});
	$("#item-pic").load(function(){
		$(this).css({"width": "auto", "height":"auto"});
		height = $(this).height();
		width = $(this).width();
		if (width > height) {
			if (width > 300) {
				height = 300/width*height;
				width = 300;
			}
		} else {
			if (height > 300) {
				width = 300/height*width;
				height = 300;
			}
		}
		padding_top = (300-height)/2;
		$(this).css({"width": width+"px", "height":height+"px", "padding-top":padding_top+"px"});
	});
	if (typeof images!= "undefined") {
		if (images.length >0) {
			$(".next-pic").show();
		} else {
			$(".next-pic").hide();
		}
	}
	
	maxHeight = 0;
	$("ul.goods li .h1").each(function(){
		if ($(this).innerHeight() > maxHeight) {
			maxHeight = $(this).innerHeight();
		}
	});
	
	$("ul.goods li .h1").css("height", maxHeight+"px");
	
	$("ul.goods li p a img").load(function(){
		block = $(this).parent().parent();
		totalHeight = 0;
		block.parent().children().each(function(){
			totalHeight = totalHeight + $(this).innerHeight();
		});
		margin_top = 200 - totalHeight;
	//	block.css("margin-top", margin_top+"px");
	});
}); 

