﻿jQuery(function(){
	jQuery('input[placeholder], textarea[placeholder]').placeholder();
});
 
$(document).ready(function(){
	$(".products .pm_item .sub").hide();
	//$(".question .ans").hide();
	$(".products .pm_item .lvl_2").click(function(){
		$(this).next(".sub").slideToggle(300);
		}); 
//	$(".question .qu").click(function(){
	//	$(this).next(".ans").slideToggle(300);
	//	});
	var prIt=$(".products .prod_items").parent().height();
	//$(".products .prod_items").height(prIt);
	//$(".products .prod_items .title").css("margin-bottom", $(".products .prod_items .title").parent().height()-$(".products .prod_items .title").prev("img").height()-$(".products .prod_items .title").next(".info").height()-$(".products .prod_items .title").height());
	//$(".products .prod_items .title").css("margin-bottom",$(".products .prod_items .title").height());
	//$(".products .prod_items")
	$("#left_menu .sub").hide();
	if($("#left_menu .item.active").parent().prev().hasClass("item"))
	{
		//alert("ddd");
		$("#left_menu .item.active").parent().prev().addClass("active");
	}
	if($("#left_menu .item.active").parent().parent().prev().hasClass("item"))
	{
		//alert("ddd");
		$("#left_menu .item.active").parent().parent().prev().addClass("active");
	}
	
	if($("#left_menu .item.active").parent().hasClass("sub")){
		$("#left_menu .item.active").parent().show();
	}
	$(
	"#left_menu .item.active").next(".sub").show();
	
	$("#left_menu .bullet").click(function(){
		$(this).parent().next(".sub").slideToggle(500);			
	});
	var $newdiv1 = $('<div class="prod_about"><div class="close">Закрыть</div><div class="cont"><img src="" alt="" /><a href="#" class="title" ></a><div class="info"></div><div class="price"></div><div class="descr"></div><strong class="add">В корзину</strong></div></div>')
		
		$(".prod_items .prod_img").click(function(){
			$(".prod_about").hide();
			$(".prod_about .cont img").removeAttr("src");
			$(".prod_items .descr").hide();
			$(".prod_items .prod_about").remove();
			
			//alert($(this).parent().position().left);
			$(this).parent().append($newdiv1);
			$(".prod_about .cont .title").html($(this).next(".title").html());
			$(".prod_about .cont .title").attr("href",$(this).next(".title").attr("href"));
			$(".prod_about .cont img").attr("src", $(this).children("img").attr("title"));
			//alert($(".prod_about .cont img").attr("src"));
			$(".prod_about .cont .info").html($(this).next().next(".info").html());
			$(".prod_about .cont .price").html($(this).next().next().next(".price").html());
			$(this).next().next().next().next(".descr").show();
			$(".prod_about .cont .descr").css("display","block");
			$(".prod_about .cont .title").html($(this).next(".title").html());
			$(".prod_about .cont .title").css("display","block");
			$(".prod_about .cont .title").attr("href",$(this).next(".title").attr("href"));
			$(".prod_about .cont .info").css("display","block");
			$(".prod_about .cont .add").css("display","inline");
			$(".prod_about .cont .descr").html($(this).next().next().next().next(".descr").html());
			$(".prod_about .cont .add").attr("onclick",$(this).next().next().next().next().next(".add").attr("onclick"));
			$(".prod_about .cont .add").attr("id",$(this).next().next().next().next().next(".add").attr("id"));
			$(".prod_about").css("left",-30);
			if($(this).parent().hasClass("search")){
				$(".prod_about").css("top",0);
			}
			else{
				$(".prod_about").css("bottom",-1);
			}
			$(".prod_about .close").click(function(){
			//alert("Юля!!!");
			$(".prod_about .cont img").attr("src"," ");
			$(".prod_about").fadeOut(300);
			$(".prod_items .descr").css("display","none");
			
		});
		$(".prod_about .cont img").load(function(){
				//alert("ddd");
				$(".prod_about").fadeIn(400);
				});
				
	$(".prod_items .add, table.nit .add, .products .inbask .add, .prod_about .add").click(function(){
			$(".full_bck").remove();
			$(".addcount_form").remove();
			//alert('ddd');
			$("body").append($('<div class="full_bck"/>'));
			//$("body").append($('<form class="addcount_form" method="post" id="" name="" />'));
            $("body").append($('<div class="addcount_form" id="" name="" />'));
			$(".addcount_form").append($('<div class="close_but" title="Закрыть"></div>'));
			$(".addcount_form").append($('<div class="header">Введите количество:</div>'));
			$(".addcount_form").append($('<input type="text" name="addcount_field" id="addcount_field" class="t_field" value="1"/>'));
			$(".addcount_form").append($('<div class="bask_add"><strong class="add">Добавить в корзину</strong></div>'));
            $(".addcount_form").append('</div>');
			$(".addcount_form .bask_add .add").attr("id",$(this).attr("id"));
			$(".full_bck").show();
			$(".addcount_form").fadeIn(500);
			$(".addcount_form .bask_add .add").click(function(){
				//alert($(this).attr("id")+" "+$(".addcount_form input").val())
				basketAdd($(this).attr("id"), $(".addcount_form input").val());
				$(".full_bck").hide();
				$(".addcount_form").fadeOut(300, function(){$(".full_bck").remove();$(".addcount_form").remove();});
				});	
			$(".full_bck").click(function(){
				$(".full_bck").hide();
				$(".addcount_form").fadeOut(300, function(){$(".full_bck").remove();$(".addcount_form").remove();});
			//	$(".full_bck").remove();
				//$(".addcount_form").remove();
			});
			$(".addcount_form .close_but").click(function(){
				$(".full_bck").hide();
				$(".addcount_form").fadeOut(300, function(){$(".full_bck").remove();$(".addcount_form").remove();});
			//	$(".full_bck").remove();
				//$(".addcount_form").remove();
			});

            $("#addcount_field").keypress(function(e){
                if(e.keyCode==13){
                    basketAdd($(".addcount_form .bask_add .add").attr("id"), $(".addcount_form input").val());
    				$(".full_bck").hide();
    				$(".addcount_form").fadeOut(300, function(){$(".full_bck").remove();$(".addcount_form").remove();});
                }
            });
            
		});			
				
				
	});
		$(".prod_items .add, table.nit .add, .products .inbask .add, .prod_about .add").click(function(){
			//alert('ddd');
			$("body").append($('<div class="full_bck"/>'));
			//$("body").append($('<form class="addcount_form" method="post" id="" name="" />'));
            $("body").append($('<div class="addcount_form" id="" name="" />'));
			$(".addcount_form").append($('<div class="header">Введите количество:</div>'));
			$(".addcount_form").append($('<div class="close_but" title="Закрыть"></div>'));
			$(".addcount_form").append($('<input type="text" name="addcount_field" id="addcount_field" class="t_field" value="1"/>'));
			$(".addcount_form").append($('<div class="bask_add"><strong class="add">Добавить в корзину</strong></div>'));
            $(".addcount_form").append('</div>');
			$(".addcount_form .bask_add .add").attr("id",$(this).attr("id"));
			$(".full_bck").show();
			$(".addcount_form").fadeIn(500);
			$(".addcount_form .bask_add .add").click(function(){
				//alert($(this).attr("id")+" "+$(".addcount_form input").val())
				basketAdd($(this).attr("id"), $(".addcount_form input").val());
				$(".full_bck").hide();
				$(".addcount_form").fadeOut(300, function(){$(".full_bck").remove();$(".addcount_form").remove();});
				});	
			$(".full_bck").click(function(){
				$(".full_bck").hide();
				$(".addcount_form").fadeOut(300, function(){$(".full_bck").remove();$(".addcount_form").remove();});
			//	$(".full_bck").remove();
				//$(".addcount_form").remove();
			});
			$(".addcount_form .close_but").click(function(){
				$(".full_bck").hide();
				$(".addcount_form").fadeOut(300, function(){$(".full_bck").remove();$(".addcount_form").remove();});
			//	$(".full_bck").remove();
				//$(".addcount_form").remove();
			});
            
            $("#addcount_field").keypress(function(e){
                if(e.keyCode==13){                    
                    basketAdd($(".addcount_form .bask_add .add").attr("id"), $(".addcount_form input").val());
    				$(".full_bck").hide();
    				$(".addcount_form").fadeOut(300, function(){$(".full_bck").remove();$(".addcount_form").remove();});
                }
            });
		});
			
		
});

$(document).ready(function(){
				
				$("area[rel^='prettyPhoto']").prettyPhoto();
				$(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'facebook',slideshow:false, autoplay_slideshow: false});
				$(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'fast',slideshow:10000, hideflash: true});
				
				$(".products:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'facebook',slideshow:false, autoplay_slideshow: false});
				$(".products:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'fast',slideshow:10000, hideflash: true});
				
				
				$("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({
				custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
				changepicturecallback: function(){ initialize(); }
				});
				$("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({
				custom_markup: '<div id="bsap_1259344" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div><div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
				changepicturecallback: function(){ _bsap.exec(); }
				}); 
								
	});  
	
	

