﻿function Login() {
 var Error="";
 var CheckError="";
 Error=check_string("登入帳號",document.getElementById("Account1").value,1,32);
 if(Error!="") { if(CheckError=="") document.getElementById("Account1").focus(); CheckError+=Error; }
 Error=check_string("密　　碼",document.getElementById("Password1").value,1,32);
 if(Error!="") { if(CheckError=="") document.getElementById("Password1").focus(); CheckError+=Error; }
 if(document.getElementById("Account1").value=="[Account]") { document.getElementById("Account1").focus(); CheckError+="【登入帳號】不可為保留字\"[Account]\"！"; }
 if(document.getElementById("Password1").value=="[Account]") { document.getElementById("Password1").focus(); CheckError+="【密　　碼】不可為保留字\"[Password]\"！"; }
 if(CheckError!="") { alert(CheckError); return false; }
 if(document.getElementById("CallValue")!=null) {
 document.getElementById("CallValue").value="[Account]"+document.getElementById("Account1").value+"[Password]"+document.getElementById("Password1").value;
 document.getElementById("CallBack").click();
 return;
 }
 else { document.FormLogin.submit(); }
}
function Forget() {
 var Error="";
 var CheckError="";
 Error=check_string("登入帳號",document.getElementById("Account1").value,1,32);
 if(Error!="") { if(CheckError=="") document.getElementById("Account1").focus(); CheckError+=Error; }
 if(CheckError!="") { alert(CheckError); return false; }
 else { document.getElementById("Password1").value=""; document.FormLogin.submit(); }
}
function Logout() { if(confirm("登出消費者，您確定要繼續嗎？")) document.FormLogout.submit(); }
function Member(X) { //window.navigate("member.aspx?shop="+X);
 location.href="member.aspx?shop="+X;
}
function Remember(Y) {
 if(!document.getElementById("AutoLogin").checked) { delCookie(Y+"MAccount");delCookie(Y+"MPassword");delCookie(Y+"MAutoLogin"); }
}
function Node_Click(X) {
 if(document.getElementById(X).style.display=="none") {
 document.getElementById(X).style.display="block"; document.getElementById("I"+X).src="image/tree_node2.gif"; }
 else {
 document.getElementById(X).style.display="none"; document.getElementById("I"+X).src="image/tree_node1.gif"; }
}
function Buy(Product,Shop,Mode) {
 var OptionContent="";
 if(document.getElementById("Option_Count")!=null)
 for(i=0;i<document.getElementById("Option_Count").value;i++) 
 if(document.getElementById("Option_Name"+i)!=null && document.getElementById("Option"+i+"1")!=null) {
 var Tmp="";
 OptionContent+="["+document.getElementById("Option_Name"+i).value+"]";
 for(j=0;j<document.getElementById("Option"+i+"1").options.length;j++) {
 if(document.getElementById("Option"+i+"1").options[j].selected)
 //Tmp+=document.getElementById("Option"+i+"1").options[j].text+", ";
 Tmp+=document.getElementById("Option"+i+"1").options[j].value+",";
 }
 if(Tmp=="") OptionContent+="-- "; else OptionContent+=Tmp;
 }
 var URL="car.aspx?shop="+Shop+"&mode="+Mode+"&add="+Product+"&option="+OptionContent;
 for(i=1;i<=10;i++) if(document.getElementById("Add"+i)!=null && document.getElementById("Add"+i).checked) 
 URL+="&add"+i+"="+document.getElementById("Add"+i).value+"&addcount"+i+"="+document.getElementById("AddCount"+i).value;
 location.href=URL;
}
function Remove_Car(X,Y) {
 var MSG="您確定要移除項目 "+X+" 的商品嗎？";
 if(Y==1) MSG+="移除這個項目，將一併移除這個商品的加購項目";
 if(confirm(MSG)) return true; else return false;
}
function OptionChange(X,Name) {
 if(document.getElementById(Name+"2")!=null && document.getElementById(Name+"1")!=null) {
 if(X==1) {
 for(i=0;i<document.getElementById(Name+"1").options.length;i++)
 if(document.getElementById(Name+"1").options[i].selected) document.getElementById(Name+"2").options[i].selected=true;
 else document.getElementById(Name+"2").options[i].selected=false;
 }
 else
 {
 for(i=0;i<document.getElementById(Name+"2").options.length;i++)
 if(document.getElementById(Name+"2").options[i].selected) document.getElementById(Name+"1").options[i].selected=true;
 else document.getElementById(Name+"1").options[i].selected=false;
 } }
}
function Quick_Search() {
 if(document.getElementById("Search").value.length>32) alert("商品快速搜尋長度過長，最長不可超過 32 個字！");
 else if(document.getElementById("Search").value=="") alert("商品快速搜尋尚未填寫！");
 else if(document.getElementById("Type").value==3 && check_intS("",document.getElementById("Search").value)!="") alert("商品快速搜尋價格，必須為數字！");
 else document.Search1.submit();
}
function ButtonOver(X) { document.getElementById("Btn_"+X).className="Table1"; }
function ButtonOut(X) { document.getElementById("Btn_"+X).className="Td1"; }