function changeCart(E,D){var B="";if(getCartCookie("cart24h")){B=getCartCookie("cart24h")}var A=getCartItemStatus(E,D);var C=E+","+D+","+A+"|";if(document.getElementById("chkbox_"+E).checked){if(getCartNum()>=20){document.getElementById("chkbox_"+E).checked=false;alert("您的購物清單商品數超過上限(最多20樣)，超過的部分將無法加入")}else{if(document.getElementById("gdbox"+E).getAttributeNode("class").value.indexOf("MktSet")>=0){document.getElementById("gdbox"+E).getAttributeNode("class").value="MktSet-24hrC"}else{if(document.getElementById("gdbox"+E).getAttributeNode("class").value.indexOf("BestChoice6")>=0){document.getElementById("gdbox"+E).getAttributeNode("class").value="BestChoice6-24hrC"}}if(B.indexOf(C)<0){B+=C}else{if(A==2){var F=new String(B);B=F.replace(C,E+","+D+",1|")}}}}else{if(document.getElementById("gdbox"+E).getAttributeNode("class").value.indexOf("MktSet")>=0){document.getElementById("gdbox"+E).getAttributeNode("class").value="MktSet-24hr"}else{if(document.getElementById("gdbox"+E).getAttributeNode("class").value.indexOf("BestChoice6")>=0){document.getElementById("gdbox"+E).getAttributeNode("class").value="BestChoice6"}}var F=new String(B);if(A==0){B=F.replace(C,"")}else{if(A==1){B=F.replace(C,E+","+D+",2|")}}}setCartCookie("cart24h",B);setCartWatermarkInfo();showShoppingCartLogo("topmsg")}function getCartCookie(C){if(document.cookie){var B=document.cookie.indexOf(C+"=");if(B!=-1){B=B+C.length+1;var A=document.cookie.indexOf(";",B);if(A==-1){A=document.cookie.length}return unescape(document.cookie.substring(B,A))}}else{setCartCookie(C,"");return""}}function setCartCookie(C,B){var A=location.hostname;if(!A.match(/^[0-9\.]+$/gi)){A=A.replace(/^[^\.]*?\./,"")}document.cookie=C+"="+escape(B)+((A)?"; domain="+A:"")}function getCartNum(){var A="";var D=0;if(getCartCookie("cart24h")){A=getCartCookie("cart24h");var C=A.split("|");for(var B=0;B<C.length-1;B++){if(C[B].split(",")[2]=="0"||C[B].split(",")[2]=="1"){D++}}return D}else{return 0}}function loadCartBoxColor(){var B="";if(getCartCookie("cart24h")){B=getCartCookie("cart24h");var D=B.split("|");for(var C=0;C<D.length-1;C++){var E=D[C].split(",")[0];var A=D[C].split(",")[2];if(document.getElementById("gdbox"+E)&&(A=="0"||A=="1")){if(document.getElementById("gdbox"+E).getAttributeNode("class").value.indexOf("MktSet")>=0){document.getElementById("gdbox"+E).getAttributeNode("class").value="MktSet-24hrC"}else{if(document.getElementById("gdbox"+E).getAttributeNode("class").value.indexOf("BestChoice6")>=0){document.getElementById("gdbox"+E).getAttributeNode("class").value="BestChoice6-24hrC"}}}if(document.getElementById("chkbox_"+E)&&(A=="0"||A=="1")){document.getElementById("chkbox_"+E).checked=true}}}}function setCartWatermarkInfo(){var cartList="";if(getCartCookie("cart24h")){cartList=getCartCookie("cart24h");var aryCartList=cartList.split("|");var totalNum=0;var totalPrice=0;for(var i=0;i<aryCartList.length-1;i++){var item=aryCartList[i].split(",");var status=item[2];if(status=="0"||status=="1"){totalNum++;totalPrice+=eval(item[1])}}if(getCartCookie("ShoppingCart")){var shoppingCartList="";for(var i=0;i<getCartCookie("ShoppingCart").split(",").length;i++){if(i==8){shoppingCartList+=totalNum+","}else{if(i==9){shoppingCartList+=totalPrice+","}else{if((i+1)<getCartCookie("ShoppingCart").split(",").length){shoppingCartList+=getCartCookie("ShoppingCart").split(",")[i]+","}else{shoppingCartList+=getCartCookie("ShoppingCart").split(",")[i]}}}}setCartCookie("ShoppingCart",shoppingCartList)}else{setCartCookie("ShoppingCart","0,0,0,0,0,0,0,0,"+totalNum+","+totalPrice+",0,0,0,0,0,0")}}else{if(getCartCookie("ShoppingCart")){var shoppingCartList="";for(var i=0;i<getCartCookie("ShoppingCart").split(",").length;i++){if(i==8){shoppingCartList+="0,"}else{if(i==0){shoppingCartList+="0,"}else{if((i+1)<getCartCookie("ShoppingCart").split(",").length){shoppingCartList+=getCartCookie("ShoppingCart").split(",")[i]+","}else{shoppingCartList+=getCartCookie("ShoppingCart").split(",")[i]}}}}setCartCookie("ShoppingCart",shoppingCartList)}else{setCartCookie("ShoppingCart","0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")}}}function getCartItemStatus(C,B){var A="";if(getCartCookie("cart24h")){A=getCartCookie("cart24h");if(A.indexOf(C+","+B+",0|")>=0){return 0}else{if(A.indexOf(C+","+B+",1|")>=0){return 1}else{if(A.indexOf(C+","+B+",2|")>=0){return 2}else{return 0}}}}else{return 0}}loadCartBoxColor();setCartWatermarkInfo();
