$(document).ready(function(){$("#catalog_zp span[rel=nav]").bind("click",{},function(){getSubZP($(this).attr("id"));});$("#catalog_sh span[rel=nav]").bind("click",{},function(){getSubSH($(this).attr("id"));});});function getSubZP(id) {var h=$("#ul"+id).html();if(!h){$.ajax({type:"POST",url:"/ajax.catalog.php",data:{"do":"getsubzp","pid":id},global:false,beforeSend:function(data){$("#cat_zp").trigger("click");showLoading(id);},success:function(data){$("#ul"+id).html(data);if(id>=1000)$("#ul"+id+" a[rel=thumb]").facebox({opacity:0.35});},error:function(data,error){alert(error);hideLoading(id);},complete:function(){}});} $("#ul"+id).toggle();} function getSubSH(id) {var h=$("#ul"+id).html();if(!h){$.ajax({type:"POST",url:"/ajax.catalog.php",data:{"do":"getsubsh","pid":id},global:false,beforeSend:function(data){$("#cat_sh").trigger("click");showLoading(id);},success:function(data){$("#ul"+id).html(data);if(id>=1000)$("#ul"+id+" a[rel=thumb]").facebox({opacity:0.35});},error:function(data,error){alert(error);hideLoading(id);},complete:function(){}});} $("#ul"+id).toggle();} function showLoading(id){$("#ul"+id).html(" Загрузка ...");} function hideLoading(id){$("#ul"+id).html("");} function createAnimateCartItem(etalon){var div=document.createElement("div");div.style.position="absolute";div.style.width=etalon.width()+"px";div.style.height=etalon.height()+"px";div.style.left=etalon.position().left+"px";div.style.top=etalon.position().top+"px";div.style.border="1px dashed #994444";return div;} function addToCart(pos,obj) {if(typeof pos!="undefined"&&pos!='') {$.ajax({type:"POST",url:"/ajax.backend.php",data:{"action":"cart","do":"add","pos":pos},dataType:"json",success:function(data){if(data.error==0)showNotify("Товар добавлен в корзину");else showNotify(data.result);},complete:function(){var div=createAnimateCartItem($(obj).parent().parent());$('body').append(div);$(div).stop(true);$(div).animate({width:$('#block_cart_table').width(),height:$('#block_cart_table').height(),left:$('#block_cart_table').offset().left,top:$('#block_cart_table').offset().top},function(){cartGetInfo();});setTimeout(function(){$(div).remove();},500);}});}} function cartAddQty(num) {var qty=document.getElementById('qty['+num+']');if(!qty.value)qty.value=0;if(qty.value<999) {qty.value=parseInt(qty.value)+1;cartEditOrder(num,qty.value);cartGetInfo();}} function cartDelQty(num) {var qty=document.getElementById('qty['+num+']');if(qty.value>0) {qty.value=parseInt(qty.value)-1;cartEditOrder(num,qty.value);cartGetInfo();}} function cartEditOrder(num,val) {$.post("/ajax.backend.php",{"action":"cart","do":"edit","id":num,"qty":val});} function cartDelRow(num) {if(num>=0) {$('#row'+num).empty();$.post("/ajax.backend.php",{"action":"cart","do":"del","del":num},function(data){if(data.error==0)showNotify("Позиция из корзины удалена");},"json");cartGetInfo();}} function cartGetInfo() {$.ajax({url:"/ajax.cart.php",type:"post",dataType:"json",data:{"what":"info"},cache:true,async:true,success:function(response){if(response.nums) {if($("#block_cart_table").get(0).display=="none")$("#block_cart_table").fadeIn(200);$("#block_cart_table").fadeOut(10);$("#block_cart_nums").html(response.nums);$("#block_cart_summ").html(response.summ);$("#block_cart_table").fadeIn(100);var discount=response.summ*response.discount/100;$("#discount").html(response.discount);$("#presumm").html(response.summ);$("#discsumm").html(discount);$("#cartsumm").html((response.summ-discount));} else {$("#block_cart_table").fadeOut(300);$("#presumm").html(0);$("#discsumm").html(0);$("#cartsumm").html(0);}},error:function(err){cld(err);showNotify("Ошибка: "+err);}});} var row_nextid=1;var uploadTimer;function shopPricesAddFile() {$("#submit").before(''+select+' -');row_nextid++;} function shopPricesDelFile(num) {if(num)$("#row"+num).remove();} function shopUploadPics() {$("#button_upload").attr("disabled","disabled");$("#status").html("Статус: Идет обработка изображений ");$.ajax({type:"POST",url:"/ajax.backend.php",data:{"action":"pictures","do":"getpics"},dataType:"json",global:false,async:true,success:function(data){if(data.error==0) {$("#noproc").html("0");showNotify(data.result);$("div#status").html(data.result);} else {$("div#status").html("Ошибка: "+data.result+"");} $("#button_upload").attr("disabled","");},error:function(){$("#status").html("Статус: Ошибка запроса ajax.backend.php");}});} function orderChangeStatus(newst,id) {$.post("/ajax.backend.php",{"action":"orders","do":"chstatus","status":newst,"id":id},function(data){if(data.error==0)showNotify(data.result);},"json");} function orderChangeItemStatus(newst,id,item) {$.post("/ajax.backend.php",{"action":"orders","do":"chitemstatus","status":newst,"id":id,"item":item},function(data){if(data.error==0)showNotify(data.result);},"json");} function orderDelOrder(id) {if(confirm('Удалить этот заказ ?')) {$.post("/ajax.backend.php",{"action":"orders","do":"del","id":id},function(data){if(data.error==0) {$("#row"+id).fadeOut(200).remove();showNotify(data.result);}},"json");}} function editComment(id,comment) {$.post("/ajax.backend.php",{"action":"comment","id":id,"comment":comment},function(data){if(data.error==0)showNotify(data.result);},"json");} function orderChangeNotice(user_id) {$.post("/ajax.backend.php",{"action":"notice","user_id":user_id,"do":"order_change"},function(data){if(data.error==0)showNotify(data.result);},"json");} function showNotify(text,stay) {if(text) {if(!stay)stay=false;$.noticeAdd({text:text,stay:stay});}} $(document).ready(function(){$("img[rel=adv]").addClass("alpha30");$("img[rel=adv]").hover(function(){$(this).stop(true).animate({opacity:0.8},500);});$("img[rel=adv]").mouseleave(function(){$(this).stop(true).animate({opacity:0.3},500);});});