function totalUpd(){$("#startOrderProcess").attr("disabled","true");var a="clientChoice=";for(q=0;q<inCart.length;q++){if(inCart[q]!=0){a=a+"|"+inCart[q]}}$.ajax({type:"POST",data:a,url:"http://"+document.domain+"/bbm/smartcart/service/totalCalc.php",success:function(b){responseProcess(b);$("#o").text(oldPrice);if((oldPrice-newPrice)>0){$("#n").text(newPrice);$("#e").text(oldPrice-newPrice);$("#pn").show()}else{$("#pn").hide()}$("#startOrderProcess").attr("disabled","")}})}function tyingShow(){$("#products div").each(function(){if($(this).hasClass("product-recommended")){$(this).removeClass("product-recommended").addClass("product-box");$(this).children(" .title").html('<img src="http://'+document.domain+'/bbm/smartcart/images/product-header.png" width="750" height="5" />');$(this).children(" .footer").html('<img src="http://'+document.domain+'/bbm/smartcart/images/product-footer.png" width="750" height="5" />')}});var a="clientChoice=";for(q=0;q<inCart.length;q++){if(inCart[q]!=0){a=a+"|"+inCart[q]}}$.ajax({type:"POST",data:a,url:"http://"+document.domain+"/bbm/smartcart/service/tyingProducts.php",success:function(d){var e=d.split("|");var c=$("#products div[id]");var b=0;for(q=0;q<e.length;q++){for(w=0;w<c.length;w++){b=c.eq(w).attr("id").split("_");b=b[1];if(b==e[q]){c.eq(w).removeClass("product-box").addClass("product-recommended");c.eq(w).children(" .title").html('<img class="pngfix" src="http://'+document.domain+'/bbm/smartcart/images/title-recommended.png" width="750" height="44" />');c.eq(w).children(" .footer").html('<img class="pngfix" src="http://'+document.domain+'/bbm/smartcart/images/bg-recommended-bottom.png" width="750" height="4" />')}}}}})}function responseProcess(a){a=a.split("&");if(!empty(a[0])){a[0]=a[0].split("|");a[0].sort();while(empty(a[0][0])&&!empty(a[0])){a[0].shift()}complectInCart.length=0;for(q=0;q<a[0].length;q++){complectInCart.push(a[0][q])}}if(!empty(a[1])){a[1]=a[1].split("|");a[1].sort();while(empty(a[1][0])&&!empty(a[1])){a[1].shift()}singleInCart.length=0;for(q=0;q<a[1].length;q++){singleInCart.push(a[1][q])}}oldPrice=a[2];newPrice=a[3]}function empty(){var c=arguments;var b=c.length;var d=0;if(b==0){throw new Error("Empty isset")}while(d!=b){if(typeof(c[d])=="undefined"||c[d]===null||c[d]===""||c[d]===0||c[d]==="0"||c[d]===false){return true}else{d++}}return false}function addToCart(f){var b=0;f=f.split("_");for(q=0;q<inCart.length;q++){if(inCart[q]==f[1]){b=1}}if(b==0){if(cartIndex==0){$("#cart_w").slideDown("slow")}var e="<div class='product' id='inCart_"+f[1]+"'>  </div>";$(e).appendTo("#cart");var c="#pr_"+f[1]+" span";$(c).each(function(){if($(this).hasClass("recommended")){$(this).remove()}});var d=$("#fpr_"+f[1]+" :input");var a=d.eq(2).val();$("#inCart_"+f[1]).append('<table width="71" height="71" border="0" cellpadding="0" cellspacing="0"><tr><td width="71" height="71" align="center" valign="middle"><img src="'+a+'" /></td></tr></table>');$("#inCart_"+f[1]).append('<a href="#" class="title">'+d.eq(0).val()+"</a>").append('<span class="price"> Цена: <strong>'+d.eq(1).val()+"</strong> руб.</span>");$("<a class='delete-product' href='#'> удалить из корзины </a>").appendTo("#inCart_"+f[1]).click(function(){var g=$(this).parent("div[id]").attr("id").split("_");$(this).parent("div[id]").remove();for(q=0;q<inCart.length;q++){if(inCart[q]==g[1]){if(inCart.length>1&&q!=inCart.length-1){for(w=q;w<inCart.length-1;w++){inCart[w]=inCart[w+1];inCart[w+1]=0}}else{inCart[q]=0}cartIndex--;if(cartIndex==0){$("#cart_w").slideUp("slow");$("#cartShow").fadeOut("slow")}else{$("#prNum").fadeOut(500);setTimeout(function(){$("#prNum").text(cartIndex)},500);$("#prNum").fadeIn(500)}setCookie("infodvd_inCart",inCart.join("|"),150);setCookie("infodvd_cartIndex",cartIndex,150)}}$("#cartSum").fadeOut("slow",function(){$(this).hide();totalUpd();$(this).fadeIn("slow")});tyingShow();$("#pr_"+f[1]).slideDown("slow")});inCart[cartIndex]=f[1];cartIndex++;if(cartIndex==1){$("#prNum").hide();$("#cartShow").fadeIn(500)}$("#prNum").fadeOut(500);setTimeout(function(){$("#prNum").text(cartIndex)},500);$("#prNum").fadeIn(500);setCookie("infodvd_inCart",inCart.join("|"),150);setCookie("infodvd_cartIndex",cartIndex,150)}else{alert("этот товар уже есть в корзине")}}function cartTrigger(a,c){var b=0;var d=new Array();d=a.split(c);for(b=0;b<d.length;b++){$("#add_"+d[b]).trigger("click")}}function preload(a){if(typeof document.body=="undefined"){return}try{var d=document.createElement("div");var b=d.style;b.position="absolute";b.top=b.left=0;b.visibility="hidden";document.body.appendChild(d);d.innerHTML='<img src="'+a.join('" /><img src="')+'" />'}catch(c){}};
