function clientCheck(storeNo, storeName, storeNameEng) {
	if (storeNo.value == "") {
		alert("請務必輸入商店編號!!");
		return false;
	}
	if (storeName.value == "") {
		alert("請務必輸入中文商店名稱!!");
		return false;
	}
	return true;
}

/*function checkCountry(countryInput, countyInput, zoneInput, post) {
	if (countryInput.selectedIndex == 0 ) { // 中華民國 selected
		initCounty(countyInput);
		initZone(countyInput, zoneInput, post);
	} else { // 海外 selected
		countyInput.length = 1;
		countyInput.options[0].value = "";
		countyInput.options[0].text = "";
		zoneInput.length = 1;
		zoneInput.options[0].value = "";
		zoneInput.options[0].text = "";
		post.value = "";
	}
}*/

function initCounty(countyInput){
	countyInput.length = County.length;
	for (i = 0; i < County.length; i++) {
		countyInput.options[i].value = County[i];
		countyInput.options[i].text = County[i];
	}
	countyInput.selectedIndex = 0;
}

function initZone(countyInput, zoneInput, post){
	changeZone(countyInput, zoneInput, post);
}

function initCounty2(countyInput, countyValue){
	countyInput.length = County.length;
	for (i = 0; i < County.length; i++) {
		countyInput.options[i].value = County[i];
		countyInput.options[i].text = County[i];

		if (countyValue == County[i])
			countyInput.selectedIndex = i;
	}
}

function initZone2(countyInput, zoneInput, post, zoneValue){
	selectedCountyIndex = countyInput.selectedIndex;

	zoneInput.length = Zone[selectedCountyIndex].length;
	for (i = 0; i < Zone[selectedCountyIndex].length; i++) {
		zoneInput.options[i].value = Zone[selectedCountyIndex][i];
		zoneInput.options[i].text = Zone[selectedCountyIndex][i];

		if (zoneValue == Zone[selectedCountyIndex][i])
			zoneInput.selectedIndex = i;
	}

	showZipCode(countyInput, zoneInput, post);
}

function changeZone(countyInput, zoneInput, post) {
	selectedCountyIndex = countyInput.selectedIndex;

	zoneInput.length = Zone[selectedCountyIndex].length;
	for (i = 0; i < Zone[selectedCountyIndex].length; i++) {
		zoneInput.options[i].value = Zone[selectedCountyIndex][i];
		zoneInput.options[i].text = Zone[selectedCountyIndex][i];
	}
	zoneInput.selectedIndex = 0;

	showZipCode(countyInput, zoneInput, post);
}

function showZipCode(countyInput, zoneInput, post) {
	post.value = ZipCode[countyInput.selectedIndex][zoneInput.selectedIndex];
}

County = new Array("請選擇縣市", "臺北市", "基隆市", "臺北縣", "宜蘭縣", "新竹市",
		"新竹縣", "桃園縣", "苗栗縣", "臺中市", "臺中縣", "彰化縣",
		"南投縣", "嘉義市", "嘉義縣", "雲林縣", "臺南市", "臺南縣",
		"高雄市", "高雄縣", "澎湖縣", "屏東縣", "臺東縣", "花蓮縣",
		"金門縣", "連江縣", "南海諸島");

Zone = new Array(27);
// for "臺北市"
Zone[0] = new Array("請選擇鄉鎮區");
Zone[1] = new Array("請選擇鄉鎮區", "中正區","大同區","中山區","松山區","大安區",
	"萬華區","信義區","士林區","北投區","內湖區","南港區",
	"文山區(木柵)","文山區(景美)");
// for "基隆市"
Zone[2] = new Array("請選擇鄉鎮區", "仁愛區","信義區","中正區","中山區","安樂區",
	"暖暖區","七堵區");
// for "臺北縣"
Zone[3] = new Array("請選擇鄉鎮區", "萬里","金山","板橋","汐止","深坑","石碇","瑞芳",
	"平溪","雙溪","貢寮","新店","坪林","烏來","永和","中和","土城",
	"三峽","樹林","鶯歌","三重","新莊","泰山","林口","蘆洲","五股",
	"八里","淡水","三芝","石門");
// for "宜蘭縣"
Zone[4] = new Array("請選擇鄉鎮區", "宜蘭","頭城","礁溪","壯圍","員山","羅東","三星",
	"大同","五結","冬山","蘇澳","南澳");
// for "新竹市"
Zone[5] = new Array("請選擇鄉鎮區", "新竹市");
// for "新竹縣"
Zone[6] = new Array("請選擇鄉鎮區", "竹北","湖口","新豐","新埔","關西","芎林","寶山",
	"竹東","五峰","橫山","尖石","北埔","峨嵋");
// for "桃園縣"
Zone[7] = new Array("請選擇鄉鎮區", "中壢","平鎮","龍潭","楊梅","新屋","觀音","桃園",
	"龜山","八德","大溪","復興","大園","蘆竹");
// for "苗栗縣"
Zone[8] = new Array("請選擇鄉鎮區", "竹南","頭份","三灣","南庄","獅潭","後龍","通霄",
	"苑裡","苗栗","造橋","頭屋","公館","大湖","泰安","鉰鑼","三義",
	"西湖","卓蘭");
// for "臺中市"
Zone[9] = new Array("請選擇鄉鎮區", "中區","東區","南區","西區","北區","北屯區",
	"西屯區","南屯區");
// for "臺中縣"
Zone[10] = new Array("請選擇鄉鎮區", "太平","大里","霧峰","烏日","豐原","后里","石岡",
	"東勢","和平","新社","潭子","大雅","神岡","大肚","沙鹿","龍井",
	"梧棲","清水","大甲","外圃","大安");
// for "彰化縣"
Zone[11] = new Array("請選擇鄉鎮區", "彰化","芬園","花壇","秀水","鹿港","福興","線西",
	"和美","伸港","員林","社頭","永靖","埔心","溪湖","大村","埔鹽",
	"田中","北斗","田尾","埤頭","溪州","竹塘","二林","大城","芳苑",
	"二水");
// for "南投縣"
Zone[12] = new Array("請選擇鄉鎮區", "南投","中寮","草屯","國姓","埔里","仁愛","名間",
	"集集","水里","魚池","信義","竹山","鹿谷");
// for "嘉義市"
Zone[13] = new Array("請選擇鄉鎮區", "嘉義市");
// for "嘉義縣"
Zone[14] = new Array("請選擇鄉鎮區", "番路","梅山","竹崎","阿里山","中埔","大埔",
"水上","鹿草","太保","朴子","東石","六角","新港","民雄","大林","溪口",
"義竹","布袋");
// for "雲林縣"
Zone[15] = new Array("請選擇鄉鎮區", "斗南","大埤","虎尾","土庫","褒忠","東勢","臺西",
	"崙背","麥寮","斗六","林內","古坑","莿桐","西螺","二崙","北港",
	"水林","口湖","四湖","元長");
// for "臺南市"
Zone[16] = new Array("請選擇鄉鎮區", "中區","東區","南區","西區","北區","安平區",
	"安南區");
// for "臺南縣"
Zone[17] = new Array("請選擇鄉鎮區", "永康","歸仁","新化","左陣","玉井","楠西","南化",
	"仁德","關廟","龍崎","官田","麻豆","佳里","西港","七股","將軍",
	"學甲","北門","新營","後壁","白河","東山","六甲","下營","柳營",
	"鹽水","善化","大內","山上","新市","安定");
// for "高雄市"
Zone[18] = new Array("請選擇鄉鎮區", "新興區","前金區","苓雅區","鹽埕區","鼓山區",
	"旗津區","前鎮區","三民區","楠梓區","小港區","左營區");
// for "高雄縣"
Zone[19] = new Array("請選擇鄉鎮區", "仁武","大社","岡山","路竹","阿蓮","田寮","燕巢",
	"橋頭","梓官","彌陀","永安","湖內","鳳山","大寮","林園","鳥松",
	"大樹","旗山","美濃","六龜","內門","杉林","甲仙","桃源","三民",
	"茂林","茄萣");
// for "澎湖縣"
Zone[20] = new Array("請選擇鄉鎮區", "馬公","西嶼","望安","七美","白沙","湖西");
// for "屏東縣"
Zone[21] = new Array("請選擇鄉鎮區", "屏東","三地","霧臺","瑪家","九如","里港","高樹",
	"鹽埔","長治","麟洛","竹田","內埔","萬丹","潮州","泰武","來義",
	"萬巒","嵌頂","新埤","南州","林邊","東港","琉球","佳冬","新園",
	"枋寮","枋山","春日","獅子","車城","牡丹","恒泰","滿州");
// for "臺東縣"
Zone[22] = new Array("請選擇鄉鎮區", "臺東","綠島","蘭嶼","延平","卑南","鹿野","關山",
	"海端","池上","東河","成功","長濱","太麻里","金峰","大武","達仁");
// for "花蓮縣"
Zone[23] = new Array("請選擇鄉鎮區", "花蓮","新城","秀林","吉安","壽豐","鳳林","光復",
	"豐濱","瑞穗","萬榮","玉里","卓溪","富里");
// for "金門縣"
Zone[24] = new Array("請選擇鄉鎮區", "金沙","金湖","金寧","金城","烈嶼","烏坵");
// for "連江縣"
Zone[25] = new Array("請選擇鄉鎮區", "南竿","北竿","莒光","東引");
// for "南海諸島"
Zone[26] = new Array("請選擇鄉鎮區", "東沙","西沙","釣魚台列嶼");


ZipCode = new Array(27);
// for "臺北市"
ZipCode[0] = new Array("");
ZipCode[1] = new Array("","100","103","104","105","106","108","110","111",
	"112","114","115","116","117");
// for "基隆市"
ZipCode[2] = new Array("","200","201","202","203","204","205","206");
// for "臺北縣"
ZipCode[3] = new Array("","207","208","220","221","222","223","224","226",
	"227","228","231","232","233","234","235","236","237","238","239",
	"241","242","243","244","247","248","249","251","252","253");
// for "宜蘭縣"
ZipCode[4] = new Array("","260","261","262","263","264","265","266","267",
	"268","269","270","272");
// for "新竹市"
ZipCode[5] = new Array("","300");
// for "新竹縣"
ZipCode[6] = new Array("","302","303","304","305","306","307","308","310",
	"311","312","313","314","315");
// for "桃園縣"
ZipCode[7] = new Array("","320","324","325","326","327","328","330","333",
	"334","335","336","337","338");
// for "苗栗縣"
ZipCode[8] = new Array("","350","351","352","353","354","356","357",
	"358","360","361","362","363","364","365","366","367","368","369");
// for "臺中市"
ZipCode[9] = new Array("","400","401","402","403","404","406","407","408");
// for "臺中縣"
ZipCode[10] = new Array("","411","412","413","414","420","421","422","423",
	"424","426","427","428","429","432","433","434","435","436","437",
	"438","439");
// for "彰化縣"
ZipCode[11] = new Array("","500","502","503","504","505","506","507","508",
	"509","510","511","5112","513","514","515","516","520","521","522",
	"523","524","525","526","527","528","530");
// for "南投縣"
ZipCode[12] = new Array("","540","541","542","544","545","546","551","552",
	"553","555","556","557","558");
// for "嘉義市"
ZipCode[13] = new Array("","600");
// for "嘉義縣"
ZipCode[14] = new Array("","602","603","604","605","606","607","608","611",
	"612","613","614","615","616","621","622","623","624","625");
// for "雲林縣"
ZipCode[15] = new Array("","630","631","632","633","634","635","636","637",
	"638","640","643","646","647","648","649","651","652","653","654",
	"655");
// for "臺南市"
ZipCode[16] = new Array("","700","701","702","703","704","708","709");
// for "臺南縣"
ZipCode[17] = new Array("","710","711","712","713","714","715","716","717",
	"718","719","720","721","722","723","724","725","726","727","730",
	"731","732","733","734","735","736","737","741","742","743","744",
	"745");
// for "高雄市"
ZipCode[18] = new Array("","800","801","802","803","804","805","806","807",
	"811","812","813");
// for "高雄縣"
ZipCode[19] = new Array("","814","815","820","821","822","823","824","825",
	"826","827","828","829","830","831","832","833","840","842","843",
	"844","845","846","847","848","849","851","852");
// for "澎湖縣"
ZipCode[20] = new Array("","880","881","882","883","884","885");
// for "屏東縣"
ZipCode[21] = new Array("","900","901","902","903","904","905","906","907",
	"908","909","911","912","913","920","921","922","923","924","925",
	"926","927","928","929","931","932","940","941","942","943","944",
	"945","946","947");
// for "臺東縣"
ZipCode[22] = new Array("","950","951","952","953","954","955","956","957",
	"958","959","961","962","963","964","965","966");
// for "花蓮縣"
ZipCode[23] = new Array("","970","971","972","973","974","975","976","977",
	"978","979","981","982","983");
// for "金門縣"
ZipCode[24] = new Array("","890","891","892","893","894","896");
// for "連江縣"
ZipCode[25] = new Array("","209","210","211","212");
// for "南海諸島"
ZipCode[26] = new Array("","817","819","290");

function CheckID(str)
{

    var id22,id33;

	//str.toLowerCase()

	if (str.length==10)
	 {
	id1=str.substring(0,1);
    id2=str.substring(1,2);
    id3=str.substring(2,3);
    id4=str.substring(3,4);
    id5=str.substring(4,5);
    id6=str.substring(5,6);
    id7=str.substring(6,7);
    id8=str.substring(7,8);
    id9=str.substring(8,9);
    id10=str.substring(9,10);

     if ((id1=='a')||(id1=='A'))
	   {
	    id22=1;
        id33=0;
       }
	 if ((id1=='b')||(id1=='B'))
	   {
	    id22=1;
        id33=1;
       }
     if ((id1=='c')||(id1=='C'))
	   {
	    id22=1;
        id33=2;
       }
     if ((id1=='d')||(id1=='D'))
	   {
	    id22=1;
        id33=3;
       }
     if ((id1=='e')||(id1=='E'))
	   {
	    id22=1;
        id33=4;
       }
     if ((id1=='f')||(id1=='F'))
	   {
	    id22=1;
        id33=5;
       }
	 if ((id1=='g')||(id1=='G'))
	   {
	    id22=1;
        id33=6;
       }
     if ((id1=='h')||(id1=='H'))
	   {
	    id22=1;
        id33=7;
       }
     if ((id1=='j')||(id1=='J'))
	   {
	    id22=1;
        id33=8;
       }
    if ((id1=='k')||(id1=='K'))
	   {
	    id22=1;
        id33=9;
       }
    if ((id1=='l')||(id1=='L'))
	   {
	    id22=2;
        id33=0;
       }
	if ((id1=='m')||(id1=='M'))
	   {
	    id22=2;
        id33=1;
       }
    if ((id1=='n')||(id1=='N'))
	   {
	    id22=2;
        id33=2;
       }
    if ((id1=='p')||(id1=='P'))
	   {
	    id22=2;
        id33=3;
       }
    if ((id1=='q')||(id1=='Q'))
	   {
	    id22=2;
        id33=4;
       }
    if ((id1=='r')||(id1=='R'))
	   {
	    id22=2;
        id33=5;
       }
    if ((id1=='s')||(id1=='S'))
	   {
	    id22=2;
        id33=6;
       }
    if ((id1=='t')||(id1=='T'))
	   {
	    id22=2;
        id33=7;
       }
	if ((id1=='u')||(id1=='U'))
	   {
	    id22=2;
        id33=8;
       }
    if ((id1=='v')||(id1=='V'))
	   {
	    id22=2;
        id33=9;
       }
	if ((id1=='w')||(id1=='W'))
	   {
	    id22=3;
        id33=2;
       }
    if ((id1=='x')||(id1=='X'))
	   {
	    id22=3;
        id33=0;
       }
    if ((id1=='y')||(id1=='Y'))
	   {
	    id22=3;
        id33=1;
       }
	if ((id1=='z')||(id1=='Z'))
	   {
	    id22=3;
        id33=3;
       }
     if ((id1=='i')||(id1=='I'))
	   {
	    id22=3;
        id33=4;
       }
     if ((id1=='o')||(id1=='O'))
	   {
	    id22=3;
        id33=5;
       }

    y=id22+9*id33+8*eval(id2)+7*eval(id3)+6*eval(id4)+5*eval(id5)+4*eval(id6)+3*eval(id7)+2*eval(id8)+eval(id9)+eval(id10);

	y1=(y % 10) ;

	if (y1==0)
      return false
    else
	 return true
	 }

	else
	 return true
}

function CheckUID(str)
{
	if (str.length != 10) return false

	str.toUpperCase()
	if ((str.charAt(0) < 'A') || (str.charAt(0) > 'Z'))
	   return false

	for (i = 1; i < str.length; i++)
		if ((str.charAt(i) < '0') || (str.charAt(i) > '9'))
		   return false

	return true
}

function initSelect(v_select, aryValue, aryCaption, vVal){
	v_select.length = aryCaption.length;
	for (i = 0; i < aryCaption.length; i++) {
		v_select.options[i].value = aryValue[i];
		v_select.options[i].text = aryCaption[i];

		if (vVal == aryValue[i])
			v_select.selectedIndex = i;
	}
}

function initCounty_NA(countyInput, countyValue){
	countyInput.length = County.length+1;
	countyInput.options[0].value = "NA";
	countyInput.options[0].text = "      ";
	for (i = 1; i <= County.length; i++) {
		countyInput.options[i].value = County[i-1];
		countyInput.options[i].text = County[i-1];

		if (countyValue == County[i-1])
			countyInput.selectedIndex = i;
	}
}

function initZone_NA(countyInput, zoneInput, post, zoneValue){
	if (countyInput.selectedIndex==0){
		zoneInput.length = 1;
	}else{
		selectedCountyIndex = countyInput.selectedIndex-1;
		zoneInput.length = Zone[selectedCountyIndex].length+1;
	}
	zoneInput.options[0].value = "NA";
	zoneInput.options[0].text = "      ";
	for (i = 1; i < zoneInput.length; i++) {
		zoneInput.options[i].value = Zone[selectedCountyIndex][i-1];
		zoneInput.options[i].text = Zone[selectedCountyIndex][i-1];

		if (zoneValue == Zone[selectedCountyIndex][i-1])
			zoneInput.selectedIndex = i;
	}
}

function changeZone_NA(countyInput, zoneInput, post) {
	if (countyInput.value=='NA'){
    	zoneInput.length = 1;
       	zoneInput.options[0].value = "NA";
		zoneInput.options[0].text = "       ";
    	return;
    }
	selectedCountyIndex = countyInput.selectedIndex-1;
	
	zoneInput.length = Zone[selectedCountyIndex].length+1;
    zoneInput.options[0].value = "NA";
	zoneInput.options[0].text = "       ";

	for (i = 1; i < zoneInput.length; i++) {
		zoneInput.options[i].value = Zone[selectedCountyIndex][i-1];
		zoneInput.options[i].text = Zone[selectedCountyIndex][i-1];
	}
	zoneInput.selectedIndex = 1;
}
