if(window.opera) { 
         document.write('<link rel="stylesheet" type="text/css" href="assets/templates/nf_n/opera.css" />');
} 


function nf_alert(message) {
    $("td.ow_window").html(message);
    $("div.over").show();
    $("div.openwindow").fadeIn(30);
}

  $(document).ready(function(){
var hgt = $(document).height();
$("div.overover").css("height", hgt+"px");

    $("span#reg").click(function(){
      $("div.overover").show();
      $("div#regdiv").show();
      return false;
    })

   $("span.regclose").click(function(){
     $("div.overover").hide();
      $("div.regdiv").hide();
   })

   $("form#regf").ajaxForm({
        success: function(data) {
            nf_alert(data);
                 $("div.overover").hide();
                 $("div.regdiv").hide();
        }
    })

 $("span#chpass").click(function(){
      $("div.overover").show();
      $("div#forgot").show();
      return false;
    })

 $("span.fclose").click(function(){
   $("div.overover").hide();
      $("div.regdiv").hide();
 })

 $("span.fcheck").click(function(){
   phone = $("input.fphone").val();
   $.post("serve/checkphone.html",{phone:phone},
   function(data){
     if (data==1) {nf_alert("Новый пароль выслан на Ваш e-mail адрес."); $("div.regdiv").hide(); $("div.overover").hide();}
    else if (data==2) $("div.lower").slideDown();
     else nf_alert(data);
   })
 })

 $("span.fsend").click(function(){
   phone = $("input.fphone").val();
   fmail = $("input.fmail").val();
   $.post("serve/sendpass.html",{phone:phone, fmail:fmail},
   function(data){
     if (data==1) {nf_alert("Новый пароль выслан на Ваш e-mail адрес."); $("div.regdiv").hide(); $("div.overover").hide();}
     else nf_alert(data);

   })
 })
  })
  
  $(document).ready(function(){
  $(".cart_show").click(function(){
  $.post("serve/zakaz_list.html",{},function(data){$("#y_list").html(data); $("div.flyover").show();})
    $("div.overover").show();
  })

  $("span.close").live('click', function(){
    $("div.overover").hide();
    $("div.flyover").hide();
  })

  $("input[name=regme]").click(function(){
    $("div.inn_pass").slideToggle();
  })

 $("form#zzz").ajaxForm({
        success: function(data) {
if(data == "Спасибо за Ваш заказ!") {
               window.location.assign("http://www.naturefood.ru/thankyou.html");
             }
else
            nf_alert (data);
            
        }
    })

 $("input.tq_list").change(function(){
    tid = $(this).attr("id");
    newq = $(this).val();
    price = $("input.hideprice"+tid).val();
    $.post("serve/dop.html",{ tid: tid, newq: newq, price: price },
    function(data){
      $("span.y_itogo strong").html(data);
      $("span.result").html(data);
      $(this).next("input.hidenum").attr("value",newq);
    })
 })

 $("input[name=timeh]").change(function(){
   h = $(this).val();
   if (h<15 && h>2) {$(this).attr("value","15"); nf_alert("Доставка с 15:00 до 2:00.");}
   if (h<0) {$(this).attr("value","00"); nf_alert("Время не бывает отрицательным."); }
   if (h>23) {$(this).attr("value","23"); nf_alert("В сутках только 24 часа."); } 

 })

  $("input[name=timem]").change(function(){
   m = $(this).val();
   if (m<0) {$(this).attr("value","00"); nf_alert("Время отрицательным не бывает."); }
   if (m>59) {$(this).attr("value","00"); nf_alert("В часе только 60 минут.");}
 })

   $("input.cf_num").live('change',function(){
        tid = $(this).attr("id");
         trg = $(this).val();
         trg.replace(",",".");
           trq = parseFloat(trg);
           if (trg>-1)  {
         $("input[id='"+tid+"']").attr("value",trq);
        $.post("serve/cart_recalc.html",{'tid':tid, 'trq':trq}, 
           function(data){ 
             $(".cf_summ span").html(data[1]); 
              $(".result").html(data[1]);
              $("span#cst"+tid).html(data[0]);
              $("span#crst"+tid).html(data[0]); 
      }, "json" ); 
        } else {
               tpq = $("input[id='"+tid+"']").val();
               $(this).attr("value",tpq);
            }
    })

   $("input.t_price_input").live('change',function(){
       tid = $(this).attr("id");
         trg = $(this).val();
         trg.replace(",",".");
           trq = parseFloat(trg);
           if (trg>-1)
        $.post("serve/cart_recalc.html",{'tid':tid, 'trq':trq}, function(data){ $(".result").html(data[1]); $("span#crst"+tid).html(data[0]);}, "json" );
    })

   $(".cf_period").live("change", function(){ tid=$(this).attr("rel"); tp = $(this).children("option:selected").attr("value"); $.post("serve/per_change.html", {'tid':tid, 'tp':tp});  });

   $(".cf_forw span").live("click",function(){ 
     lan = $(".flyover").width();
      $(".order_table").animate({'margin-left': "-="+lan+"px"},300); 
    })

   $(".of_back span").live("click",function(){ 
     lan = $(".flyover").width();
      $(".order_table").animate({'margin-left': "+="+lan+"px"},300);
    })
})

$(document).ready(function(){
  $(".slide_click").live("click", function(){
    rep = $(this).attr("rel");
    dash = $("div#slh"+rep);
    dash.slideToggle(400);
    if ($(this).hasClass("slide_open")) {
        $(this).removeClass("slide_open").html("Вся категория");
    }else{
      $(this).addClass("slide_open").html("Свернуть");
    }
  })

  $(".bc_plus").click(function(){
   rel = $(this).attr("rel");
   dor = $("input#bci"+rel);
  dorval = dor.val().replace(",",".");
    vall = parseFloat(dorval);
   if (vall>=1) vall = vall+1;
   else {
    vall = vall+0.1;
    vall = vall.toFixed(1);
  } 
   dor.attr("value",vall);
   })

  $(".bc_minus").click(function(){
   rel = $(this).attr("rel");
   dor = $("input#bci"+rel);
    dorval = dor.val().replace(",",".");
    vall = parseFloat(dorval);
   if (vall<=0) vall=0;
   else if (vall<=1) { vall = vall-0.1; vall = vall.toFixed(1); }
   else if (vall>1) vall=vall-1;
   dor.attr("value",vall);
   })
})

 $(document).ready(function(){
  $("span.ow_x_close").click(function(){
    $(".openwindow").fadeOut(30);
    $(".over").hide();
   })
})


$(document).ready(function(){
   $("a.n_full_link").click(function(){
       $("div#nfull"+$(this).attr("id")).slideToggle(400);

       if ($(this).hasClass("open")) {
           $(this).removeClass("open");
           $(this).html("Подробнее &raquo;");
       }else{
         $(this).addClass("open");
         $(this).html("Свернуть");
       }
    return false;
    })
})

$(document).ready(function(){
$("span.refresh").click(function(){
  $.post(  "serve/cart_empty.html",{fid:"1"},   function(data){$("div.cart").html(data);}   );
   })

   $("span.del_it").click(function(){
   tid = $(this).attr("rel");
    $.post(  "serve/item_del.html",{tid:tid},   
      function(data){
    $("div.cart").html(data);
         });
   })

$('a.gal').lightBox();
})



