﻿/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: script_city.js 8422 2008-08-07 09:10:00Z zhengqingpeng $
*/

function setcity(provinceid, cityid) {
	var province = document.getElementById(provinceid).value;
    switch (province) {
        case "台灣" :
            var cityOptions = new Array(
            "台北(*)", "台北",
            "基隆", "基隆",
            "台南", "台南",
            "台中", "台中",
            "高雄", "高雄",
            "屏東", "屏東",
            "南投", "南投",
            "雲林", "雲林",
            "新竹", "新竹",
            "彰化", "彰化",
            "苗栗", "苗栗",
            "嘉義", "嘉義",
            "花蓮", "花蓮",
            "桃園", "桃園",
            "宜蘭", "宜蘭",
            "台東", "台東",
            "金門", "金門",
            "馬祖", "馬祖",
            "澎湖", "澎湖",
            "其它", "其它");
            break;
        case "海外" :
            var cityOptions = new Array(
            "美國(*)", "美國",
            "英國", "英國", 
            "法國", "法國", 
            "瑞士", "瑞士", 
            "澳洲", "澳洲", 
            "新西蘭", "新西蘭", 
            "加拿大", "加拿大", 
            "奧地利", "奧地利", 
            "韓國", "韓國", 
            "日本", "日本", 
            "德國", "德國", 
			"意大利", "意大利", 
			"西班牙", "西班牙", 
			"俄羅斯", "俄羅斯", 
			"泰國", "泰國", 
			"印度", "印度", 
			"荷蘭", "荷蘭", 
			"新加坡", "新加坡",
            "歐洲", "歐洲",
            "北美", "北美",
            "南美", "南美",
            "亞洲", "亞洲",
            "非洲", "非洲",
            "大洋洲", "大洋洲");
            break;
        default:
            var cityOptions = new Array("選擇城市", "");
            break;
    }
	
	var cityObject = document.getElementById(cityid);
	cityObject.options.length = 0;
	cityObject.options[0] = new Option("選擇城市", "");
	var j = 0;
	for(var i = 0; i < cityOptions.length/2; i++) {
		j = i + 1;
	    cityObject.options[j] = new Option(cityOptions[i*2],cityOptions[i*2+1]);
	}
}

function initprovcity(provinceid, province) {
	var provObject = document.getElementById(provinceid);
    for(var i = 0; i < provObject.options.length; i++) {
        if (provObject.options[i].value == province) {
        	provObject.selectedIndex = i;
			break;
        }
    }
    //setcity(provinceid, cityid);
}

function showprovince(provinceid, cityid, province) {
	var provinces = new Array(
		"台灣", "海外"
	);

	var html = "<select name=\"" + provinceid + "\" id=\"" + provinceid + "\" onchange=\"setcity('" + provinceid + "', '" + cityid + "');\">";
	html = html + "<option value=\"\">選擇省份</option>";
	for(var i = 0; i < provinces.length; i++) {
		html = html + "<option value=\"" + provinces[i] + "\">" + provinces[i] + "</option>";
	}
	html = html + "</select>";
	document.write(html);

	initprovcity(provinceid, province);

}

function showcity(cityid, city, provinceid) {
	if(isUndefined(provinceid)) provinceid = '';
	var html = "&nbsp;<select name=\"" + cityid + "\" id=\"" + cityid + "\">";
	if(provinceid == '') {
		if(city == "") {
			html = html + "<option value=\"\">選擇城市</option>";
		} else {
			html = html + "<option value=\"" + city + "\">" + city + "</option>";
		}
	}
	html = html + "</select>";
	document.write(html);
	if(provinceid != '') {
		setcity(provinceid, cityid);
		initprovcity(cityid, city);
	}
}

