$(document).ready(function(){
	$(".ninput1").blur(function(){
		qty = $(this).val();
		$(this).next("b").html(qty);
		$(this).next("b").append("шт.");
	});
});
$(function(){
$(".home_mul lie").hover(
  function () {
    $(this).children("div").show();
  },
  function () {
    $(this).children("div").fadeOut();
  });

  $('#mycarousel div').click(function() {
        var color=$(this).attr("color");
        var drel=$(this).attr("rel");

        $('#mycarousel div').parent().removeClass("act");
        $(this).parent().addClass("act");
      
        $(".color").hide();
        $(".color"+drel).show();
        $(".pod_mask").css("background",color+"");

  });
  
//  hidding obj info
  $(".object_list li").each(function(){$(this).css("cursor", "pointer"); $(this).children("span").css("background-color", "#f7cb2c"); $(this).children("strong").css("color", "#000"); $(this).children("span, strong").animate({top: 80}).css("opacity", "0");});
//	show obj info wrapper
  $(".object_list li").hover(function(){
	  $(this).children("span").css("border-left", "solid 5px #555").css("margin-left", "-5px");
	  $(this).children("img").animate({opacity: 0.6}, 1000);
	  $(this).children("span, strong").animate({top: 10, opacity: 0.6}, 600, function(){
		  $(this).children("strong").animate({opacity: 1}, 100);
	  });
  }, function(){
	  $(this).children("img").animate({opacity: 1}, 600);
	  $(this).children("span, strong").animate({opacity: 0}, 600);
  });
  
////	cool menu fading in wrapper
//  $(".home_mul li").children("div").css("opacity", "0");
//  $(".home_mul li").hover(function(){
//	  $(this).children("div").animate({opacity: 1}, 900);
//  }, function(){
//	  $(this).children("div").animate({opacity: 0}, 900);
//  });

  
    $("#order_send_btn").click(function() {
        var sendBtn = document.getElementById("send_btn_cont");
        sendBtn.innerHTML = '<span style="color:white;font-size:16px;font-weight:bold;">Подождите, идет отправка...</span>';

        var t=false;
        t = checkadd();
        if (t) {
            var name = $("#order_form_name").attr('value');
            var email = $("#order_form_email").attr('value');
            var phone = $("#order_form_phone").attr('value');
            var comment = $("#order_form_comment").attr('value');
            var mm = '';
//            $(".ninput1").each(function(){
//                if ($(this).attr('value') > 0) {
//                    if (mm=='')
//                        mm += $(this).attr('name') + ':' + $(this).attr('value');
//                    else
//                        mm += ',' + $(this).attr('name') + ':' + $(this).attr('value');
//                }
//            });
            $(".ctd3").children("input").remove();
            $(".ctd3").children("b").css("visibility", "visible");
            $(".ctd3").each(function(){
            	if($(this).children("b").html()=="" || $(this).children("b").html()=="0"){
                	$(this).parent("tr").remove();
                }
            });
            order = "<table width=600 border=1>"+$(".calc_table").html()+"</table>";
            cost = $("#total_cost").html();
            $.post("/ajax/aj_order.php",{name:name,email:email,phone:phone,comment:comment,order:order,cost:cost},function(data){
                if(data!=""){
                    sendBtn.innerHTML = '<span style="color:white;font-size:16px;font-weight:bold;">' + data + '</span>';
	            }
	        });
        }
    });

$(".vid").click(function(){
	height = $("#wrap").height();
	$(".vid_blk").css("visibility", "visible");
	$(".favor_podl").css("height", height+"px").show();
	return false;
});
$(".favor_podl").click(function (){
	$(this).hide();
	$(".vid_blk").css("visibility", "hidden");
});
    
$(".home_mul lie").hover(
  function () {
    $(this).children("div").show();
  },
  function () {
    $(this).children("div").fadeOut();
  });

  $('#mycarousel div').click(function() {
        var color=$(this).attr("color");
        var drel=$(this).attr("rel");

        $(".color").hide();
        $(".color"+drel).show();
        $(".pod_mask").css("background",color+"");

});



  $('.ncont_table a').click(function() {
       var arel = $(this).attr("rel");
       $('.ncont_table a[class="act"]').removeClass("act");
       $(this).addClass("act");
       ///$(".ncontact_block:visible").css("zIndex","10").hide("explode", 1000, function() {$(".ncontact_block"+arel).css("zIndex","5").show();   });
       //$(".ncontact_block:visible").hide("explode", 1000);
       //$(".ncontact_block"+arel).show("explode", 1000);
       $(".ncontact_block").css("visibility", "visible");
       //$(".ncontact_block"+arel).show();

       return false;
  });


  $('.vprofn_left span').click(function() {
       var ahtml = $(this).html();
       $('.vprofn_left span[class="act"]').removeClass("act");
       $(this).addClass("act");

       $(".vprofn_right img:visible").hide();
       $(".vpr"+ahtml).show(); 
       return false;
  });




  $('.ncont_table a').click(function() {
       var arel = $(this).attr("rel");
       $('.ncont_table a[class="act"]').removeClass("act");
       $(this).addClass("act");
       ///$(".ncontact_block:visible").css("zIndex","10").hide("explode", 1000, function() {$(".ncontact_block"+arel).css("zIndex","5").show();   });
       //$(".ncontact_block:visible").hide("explode", 1000);
       //$(".ncontact_block"+arel).show("explode", 1000);
       $(".ncontact_block:visible").hide();
       $(".ncontact_block"+arel).show();

       return false;
  });



});

function recost(){
  var allcost=0;

  //allcost = $("#item1").attr("cost")*$("#item1").attr("value") + $("#item71").attr("cost")*$("#item71").attr("value") + $("#item72").attr("cost")*$("#item72").attr("value");

    $(".ninput1").each(function(){
                if ($(this).val() > 0) {
                    allcost += $(this).attr('cost') * $(this).attr('value');
                }
//                $(this).attr("qty", $(this).attr('value'));
            });


  var orderText = document.getElementById("total_cost");
  orderText.innerHTML = allcost;
}
;

function got() {
    $("div#order_text").css("display", "block");
}

function order_click() {
    $("div#order").slideDown("slow");
    timeoutId = setTimeout('got()', 1000);
}

function checkadd(form)
{
  var msg='';
  if(($("#order_form_fio").attr("value")=='') || ($("#order_form_fio").attr("value")=='Ф.И.О.')) { msg += '* Не заполнено поле "Ф.И.О."\n'; }
  if(($("#order_form_email").attr("value")=='') || ($("#order_form_email").attr("value")=='E-mail')) { msg += '* Не заполнено поле "Email"\n'; }
  if(($("#order_form_phone").attr("value")=='') || ($("#order_form_phone").attr("value")=='Телефон')) { msg += '* Не заполнено поле "Телефон"\n'; }
  if(msg!='') { alert("Произошли ошибки:\n"+msg); return false; }
  else { return true; }
}

