function updateQuantity(c,d){if(IsNumeric(document.getElementById(c).value)==false||document.getElementById(c).value==0){if(document.getElementById(c).value<=0){$.prompt("Quantity should be greater than zero")}else{$.prompt("Quantity should be numeric")}$("#"+c).val("1");var b=document.getElementById(c).value;var a="/shopping/updateQuantity";$.ajax({type:"GET",url:a,data:"itemId="+d+"&newQty="+b,success:function(h){if(h!=null){var g=c.replace("txtquan","");var f=document.getElementById("txtprice"+g).value*document.getElementById(c).value;var e=roundNumber(f,2);document.getElementById("tdtotprice"+g).innerHTML="$"+e;document.getElementById("tdNetAmt").innerHTML="$"+h}}});document.getElementById(c).focus()}else{var b=document.getElementById(c).value;var a="/shopping/updateQuantity";$.ajax({type:"GET",url:a,data:"itemId="+d+"&newQty="+b,success:function(h){if(h!=null){var g=c.replace("txtquan","");var f=document.getElementById("txtprice"+g).value*document.getElementById(c).value;var e=roundNumber(f,2);document.getElementById("tdtotprice"+g).innerHTML="$"+e;document.getElementById("tdNetAmt").innerHTML="$"+h}}})}}function delItem(a){$.prompt("Are you sure you want to delete\n this Item from the Cart?",{callback:confirmdelItem,buttons:{Yes:a,No:"0"}})}function confirmdelItem(b,a,c){if(b!="0"){$.ajax({url:"/shopping/cart/removeItem/"+b,type:"GET",success:function(f){var e=$("#dkp-cart-item-counts").val();e=e-1;$("#dkp-cart-item-counts").val(e);if(e!=0){$("#dkp-cart-item-"+b).remove();document.getElementById("tdNetAmt").innerHTML="$"+f;var d=getCartItems();getCartCountItems()}else{window.location.href="/shopping/cart/"}}})}}function editItem(e,d,b,a,c){window.location.href="/design/"+e.replace(" ","+")+"/"+d+"/"+b+"/"+a+"/"+c}function IsNumeric(c){var a="0123456789";var d;var b=true;if(c.length==0){return false}for(i=0;i<c.length&&b==true;i++){d=c.charAt(i);if(a.indexOf(d)==-1){b=false}}return b}function continueshop(a){if(a!=""){window.location.href="/home/?pid="+a}else{window.location.href="/home"}}function mycallbackform(b,a,c){if(b=="Success"){$.prompt.close();window.location.href="/shopping/cart/billing-shipping"}}function checkout(e,k,j,h,g,d){var a=$("#dkp-cart-item-initialcounts").val();var f=0;var b=0;for(var c=1;c<=a;c++){if($("#tdShopping-1")){if($("#selectProductShop"+c).val()==""||$("#selectColorShop"+c).val()==""||$("#selectSizeShop"+c).val()==""){f=1;break}}}for(var c=1;c<=a;c++){if($("#tdShopping-1")){if($("#txtSpecialItem"+c).val()=="0"){b=1}}}if(f==1||b==0){if(b==0){$.prompt("Please purchase atleast one item before checkout.")}else{$.prompt("Please complete the Product customization for all the Items")}}else{$.ajax({type:"GET",url:"/shopping/checkCouponCode",data:"CouponCode="+$("#txtCouponCode").val(),success:function(l){$("#tdvalidate").html("");if(l=="1"){if(e=="s"){if(h!==""){if(d!=""){window.location.href="https://www.donkeyts.com/shopping/cart/billing-shipping?id="+j+"&id1="+h+"&cid="+g+"&pid="+d}else{window.location.href="https://www.donkeyts.com/shopping/cart/billing-shipping?id="+j+"&id1="+h+"&cid="+g}}else{if(d!=""){window.location.href="https://www.donkeyts.com/shopping/cart/billing-shipping/?pid="+d}else{window.location.href="https://www.donkeyts.com/shopping/cart/billing-shipping/"}}}else{if(h!==""){if(d!=""){window.location.href="http://"+k+"/shopping/cart/billing-shipping?id="+j+"&id1="+h+"&cid="+g+"&pid="+d}else{window.location.href="http://"+k+"/shopping/cart/billing-shipping?id="+j+"&id1="+h+"&cid="+g}}else{if(d!=""){window.location.href="http://"+k+"/shopping/cart/billing-shipping/?pid="+d}else{window.location.href="http://"+k+"/shopping/cart/billing-shipping/"}}}}else{if(l=="min error"){$.prompt("Minimum purchase amount to use this coupon not reached! Do you still want to continue?",{callback:mycallbackform,buttons:{Continue:"Success",Cancel:"Failure"}})}else{$.prompt(l)}}}})}}function roundNumber(e,d){var j;d=Number(d);if(d<1){j=(Math.round(e)).toString()}else{var f=e.toString();if(f.lastIndexOf(".")==-1){f+="."}var c=f.lastIndexOf(".")+d;var b=Number(f.substring(c,c+1));var a=Number(f.substring(c+1,c+2));if(a>=5){if(b==9&&c>0){while(c>0&&(b==9||isNaN(b))){if(b!="."){c-=1;b=Number(f.substring(c,c+1))}else{c-=1}}}b+=1}if(b==10){f=f.substring(0,f.lastIndexOf("."));var k=Number(f)+1;j=k.toString()+"."}else{j=f.substring(0,c)+b.toString()}}if(j.lastIndexOf(".")==-1){j+="."}var h=(j.substring(j.lastIndexOf(".")+1)).length;for(var g=0;g<d-h;g++){j+="0"}return j};