﻿function setcity(provinceid, cityid) {
	var province = document.getElementById(provinceid).value;
    switch (province) {

        case "East-US" :
            var cityOptions = new Array(
            "CT_Bridgeport", "CT_Bridgeport",
            "CT_Hartford", "CT_Hartford",
            "CT_New Haven", "CT_New Haven",
            "DE_Wilmington", "DE_Wilmington",
            "DE_Dover", "DE_Dover",
            "DE_Newark", "DE_Newark",
            "FL_Jacksonville", "FL_Jacksonville",
            "FL_Miami", "FL_Miami",
            "FL_Tampa", "FL_Tampa",
            "GA_Atlanta", "GA_Atlanta",
            "GA_Augusta", "GA_Augusta",
            "GA_Columbus", "GA_Columbus",
            "MA_Boston", "MA_Boston",
            "MA_Worcester", "MA_Worcester",
            "MA_Springfield", "MA_Springfield",
            "MD_Baltimore", "MD_Baltimore",
            "MD_Frederick", "MD_Frederick",
            "MD_Gaithersburg", "MD_Gaithersburg",
            "ME_Portland", "ME_Portland",
            "ME_Lewiston", "ME_Lewiston",
            "ME_Bangor", "ME_Bangor",
            "MI_Detroit", "MI_Detroit",
            "MI_Grand Rapids", "MI_Grand Rapids",
            "MI_Warren", "MI_Warren",
            "NC_Charlotte", "NC_Charlotte",
            "NC_Raleigh", "NC_Raleigh",
            "NC_Greensboro", "NC_Greensboro",
            "NH_Manchester", "NH_Manchester",
            "NH_Nashua", "NH_Nashua",
            "NH_Concord", "NH_Concord",
            "NJ_Newark", "NJ_Newark",
            "NJ_Jersey City", "NJ_Jersey City",
            "NJ_Paterson", "NJ_Paterson",
            "NY_New York", "NY_New York",
            "NY_Buffalo", "NY_Buffalo",
            "NY_Rochester", "NY_Rochester",
            "OH_Columbus", "OH_Columbus",
            "OH_Cleveland", "OH_Cleveland",
            "OH_Cincinnati", "OH_Cincinnati",
            "PA_Philadelphia", "PA_Philadelphia",
            "PA_Pittsburgh", "PA_Pittsburgh",
            "PA_Allentown", "PA_Allentown",
            "RI_Providence", "RI_Providence",
            "RI_Warwick", "RI_Warwick",
            "RI_Cranston", "RI_Cranston",
            "SC_Columbia", "SC_Columbia",
            "SC_Charleston", "SC_Charleston",
            "SC_N Charleston", "SC_N Charleston",
            "VA_Virg_Beach", "VA_Virg_Beach",
            "VA_Norfolk", "VA_Norfolk",
            "VA_Chesapeake", "VA_Chesapeake",
            "Washington D.C.", "Washington D.C.",
            "VT_Burlington", "VT_Burlington",
            "VT_Rutland", "VT_Rutland",
            "VT_S Burlington", "VT_S Burlington",
            "WV_Charleston", "WV_Charleston",
            "WV_Huntington", "WV_Huntington",
            "WV_Parkersburg", "WV_Parkersburg");
             break;

        case "West-US" :
            var cityOptions = new Array(
            "AZ_Phoenix", "AZ_Phoenix",
            "AZ_Tucson", "AZ_Tucson",
            "AZ_Mesa", "AZ_Mesa",
            "CA_Los Angeles", "CA_Los Angeles",
            "CA_San Francisco", "CA_San Francisco",
            "CA_San Diago", "CA_San Diago",
            "CO_Denver", "CO_Denver",
            "CO_Colo_Springs", "CO_Colo_Springs",
            "CO_Aurora", "CO_Aurora",
            "ID_Boise", "ID_Boise",
            "ID_Nampa", "ID_Nampa",
            "ID_Idaho Falls", "ID_Idaho Falls",
            "MT_Billings", "MT_Billings",
            "MT_Missoula", "MT_Missoula",
            "MT_Great Falls", "MT_Great Falls",
            "NM_Albuquerque", "NM_Albuquerque",
            "NM_Las Cruces", "NM_Las Cruces",
            "NM_Santa Fe", "NM_Santa Fe",
            "NV_Las Vegas", "NV_Las Vegas",
            "NV_Henderson", "NV_Henderson",
            "NV_Reno", "NV_Reno",
            "OR_Portland", "OR_Portland",
            "OR_Salem", "OR_Salem",
            "OR_Eugene", "OR_Eugene",
            "UT_Salt Lake", "UT_Salt Lake",
            "UT_Provo", "UT_Provo",
            "UT_West Valley", "UT_West Valley",
            "WA_Seattle", "WA_Seattle",
            "WA_Spokane", "WA_Spokane",
            "WA_Tacoma", "WA_Tacoma",
            "WY_Cheyenne", "WY_Cheyenne",
            "WY_Casper", "WY_Casper",
            "WY_Laramie", "WY_Laramie");
             break;


        case "Cent-US" :
            var cityOptions = new Array(
            "AL_Birmingham", "AL_Birmingham",
            "AL_Montgomery", "AL_Montgomery",
            "AL_Mobile", "AL_Mobile",
            "AR_Little Rock", "AR_Little Rock",
            "AR_Fort Smith", "AR_Fort Smith",
            "AR_Fayetteville", "AR_Fayetteville",
            "IA_Des Moines", "IA_Des Moines",
            "IA_Cedar Rapids", "IA_Cedar Rapids",
            "IA_Davenport", "IA_Davenport",

            "IL_Chicago", "IL_Chicago",
            "IL_Aurora", "IA_Aurora",
            "IL_Rockford", "IL_Rockford",

            "IN_Indianapolis", "IN_Indianapolis",
            "IN_Fort Wayne", "IN_Fort Wayne",
            "IN_Evansville", "IN_Evansville",

            "LA_New Orleans", "LA_New Orleans",
            "LA_Baton Rouge", "LA_Baton Rouge",
            "LA_Shreveport", "LA_Shreveport",
            "MN_Minneapolis", "MN_Minneapolis",
            "MN_Saint Paul", "MN_Saint Paul",
            "MN_Rochester", "MN_Rochester",

            "MO_Kansas City", "MO_Kansas City",
            "MO_Saint Louis", "MO_Saint Louis",
            "MO_Springfield", "MO_Springfield",
            "MS_Jackson", "MS_Jackson",
            "MS_Gulfport", "MS_Gulfport",
            "MS_Biolex", "MS_Biolex",

            "TN_Memphis", "TN_Memphis",
            "TN_Nashville", "TN_Nashville",
            "TN_Knoxville", "TN_Knoxville",
            "WI_Milwaukee", "WI_Milwaukee",
            "WI_Madison", "WI_Madison",
            "WI_Green Bay", "WI_Green Bay");
             break;


        case "Not US" :
            var cityOptions = new Array(
            "Europe", "Europe",
            "Asia", "Asia",
            "South America", "South America",
            "Africa", "Africa",
            "Others", "Others");
            break;
        default:
            var cityOptions = new Array("City", "");
            break;
    }
	
	var cityObject = document.getElementById(cityid);
	cityObject.options.length = 0;
	cityObject.options[0] = new Option("City", "");
	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(
		"East-US", "West-US", "Cent-US",  "Not US"
	);

	var html = "<select name=\"" + provinceid + "\" id=\"" + provinceid + "\" onchange=\"setcity('" + provinceid + "', '" + cityid + "');\">";
	html = html + "<option value=\"\">State</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) {


	var html = "&nbsp;<select name=\"" + cityid + "\" id=\"" + cityid + "\">";
	if(city == "") {
		html = html + "<option value=\"\">City</option>";
	} else {
		html = html + "<option value=\"" + city + "\">" + city + "</option>";
	}
	html = html + "</select>";
	document.write(html);
}