var selectedShipping=null;var selectedPayment=null;var selectedPack=null;var selectedCard=null;var selectedSurplus="";var selectedBonus=0;var selectedIntegral=0;var selectedOOS=null;var alertedSurplus=false;var groupBuyShipping=null;var groupBuyPayment=null;function selectShipping(C){if(typeof(C)!="object"){var E=document.getElementById("shipping_radio_"+C);E.checked=true}else{E=C}if(selectedShipping==E){return}else{selectedShipping=E}var A=E.attributes["supportCod"].value+0;var D=E.form;for(i=0;i<D.elements.length;i++){if(D.elements[i].name=="payment"&&D.elements[i].attributes["isCod"].value=="1"){if(A==0){D.elements[i].checked=false;D.elements[i].disabled=true}else{D.elements[i].disabled=false}}}if(E.attributes["insure"].value+0==0){document.getElementById("ECS_NEEDINSURE").checked=false;document.getElementById("ECS_NEEDINSURE").disabled=true}else{document.getElementById("ECS_NEEDINSURE").checked=false;document.getElementById("ECS_NEEDINSURE").disabled=false}var B=new Date();Ajax.call("flow.php?step=select_shipping","shipping="+E.value,orderShippingSelectedResponse,"GET","JSON")}function orderShippingSelectedResponse(A){if(A.need_insure){try{document.getElementById("ECS_NEEDINSURE").checked=true}catch(B){alert(B.message)}}try{if(document.getElementById("ECS_CODFEE")!=undefined){document.getElementById("ECS_CODFEE").innerHTML=A.cod_fee}}catch(B){alert(B.message)}orderSelectedResponse(A)}function selectPayment(A){var B=document.getElementById("pay_radio_"+A);B.checked=true;if(selectedPayment==B){return}else{selectedPayment=B}Ajax.call("flow.php?step=select_payment","payment="+B.value,orderSelectedResponse,"GET","JSON")}function handleGroupBuyShipping(C){if(groupBuyShipping==C){return}else{groupBuyShipping=C}var A=C.attributes["supportCod"].value+0;var B=C.form;for(i=0;i<B.elements.length;i++){if(B.elements[i].name=="payment"&&B.elements[i].attributes["isCod"].value=="1"){if(A==0){B.elements[i].checked=false;B.elements[i].disabled=true}else{B.elements[i].disabled=false}}}if(C.attributes["insure"].value+0==0){document.getElementById("ECS_NEEDINSURE").checked=false;document.getElementById("ECS_NEEDINSURE").disabled=true}else{document.getElementById("ECS_NEEDINSURE").checked=false;document.getElementById("ECS_NEEDINSURE").disabled=false}Ajax.call("group_buy.php?act=select_shipping","shipping="+C.value,orderSelectedResponse,"GET")}function handleGroupBuyPayment(A){if(groupBuyPayment==A){return}else{groupBuyPayment=A}Ajax.call("group_buy.php?act=select_payment","payment="+A.value,orderSelectedResponse,"GET")}function selectPack(A){if(selectedPack==A){return}else{selectedPack=A}Ajax.call("flow.php?step=select_pack","pack="+A.value,orderSelectedResponse,"GET","JSON")}function selectCard(A){if(selectedCard==A){return}else{selectedCard=A}Ajax.call("flow.php?step=select_card","card="+A.value,orderSelectedResponse,"GET","JSON")}function selectInsure(A){A=A?1:0;Ajax.call("flow.php?step=select_insure","insure="+A,orderSelectedResponse,"GET","JSON")}function handleGroupBuyInsure(A){A=A?1:0;Ajax.call("group_buy.php?act=select_insure","insure="+A,orderSelectedResponse,"GET","JSON")}function orderSelectedResponse(B){if(B.error){alert(B.error);location.href="./"}try{var A=document.getElementById("ECS_ORDERTOTAL");A.innerHTML=(typeof B=="object")?B.content:B;if(B.payment!=undefined){var C=document.forms["theForm"].elements["surplus"];if(C!=undefined){C.disabled=B.pay_code=="balance"}}}catch(D){}}function changeSurplus(A){if(selectedSurplus==A){return}else{selectedSurplus=A}Ajax.call("flow.php?step=change_surplus","surplus="+A,changeSurplusResponse,"GET","JSON")}function changeSurplusResponse(B){if(B.error){try{document.getElementById("ECS_SURPLUS_NOTICE").innerHTML=B.error;document.getElementById("ECS_SURPLUS").value="0";document.getElementById("ECS_SURPLUS").focus()}catch(A){}}else{try{document.getElementById("ECS_SURPLUS_NOTICE").innerHTML=""}catch(A){}orderSelectedResponse(B.content)}}function changeIntegral(A){if(selectedIntegral==A){return}else{selectedIntegral=A}Ajax.call("flow.php?step=change_integral","points="+A,changeIntegralResponse,"GET","JSON")}function changeIntegralResponse(B){if(B.error){try{document.getElementById("ECS_INTEGRAL_NOTICE").innerHTML=B.error;document.getElementById("ECS_INTEGRAL").value="0";document.getElementById("ECS_INTEGRAL").focus()}catch(A){}}else{try{document.getElementById("ECS_INTEGRAL_NOTICE").innerHTML=""}catch(A){}orderSelectedResponse(B.content)}}function changeBonus(A){if(selectedBonus==A){return}else{selectedBonus=A}Ajax.call("flow.php?step=change_bonus","bonus="+A,changeBonusResponse,"GET","JSON")}function changeBonusResponse(B){if(B.error){alert(B.error);try{document.getElementById("ECS_BONUS").value="0"}catch(A){}}else{orderSelectedResponse(B.content)}}function validateBonus(A){Ajax.call("flow.php?step=validate_bonus","bonus_sn="+A,validateBonusResponse,"GET")}function validateBonusResponse(A){alert(A)}function changeNeedInv(){var A=document.getElementById("ECS_NEEDINV");var G=document.getElementById("ECS_INVTYPE");var H=document.getElementById("ECS_INVPAYEE");var C=document.getElementById("ECS_INVCONTENT");var D=A.checked?1:0;var E=A.checked?(G!=undefined?G.value:""):"";var F=A.checked?H.value:"";var B=A.checked?C.value:"";G.disabled=H.disabled=C.disabled=!A.checked;if(G!=null){G.disabled=!A.checked}Ajax.call("flow.php?step=change_needinv","need_inv="+D+"&inv_type="+encodeURIComponent(E)+"&inv_payee="+encodeURIComponent(F)+"&inv_content="+encodeURIComponent(B),orderSelectedResponse,"GET")}function groupBuyChangeNeedInv(){var F=document.getElementById("ECS_NEEDINV");var E=document.getElementById("ECS_INVPAYEE");var D=document.getElementById("ECS_INVCONTENT");var C=F.checked?1:0;var B=F.checked?E.value:"";var A=F.checked?D.value:"";E.disabled=D.disabled=!F.checked;Ajax.call("group_buy.php?act=change_needinv","need_idv="+C+"&amp;payee="+B+"&amp;content="+A,null,"GET")}function changeOOS(A){if(selectedOOS==A){return}else{selectedOOS=A}Ajax.call("flow.php?step=change_oos","oos="+A.value,null,"GET")}function checkOrderForm(C){var G=false;var A=false;for(i=0;i<C.elements.length;i++){if(C.elements[i].name=="shipping"&&C.elements[i].checked){A=true}if(C.elements[i].name=="payment"&&C.elements[i].checked){G=true}}if(!A){alert(flow_no_shipping);return false}if(!G){alert(flow_no_payment);return false}if(document.getElementById("ECS_SURPLUS")){var D=document.getElementById("ECS_SURPLUS").value;var B=Utils.trim(Ajax.call("flow.php?step=check_surplus","surplus="+D,null,"GET","TEXT",false));if(B){try{document.getElementById("ECS_SURPLUS_NOTICE").innerHTML=B}catch(F){}return false}}if(document.getElementById("ECS_INTEGRAL")){var E=document.getElementById("ECS_INTEGRAL").value;var B=Utils.trim(Ajax.call("flow.php?step=check_integral","integral="+E,null,"GET","TEXT",false));if(B){return false;try{document.getElementById("ECS_INTEGRAL_NOTICE").innerHTML=B}catch(F){}}}C.action=C.action+"?step=done";return true}function checkConsignee(A){var B=new Array();var C=false;if(A.elements["country"]&&A.elements["country"].value==0){B.push(country_not_null);C=true}if(A.elements["province"]&&A.elements["province"].value==0&&A.elements["province"].length>1){C=true;B.push(province_not_null)}if(A.elements["city"]&&A.elements["city"].value==0&&A.elements["city"].length>1){C=true;B.push(city_not_null)}if(A.elements["district"]&&A.elements["district"].length>1){if(A.elements["district"].value==0){C=true;B.push(district_not_null)}}if(Utils.isEmpty(A.elements["consignee"].value)){C=true;B.push(consignee_not_null)}if(A.elements["address"]&&Utils.isEmpty(A.elements["address"].value)){C=true;B.push(address_not_null)}if(A.elements["zipcode"]&&A.elements["zipcode"].value.length>0&&(!Utils.isNumber(A.elements["zipcode"].value))){C=true;B.push(zip_not_num)}if(Utils.isEmpty(A.elements["tel"].value)){C=true;B.push(tele_not_null)}else{if(!Utils.isTel(A.elements["tel"].value)){C=true;B.push(tele_invaild)}}if(A.elements["mobile"]&&A.elements["mobile"].value.length>0&&(!Utils.isTel(A.elements["mobile"].value))){C=true;B.push(mobile_invaild)}if(C){message=B.join("\n");alert(message)}return !C};
