﻿var countrylist = new Array("US:United States","CA:Canada","MX:Mexico");

var statelist = new Array();
statelist["US"] = new Array("AK:Alaska","AL:Alabama","AR:Arkansas","AS:American Samoa","AZ:Arizona","CA:California","CO:Colorado","CT:Connecticut","DC:District Of Columbia","DE:Delaware","FL:Florida","FM:Federated States Of Micronesia","GA:Georgia","GU:Guam","HI:Hawaii","IA:Iowa","ID:Idaho","IL:Illinois","IN:Indiana","KS:Kansas","KY:Kentucky","LA:Louisiana","MA:Massachusetts","MD:Maryland","ME:Maine","MH:Marshall Islands","MI:Michigan","MN:Minnesota","MO:Missouri","MP:Northern Mariana Islands","MS:Mississippi","MT:Montana","NC:North Carolina","ND:North Dakota","NE:Nebraska","NH:New Hampshire","NJ:New Jersey","NM:New Mexico","NV:Nevada","NY:New York","OH:Ohio","OK:Oklahoma","OR:Oregon","PA:Pennsylvania","PR:Puerto Rico","PW:Palau","RI:Rhode Island","SC:South Carolina","SD:South Dakota","TN:Tennessee","TX:Texas","UT:Utah","VA:Virginia","VI:Virgin Islands","VT:Vermont","WA:Washington","WI:Wisconsin","WV:West Virginia","WY:Wyoming");
statelist["CA"] = new Array("AB:Alberta","BC:British Columbia","MB:Manitoba","NB:New Brunswick","NL:Newfoundland","NS:Nova Scotia","NT:Northwest Territories","NU:Nunavut","ON:Ontario","PE:Prince Edward Island","QC:Quebec","SK:Saskatchewan","YT:Yukon Territory");
statelist["MX"] = new Array("QROO:Quintana Roo","BCS:Baja California Sur")

var citylist = new Array();
citylist["Alabama"]=new Array("Gulf Shores","Orange Beach");
citylist["Arizona"]=new Array("Lakeside","Pinetop","Show Low");
citylist["British Columbia"]=new Array("Big White","Whistler");
citylist["California"]=new Array("Alpine Meadows","Angels Camp","Arnold","Bermuda Dunes","Big Bear City","Big Bear Lake","Big Trees Village","Blue Lake Springs","Cardiff By The Sea","Carlsbad","Carnelian Bay","Cathedral City","Columbia","Del Mar","Dorrington","Encinitas","Ganns Meadow","Groveland","Hathaway Pines","Homewood","Indio","Irish Beach","Kings Beach","La Jolla","La Quinta","Leucadia","Manchester","Meeks Bay","Mi Wuk Village","Mission Beach","Moonridge","Oceanside","Olympic Valley","Pacific Beach","Palm Desert","Palm Springs","Paso Robles","Pinecrest","PLAM DESERT","Rancho Mirage","San Diego","Santa Rosa","Sierra Park","Sierra Village","Solana Beach","Sonora","South Lake Tahoe","South Mission Beach","Tahoe City","Tahoe Vista","Tahoma","Truckee","Twain Harte");
citylist["Colorado"]=new Array("Telluride");
citylist["Florida"]=new Array("Blue Mountain Beach","Cape Coral","Cape Haze","Cape San Blas","Captiva","Clearwater Beach","Clermont","Davenport","Delray Beach","Destin","Dune Allen Beach","Fort Myers Beach","Fort Pierce","Fort Walton Beach","Grayton Beach","Gulfport","Indian Pass","Indian Rocks Beach","Indian Shores","Inlet Beach","Islamorada","Jacksonville Beach","Jensen Beach","Key Largo","Key West","Kissimmee","Longboat Key","Madeira Beach","Marco Island","Melbourne Beach","Miami Beach","Miramar Beach","Naples","North Redington Beach","Ocean Ridge","Orlando","Panama City Beach","Placida","Pompano Beach","Ponte Vedra Beach","Ponte Vedra","Port Saint Joe","Redington Beach","Redington Shores","Rosemary Beach","Sanibel Island","Sanibel","Santa Rosa Beach","Seacrest Beach","Seagrove Beach","Seaside","St. Pete Beach","St. Petersburg","Stuart","Tavernier","Treasure Island","Vero Beach","Watercolor","Watersound Beach","Watersound");
citylist["Georgia"]=new Array("Blairsville","Blue Ridge","Clayton","Epworth","Humphrey Heights Rd","Mineral Bluff","Morganton","St. Simons Island");
citylist["Hawaii"]=new Array("Anahola","Haleiwa","Honolulu","Kahuku","Kailua Kona","Kailua-Kona","Kamuela","Kapaa","Kapa'a","Kapalua","Keauhou","Kihei Maui","Kihei","Kohala Coast","Koloa","Kona","Lahaina","Mauna Lani","Poipu","Princeville","Waikoloa Beach","Waikoloa","Wailea Maui","Wailea");
citylist["Idaho"]=new Array("Bayview","Donnelly","Garden Valley","Lowman","MCCALL","New Meadows");
citylist["Maryland"]=new Array("Cambridge","Centerville","Chestertown","Easton","Kennedyville","Oxford","Royal Oak","St. Michaels","Tilghman Island");
citylist["Massachusetts"]=new Array("Chilmark","Oak Bluffs","Vineyard Haven");
citylist["Montana"]=new Array("Big Arm","Bigfork","Dayton","Kalispell","Lakeside","Rollins","Seeley Lake","Somers","Yellow Bay");
citylist["Nevada"]=new Array("Henderson","Lake Las Vegas","South Lake Tahoe","Stateline","Zephyr Cove");
citylist["New Mexico"]=new Array("Santa Fe","Taos");
citylist["Oregon"]=new Array("Arch Cape","Bay City","Bend","Black Butte Ranch","Cannon Beach","Cape Meares","Depoe Bay","Florence","Gearhart","Gleneden Beach","Lincoln Beach","Lincoln City","Manzanita","Neahkahnie","Nehalem","Neskowin","Netarts","Newport","Oceanside","Otter Rock","Pacific City","Rhododendron","Rockaway Beach","Seal Rock","Seaside","South Beach","Sunriver","Waldport","Yachats");
citylist["South Carolina"]=new Array("Dewees Island","Edisto Beach","Edisto Island","Hilton Head Island","Hilton Head","Isle of Palms","Myrtle Beach","North Myrtle Beach","Sullivan's Island","Wild Dunes");
citylist["Tennessee"]=new Array("Ducktown","Galinburg","Gatlinburg","Pigeon Forge","Sevierviile","Sevierville");
citylist["Texas"]=new Array("Galveston","Port Aransas","Sea Isle","South Padre Island");
citylist["Vermont"]=new Array("Killington","Pico","Pittsfield","Shrewsbury","Smugglers' Notch");
citylist["Virgin Islands"]=new Array("St. John");
citylist["Washington"]=new Array("Cle Elum","Easton","Freeland","Friday Harbor","Long Beach","Lopez Island","Lopez","Orcas Island - Deer Harbor","Orcas Island - Eastsound","Orcas Island - Olga","Orcas Island","Roche Harbor","Ronald","Roslyn","Seattle");
citylist["Quintana Roo"]=new Array("Akumal","Cancun","Cozumel","Playa del Carmen","Puerto Aventuras","Puerto Morelos","Soliman Bay","Tankah");
citylist["Baja California Sur"]=new Array("Cabo San Lucas","San Jose Del Cabo");

// EMPTY A DROPDOWN
function emptyList( box, start ) {

	if (box) {
		if (box.options) {
			var size = box.options.length;
			var current = box.value;

			for (i = size; i >= start; i--) {
				box.options[i] = null;
			}

			return current;
		}
	}

}

function dpfillcountry(countrycode, statecode, cityname) {

    var box = document.getElementById("ddlCountry");
	if (box) {
		if (!box.options) {
			return;
		}
	}
	emptyList(box,0);
	if (box) {
		for (var i = 0; i < countrylist.length; i++) {
			var res = countrylist[i].split(":");

			if (res[1]) {
				option = new Option( res[1], res[0] );
			} else {
				option = new Option( res[0], res[0] );
			}
			box.options[box.length] = option;
		}
		if(countrycode!="")
			box.value=countrycode;
		dpfillstate(statecode, cityname);
	}	
}

function dpfillstate(statecode, cityname) {

    var countrycode=document.getElementById("ddlCountry").value;      
	var box = document.getElementById("ddlState");
	if (box) {
		if (!box.options) {
			return;
		}
	}
	emptyList(box,0);
	if (box) {
		for (var i = 0; i < statelist[countrycode].length; i++) {
			var res = statelist[countrycode][i].split(":");

			if (res[1]) {
				option = new Option( res[1], res[0] );
			} else {
				option = new Option( res[0], res[0] );
			}
			box.options[box.length] = option;			
		}
		if(statecode!="")
			box.value=statecode;		
		dpfillcity(cityname);
	}
}

function dpfillcity(cityname) {

    var statebox=document.getElementById("ddlState");     
    var statename = statebox.options[statebox.selectedIndex].text;
    
	var box = document.getElementById("ddlCity");
	if (box) {
		if (!box.options) {
			return;
		}
	}
	emptyList(box,0);
	if (box) {	
	option = new Option("Any", "");
	box.options[box.length]=option;
	if(citylist[statename])
	{
	    	for (var i = 0; i < citylist[statename].length; i++) {			
            option = new Option( citylist[statename][i], citylist[statename][i]);			
			box.options[box.length] = option;
		}
	}
	    if(cityname!="")
			box.value=cityname;
	}
}


var countryid;
var stateid;
var cityid;

function dpfillcountry1(coutryid,sid,cid,countrycode, statecode, cityname) {

 countryid=coutryid;
 stateid=sid;
 cityid=cid;

    var box = document.getElementById(countryid);
	if (box) {
		if (!box.options) {
			return;
		}
	}
	emptyList(box,0);
	if (box) {
		for (var i = 0; i < countrylist.length; i++) {
			var res = countrylist[i].split(":");

			if (res[1]) {
				option = new Option( res[1], res[0] );
			} else {
				option = new Option( res[0], res[0] );
			}
			box.options[box.length] = option;
		}
		if(countrycode!="")
			box.value=countrycode;
		dpfillstate1(statecode, cityname);
	}	
}

function dpfillstate1(statecode, cityname) {

    var countrycode=document.getElementById(countryid).value;      
	var box = document.getElementById(stateid);
	if (box) {
		if (!box.options) {
			return;
		}
	}
	emptyList(box,0);
	if (box) {
		for (var i = 0; i < statelist[countrycode].length; i++) {
			var res = statelist[countrycode][i].split(":");

			if (res[1]) {
				option = new Option( res[1], res[0] );
			} else {
				option = new Option( res[0], res[0] );
			}
			box.options[box.length] = option;			
		}
		if(statecode!="")
			box.value=statecode;		
		dpfillcity1(cityname);
	}
}

function dpfillcity1(cityname) {

    var statebox=document.getElementById(stateid);     
    var statename = statebox.options[statebox.selectedIndex].text;
    
	var box = document.getElementById(cityid);
	if (box) {
		if (!box.options) {
			return;
		}
	}
	emptyList(box,0);
	if (box) {	
	option = new Option("Any", "");
	box.options[box.length]=option;
	if(citylist[statename])
	{
	    	for (var i = 0; i < citylist[statename].length; i++) {			
            option = new Option( citylist[statename][i], citylist[statename][i]);			
			box.options[box.length] = option;
		}
	}
	    if(cityname!="")
			box.value=cityname;
	}
}