function showList1(form,obj) {
		clearlist1();
		clearlist2();
		clearlist3();
		var isfox = check();
		var argument = "city_name=" +obj+"&isfox="+isfox;
		sendRequest1("list_get_store_desc.jsp?"+argument);
	}
	function sendRequest1(url) {
		createXMLHttpRequest();
		XMLHttpReq.open("GET", url, true);
		XMLHttpReq.onreadystatechange = processResponse1;
		XMLHttpReq.send(null);
	}

    function processResponse1() {
   	if (XMLHttpReq.readyState == 4) {
        	if (XMLHttpReq.status == 200) {
				updateList1();
		    } else {
		      	alert('請選擇縣市');
					clearlist1();
					clearlist2();
					clearlist3();
	      		document.getElementById('div_choice').style.display='none';	
		    }
        }
    }
    
    function updateList1() {
		var xmlDoc = XMLHttpReq.responseText;
		xmlDoc = xmlDoc.replace(/[\s　",';]+/g, "");
		var abc = xmlDoc.split("_");
		//alert(abc.length);
		var current = document.MainForm.list1;
		var anode, tnode;
		while(current.hasChildNodes()) {
			anode = current.firstChild;
			current.removeChild(anode);
		}
		for(i=0; i<abc.length-1;i++){
			anode = document.createElement("option");
         anode.setAttribute("value",abc[i]);
          if(i == 0) 
            anode.setAttribute("selected", "1");
          	current.appendChild(anode);
          	tnode = document.createTextNode(abc[i]);
				anode.appendChild(tnode);
		}
		document.MainForm.list1.disabled = false;
      document.MainForm.list1.style.backgroundColor = '#FFFFCC';
      document.MainForm.mli.style.backgroundColor = '#FFFFFF';	
	}
	function showList2(form,obj) {
		clearlist2();
		var isfox = check();
		var city1 = document.MainForm.mli.options[document.MainForm.mli.selectedIndex].text;
		var argument = "city_name=" +city1+"&district_name="+obj+"&isfox="+isfox;
		sendRequest2("list_get_store_desc.jsp?"+argument);
	}
	function sendRequest2(url) {
		createXMLHttpRequest();
		XMLHttpReq.open("GET", url, true);
		XMLHttpReq.onreadystatechange = processResponse2;
		XMLHttpReq.send(null);
	}

    function processResponse2() {
   	if (XMLHttpReq.readyState == 4) {
        	if (XMLHttpReq.status == 200) {
				updateList2();
		    } else {
		      	alert('請選擇鄉鎮市區');
					clearlist2();
					clearlist3();     
					document.getElementById('div_choice').style.display='none';   
		    }
        }
    }
    
    function updateList2() {
		var xmlDoc = XMLHttpReq.responseText;
		xmlDoc = xmlDoc.replace(/[\s　",';]+/g, "");
		var abc = xmlDoc.split("_");
		var current = document.MainForm.list2;
		var anode, tnode,fnoe;
		while(current.hasChildNodes()) {
			anode = current.firstChild;
			current.removeChild(anode);
		}
		for(i=0; i<abc.length-1;i++){
			anode = document.createElement("option");
         anode.setAttribute("value",abc[i]);
          if(i == 0) 
            anode.setAttribute("selected", "1");
          	current.appendChild(anode);
          	tnode = document.createTextNode(abc[i]);
				anode.appendChild(tnode);
		}
		document.MainForm.list2.disabled = false;
      document.MainForm.list2.style.backgroundColor = '#FFFFCC';
      document.MainForm.list1.style.backgroundColor = '#FFFFFF';	
      clearlist3();	
	}
	function showList3(form,obj) {
		//clearlist2();
		var isfox = check();
		var city1 = document.MainForm.mli.options[document.MainForm.mli.selectedIndex].text;
		var city2 = document.MainForm.list1.options[document.MainForm.list1.selectedIndex].text;
		var argument = "city_name=" +city1+"&district_name="+city2+"&road_name="+obj+"&isfox="+isfox;
		sendRequest3("list_get_store_desc.jsp?"+argument);
	}
	function sendRequest3(url) {
		createXMLHttpRequest();
		XMLHttpReq.open("GET", url, true);
		XMLHttpReq.onreadystatechange = processResponse3;
		XMLHttpReq.send(null);
	}

    function processResponse3() {
   	if (XMLHttpReq.readyState == 4) {
        	if (XMLHttpReq.status == 200) {
				updateList3();
		    } else {
		      	alert('請選擇街道');
					clearlist3(); 
					document.getElementById('div_choice').style.display='none';   
		    }
        }
    }
    
    function updateList3() {
		var xmlDoc = XMLHttpReq.responseText;
		xmlDoc = xmlDoc.replace(/[\s　",';]+/g, "");
		var abc = xmlDoc.split("_");
		var current = document.MainForm.list3;
		var anode, tnode,fnoe;
		while(current.hasChildNodes()) {
			anode = current.firstChild;
			current.removeChild(anode);
		}
		for(i=0; i<abc.length-1;i++){
			anode = document.createElement("option");
         anode.setAttribute("value",abc[i]);
          if(i == 0) 
            anode.setAttribute("selected", "1");
          	current.appendChild(anode);
          	tnode = document.createTextNode(abc[i]);
				anode.appendChild(tnode);
		}
		 if (abc.length==3) { 
        	showList4(document.MainForm,document.MainForm.list3[1].value);
        }	
		document.MainForm.list3.disabled = false;
     	document.MainForm.list3.style.backgroundColor = '#FFFFCC';
     	document.MainForm.list2.style.backgroundColor = '#FFFFFF';			
	}
	function showList4(form,obj) {
  		
  		if (obj=='---請選擇門市---') {
			alert('請選擇門市');
			document.getElementById('div_choice').style.display='none';   		
  		} else {  
  			vShowStoreName = obj;	
  			document.getElementById("store_id").innerHTML = "";
			document.getElementById("store_name").innerHTML = "";
			document.getElementById("store_tel").innerHTML = "";
			document.getElementById("store_addr").innerHTML = "";
			
			document.getElementById("arr_time").innerHTML = "";
			document.getElementById("show_map").innerHTML = "";
			document.getElementById("ArrTimeNote").style.display = "none";
			
			document.getElementById("div_choice").style.display="none";		
			
			form.vstore_name.value="";
			form.vstore_id.value="";
      	
			var city1 = document.MainForm.mli.options[document.MainForm.mli.selectedIndex].text;
			var city2 = document.MainForm.list1.options[document.MainForm.list1.selectedIndex].text;
			var city3 = document.MainForm.list2.options[document.MainForm.list2.selectedIndex].text;
			var isfox = check();
			var argument = "in_store_name=" +obj+"&isfox="+isfox;
			sendRequest4("list_get_store_desc.jsp?"+argument);
		}
	}
	
	function sendRequest4(url) {
		createXMLHttpRequest();
		XMLHttpReq.open("GET", url, true);
		XMLHttpReq.onreadystatechange = processResponse4;
		XMLHttpReq.send(null);
	}

	function processResponse4() {
   	if (XMLHttpReq.readyState == 4) {
        	if (XMLHttpReq.status == 200) {
				updateList4();
		    } else {
		      	alert("很抱歉，目前系統忙碌中，請稍後再試。");
		    }
        }
    }
    
    function updateList4() {
		var xmlDoc = XMLHttpReq.responseText;
		xmlDoc = xmlDoc.replace(/[\s　",';]+/g, "");
		if(xmlDoc.length==0){
			alert('請選擇門市');
		}else{
		var abc = xmlDoc.split("_");
		var store_id = "查無資料";
		var store_name = "查無資料";
		var store_tel = "查無資料";
		var store_addr = "查無資料";
		var longitude;
		var latitude;
		var show_alert;
		var arr_time;
		var isopen;
		for(i=0; i<abc.length;i++){
			store_id = abc[0];
			store_name = abc[1];
			store_tel = abc[2];
			store_addr = abc[3];
			longitude = abc[4];
			latitude = abc[5];
			arr_time = abc[6];
			show_alert = abc[7];
			isopen = abc[8];
		}
		var vStoreLogo = store_name.substring(0,2);
		if (vStoreLogo=="全家") {
			vStoreLogo = './logo_TFM.jpg';
			arr_time = arr_time + ' <span style=\"font-size:9px; cursor:hand;\" onClick=fShowArrTimeNote()>( 按這裡看說明)</span>'
		} else if (vStoreLogo=="萊爾") {
			vStoreLogo = './logo_TLF.jpg';
			//arr_time = '未提供';
			arr_time = arr_time + ' <span style=\"font-size:9px; cursor:hand;\" onClick=fShowArrTimeNote()>( 按這裡看說明)</span>'
		} else if (vStoreLogo=="OK") {
			vStoreLogo = './logo_TOK.jpg';
			arr_time = '未提供';
		} else {
			vStoreLogo = '';
		}
		document.getElementById("store_id").innerHTML = store_id;
		document.getElementById("store_name").innerHTML = store_name;
		document.getElementById("store_tel").innerHTML = store_tel;
		document.getElementById("store_addr").innerHTML = store_addr;
		
		document.getElementById("store_logo").src = vStoreLogo;
		document.getElementById("store_logo").style.display='';
		
		var a1 = document.MainForm.rstore_id;
		var a2 = document.MainForm.rstore_name;
		var a3 = document.MainForm.rstore_tel;
		var a4 = document.MainForm.rstore_addr;
		var a5 = document.MainForm.rlongitude;
		var a6 = document.MainForm.rlatitude;
		
		a1.value=store_id;
		a2.value=store_name;
		a3.value=store_tel;
		a4.value=store_addr;
		a5.value=longitude;
		a6.value=latitude;

		var Layer_choice;
		var Layer_choice2;

		if (document.getElementById) { //Netscape 6.x
			Layer_choice = eval("document.getElementById('div_choice')");
		} else { // IE 5.x
			Layer_choice = eval("document.all.choice.div_choice");
		}

		if (document.getElementById) { //Netscape 6.x
			Layer_choice = eval("document.getElementById('div_choice')");
		} else { // IE 5.x
			Layer_choice = eval("document.all.choice.div_choice");
		}

      if(Layer_choice){
      	if(store_id=='0'){
      		//alert('很抱歉，您選擇的【'+vShowStoreName+'】暫時無法提供店到店服務，請選擇其他門市。');
      		document.MainForm.list3.focus();
			}else{
          	Layer_choice.style.display='';
          	
				document.MainForm.vstore_name.value=store_name;
				document.MainForm.vstore_id.value=store_id;          	
          	
				var rlongitude = longitude;
				var rlatitude = latitude;
				document.getElementById("show_map").innerHTML = "";
				var url = "http://maps.google.com/staticmap?center="+rlongitude+","+rlatitude+"&zoom=16&size=450x250&maptype=mobile&markers="+rlongitude+","+rlatitude+",blue&key=ABQIAAAAj7LHo8ZiMJ75zibEmJfphhS_CnJW_Ma-GHYZ2Jkhc83I26dNBhSLx-1K07BbgVRcWKm06zK6VZXs3w&sensor=false";
				var srcFile = url;
				document.getElementById("show_map").innerHTML = '<iframe src="'+srcFile+'" height="256" width="456" marginheight="3" marginwidth="3" frameborder=0 scrolling="no" noresize></iframe>';
				if(show_alert=='N'){
         		var Layer_show_alert = eval("document.getElementById('show_alert')");
        			Layer_show_alert.style.padding = '2px 2px 2px 5px';
        			Layer_show_alert.style.borderStyle = 'dotted'; 
        			Layer_show_alert.style.borderWidth = '1px'; 
        			Layer_show_alert.style.borderColor = '#CC3333'; 
         		if(isopen=='Y'){
         			document.getElementById("show_alert").innerHTML = "";
         			document.getElementById("next").style.display="block";
         		}else{
         			document.getElementById("show_alert").innerHTML = '<span style="font-size:21px;"><center><font color=red>～此店舖今日無提供下單取貨服務～</font></center></span>';
         			document.getElementById("next").style.display = "none"
         		}

         		var vcvsname = document.MainForm.cvsname.value;
         		if(vcvsname==''){
         			document.getElementById("next").style.display = "none"
         		}

         	}else{
        			var Layer_show_alert = eval("document.getElementById('show_alert')");
        			Layer_show_alert.style.padding = '2px 2px 2px 5px';
        			Layer_show_alert.style.borderStyle = 'dotted'; 
        			Layer_show_alert.style.borderWidth = '1px'; 
        			Layer_show_alert.style.borderColor = '#CC3333';
         		if(isopen=='Y'){
         			document.getElementById("show_alert").innerHTML = '<span style="font-size:13px;">※ <span style=\"color:#6666CC;\">取貨相關注意事項</span>：此商店為封閉型店舖（如工廠或學校），逢週六、週日及國定假日，可能不營業，<font color=red>並請消費者確認可否進入取貨。</font></span>';
         			document.getElementById("next").style.display="block";
         		}else{
         			document.getElementById("show_alert").innerHTML = '<span style="font-size:21px;"><center><font color=red>～此店舖今日無提供下單取貨服務～</font></center></span>';
         			document.getElementById("next").style.display = "none"
         		}

					var vcvsname = document.MainForm.cvsname.value;
         		if(vcvsname==''){
         			document.getElementById("next").style.display = "none"
         		}

         	}
         	if(arr_time=='N'){
         		document.getElementById("arr_time").innerHTML = "";
         		document.getElementById("arr_time").innerHTML = arr_time;
         	}else{
         		var Layer_show_alert = eval("document.getElementById('arr_time')");
         		document.getElementById("arr_time").innerHTML = arr_time;
         	}
         }
      }
	  }
	}  