//<!--
// NOTE:
// This code is placed into the public domain and may be used in any manner desired.
// 
// Jim Carlock obtained the list of country names and state names from an HTML
// document at Microsoft's website.
//
// Thursday, January 13, 2005, 7:00:52 PM
// 
var gLngMaxStateLength=0;
var gLngMaxCountryLength=0;
var gLngNumberCountries=251;
var gLngNumberStates=0;
var gLngSelectedCountry=0;
var gLngSelectedState=0;
var gArCountryInfo;
var gArStateInfo;
// NOTE:
// Some editors may exhibit problems viewing 2803 characters...
var sCountryString = "USA|Afghanistan|Albania|Algeria|American Samoa|Angola|Anguilla|Antartica|Antigua and Barbuda|Argentina|Armenia|Aruba|Ashmore and Cartier Island|Australia|Austria|Azerbaijan|Bahamas|Bahrain|Bangladesh|Barbados|Belarus|Belgium|Belize|Benin|Bermuda|Bhutan|Bolivia|Bosnia and Herzegovina|Botswana|Brazil|British Virgin Islands|Brunei|Bulgaria|Burkina Faso|Burma|Burundi|Cambodia|Cameroon|Canada|Cape Verde|Cayman Islands|Central African Republic|Chad|Chile|China|Christmas Island|Clipperton Island|Cocos (Keeling) Islands|Colombia|Comoros|Congo, Democratic Republic of the|Congo, Republic of the|Cook Islands|Costa Rica|Cote d'Ivoire|Croatia|Cuba|Cyprus|Czeck Republic|Denmark|Djibouti|Dominica|Dominican Republic|Ecuador|Egypt|El Salvador|Equatorial Guinea|Eritrea|Estonia|Ethiopia|Europa Island|Falkland Islands (Islas Malvinas)|Faroe Islands|Fiji|Finland|France|French Guiana|French Polynesia|French Southern and Antarctic Lands|Gabon|Gambia, The|Gaza Strip|Georgia|Germany|Ghana|Gibraltar|Glorioso Islands|Greece|Greenland|Grenada|Guadeloupe|Guam|Guatemala|Guernsey|Guinea|Guinea-Bissau|Guyana|Haiti|Heard Island and McDonald Islands|Honduras|Hong Kong|Howland Island|Hungary|Iceland|India|Indonesia|Iran|Iraq|Ireland|Israel|Italy|Jamaica|Jan Mayen|Japan|Jarvis Island|Jersey|Johnston Atoll|Jordan|Juan de Nova Island|Kazakhstan|Kenya|Kiribati|Korea, North|Korea, South|Kuwait|Kyrgyzstan|Laos|Latvia|Lebanon|Lesotho|Liberia|Libya|Liechtenstein|Lithuania|Luxembourg|Macau|Macedonia, Former Yugoslav Republic of|Madagascar|Malawi|Malaysia|Maldives|Mali|Malta|Man, Isle of|Marshall Islands|Martinique|Mauritania|Mauritius|Mayotte|Mexico|Micronesia, Federated States of|Midway Islands|Moldova|Monaco|Mongolia|Montserrat|Morocco|Mozambique|Namibia|Nauru|Nepal|Netherlands|Netherlands Antilles|New Caledonia|New Zealand|Nicaragua|Niger|Nigeria|Niue|Norfolk Island|Northern Mariana Islands|Norway|Oman|Pakistan|Palau|Panama|Papua New Guinea|Paraguay|Peru|Philippines|Pitcaim Islands|Poland|Portugal|Puerto Rico|Qatar|Reunion|Romainia|Russia|Rwanda|Saint Helena|Saint Kitts and Nevis|Saint Lucia|Saint Pierre and Miquelon|Saint Vincent and the Grenadines|Samoa|San Marino|Sao Tome and Principe|Saudi Arabia|Scotland|Senegal|Seychelles|Sierra Leone|Singapore|Slovakia|Slovenia|Solomon Islands|Somalia|South Africa|Spain|Spratly Islands|Sri Lanka|Sudan|Suriname|Svalbard|Swaziland|Sweden|Switzerland|Syria|Taiwan|Tajikistan|Tanzania|Thailand|Tobago|Toga|Tokelau|Tonga|Trinidad|Tunisia|Turkey|Turkmenistan|Tuvalu|Uganda|Ukraine|United Arab Emirates|United Kingdom|Uruguay|Uzbekistan|Vanuatu|Venezuela|Vietnam|Virgin Islands|Wales|Wallis and Futuna|West Bank|Western Sahara|Yemen|Yugoslavia|Zambia|Zimbabwe";
var aStates = new Array();

aStates[0]="Alabama|Alaska|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|District of Columbia|Florida|Georgia|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Maryland|Massachusetts|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Ohio|Oklahoma|Oregon|Pennsylvania|Rhode Island|South Carolina|South Dakota|Tennessee|Texas|Utah|Vermont|Virginia|Washington|West Virginia|Wisconsin|Wyoming";
aStates[1]="";
aStates[2]="";
aStates[3]="";
aStates[4]="";
aStates[5]="";
aStates[6]="";
aStates[7]="";
aStates[8]="";
aStates[9]="";
aStates[10]="";
aStates[11]="";
aStates[12]="";
aStates[13]="";
aStates[14]="";
aStates[15]="";
aStates[16]="";
aStates[17]="";
aStates[18]="";
aStates[19]="";
aStates[20]="";
aStates[21]="";
aStates[22]="";
aStates[23]="";
aStates[24]="";
aStates[25]="";
aStates[26]="";
aStates[27]="";
aStates[28]="";
aStates[29]="";
aStates[30]="";
aStates[31]="";
aStates[32]="";
aStates[33]="";
aStates[34]="";
aStates[35]="";
aStates[36]="";
aStates[37]="";
aStates[38]="Alberta|British Columbia|Manitoba|New Brunswick|Newfoundland|Northwest Territories|Nova Scotia|Nunavut|Ontario|Prince Edward Island|Quebec|Saskatchewan|Yukon Territory";
aStates[39]="";
aStates[40]="";
aStates[41]="";
aStates[42]="";
aStates[43]="";
aStates[44]="";
aStates[45]="";
aStates[46]="";
aStates[47]="";
aStates[48]="";
// <!-- -->
aStates[49]="";
aStates[50]="";
aStates[51]="";
aStates[52]="";
aStates[53]="";
aStates[54]="";
aStates[55]="";
aStates[56]="";
aStates[57]="";
aStates[58]="";
aStates[59]="";
aStates[60]="";
aStates[61]="";
aStates[62]="";
aStates[63]="";
aStates[64]="";
aStates[65]="";
aStates[66]="";
aStates[67]="";
aStates[68]="";
aStates[69]="";
aStates[70]="";
aStates[71]="";
aStates[72]="";
aStates[73]="";
aStates[74]="";
aStates[75]="";
aStates[76]="";
aStates[77]="";
aStates[78]="";
aStates[79]="";
aStates[80]="";
aStates[81]="";
aStates[82]="";
aStates[83]="";
aStates[84]="";
aStates[85]="";
aStates[86]="";
aStates[87]="";
aStates[88]="";
aStates[89]="";
aStates[90]="";
aStates[91]="";
aStates[92]="";
aStates[93]="";
aStates[94]="";
aStates[95]="";
aStates[96]="";
aStates[97]="";
aStates[98]="";
aStates[99]="";
aStates[100]="";
aStates[101]="";
aStates[102]="";
aStates[103]="";
aStates[104]="";
aStates[105]="";
aStates[106]="";
aStates[107]="";
aStates[108]="";
aStates[109]="";
aStates[110]="";
aStates[111]="";
aStates[112]="";
aStates[113]="";
aStates[114]="";
aStates[115]="";
aStates[116]="";
aStates[117]="";
aStates[118]="";
aStates[119]="";
aStates[120]="";
aStates[121]="";
aStates[122]="";
aStates[123]="";
aStates[124]="";
aStates[125]="";
aStates[126]="";
aStates[127]="";
aStates[128]="";
aStates[129]="";
aStates[130]="";
aStates[131]="";
aStates[132]="";
aStates[133]="";
aStates[134]="";
aStates[135]="";
aStates[136]="";
aStates[137]="";
aStates[138]="";
aStates[139]="";
aStates[140]="";
aStates[141]="";
aStates[142]="";
aStates[143]="";
aStates[144]="";
aStates[145]="";
aStates[146]="";
aStates[147]="";
aStates[148]="";
aStates[149]="";
aStates[150]="";
aStates[151]="";
aStates[152]="";
aStates[153]="";
aStates[154]="";
aStates[155]="";
aStates[156]="";
aStates[157]="";
aStates[158]="";
aStates[159]="";
aStates[160]="";
aStates[161]="";
aStates[162]="";
aStates[163]="";
aStates[164]="";
aStates[165]="";
aStates[166]="";
aStates[167]="";
aStates[168]="";
aStates[169]="";
aStates[170]="";
aStates[171]="";
aStates[172]="";
aStates[173]="";
aStates[174]="";
aStates[175]="";
aStates[176]="";
aStates[177]="";
aStates[178]="";
aStates[179]="";
aStates[180]="";
aStates[181]="";
aStates[182]="";
aStates[183]="";
aStates[184]="";
aStates[185]="";
aStates[186]="";
aStates[187]="";
aStates[188]="";
aStates[189]="";
aStates[190]="";
aStates[191]="";
aStates[192]="";
aStates[193]="";
aStates[194]="";
aStates[195]="";
aStates[196]="";
aStates[197]="";
aStates[198]="";
aStates[199]="";
aStates[200]="";
aStates[201]="";
aStates[202]="";
aStates[203]="";
aStates[204]="";
aStates[205]="";
aStates[206]="";
aStates[207]="";
aStates[208]="";
aStates[209]="";
aStates[210]="";
aStates[211]="";
aStates[212]="";
aStates[213]="";
aStates[214]="";
aStates[215]="";
aStates[216]="";
aStates[217]="";
aStates[218]="";
aStates[219]="";
aStates[220]="";
aStates[221]="";
aStates[222]="";
aStates[223]="";
aStates[224]="";
aStates[225]="";
aStates[226]="";
aStates[227]="";
aStates[228]="";
aStates[229]="";
aStates[230]="";
aStates[231]="";
aStates[232]="";
aStates[233]="";
aStates[234]="";
aStates[235]="";
aStates[236]="";
aStates[237]="";
aStates[238]="";
aStates[239]="";
aStates[240]="";
aStates[241]="";
aStates[242]="";
aStates[243]="";
aStates[244]="";
aStates[245]="";
aStates[246]="";
aStates[247]="";
aStates[248]="";
aStates[249]="";
aStates[250]="";
aStates[251]="";


/* 
 * gArCountryInfo
 * (0) Country name
 * (1) Name length
 * (2) Number of states
 * (3) Max state length
 */
gLngNumberCountries = sCountryString.split("|").length;
//gArCountryInfo = new Array(gLngNumberCountries);
gArCountryInfo=sCountryString.split("|");
/* 
 * gArStateInfo[country][statenames][namelengths]
 * (0) Country
 * (1) States (Multi-sized Array)
 *    (0) name
 *    (1) nameLength
 */
gArStateInfo   = new Array(gLngNumberCountries);

/* 
 * fInitgArStateInfo()
 * purpose: build gArStateInfo array
 * gArStateInfo[Country][States][1]
 *   (0) State name
 *   (1) State name length
 * gArStateInfo[i] is an array of state names
 * gArStateInfo[i][j]=state name, name length
 */
function fInitgArStateInfo() {
 var i=0, j=0, sStateName="", iNumberOfStates=0;
 var iMaxLength=0, iLength=0;
 var oldNumber=0;
 
 for (i=0;i<gLngNumberCountries;i++) {
  // i is selected country
  iNumberOfStates=aStates[i].split("|").length+1;
  gLngNumberStates=gLngNumberStates+iNumberOfStates;
  gArStateInfo[i]=new Array(iNumberOfStates);
  iMaxLength=0;
  
  // Add the additional information
  for (j=0;j<iNumberOfStates;j++) {
   if (iLength>iMaxLength) {
    iMaxLength=iLength;
    gArStateInfo[i][j][0]=sStateName;
   }
  }
  gArCountryInfo[i][3]=parseInt(iMaxLength);
 }
 Update_Globals();
 return;
}

/* 
 * Working on this one.
 * Fills in cboState from the arrays
 * 
 */
function xFillState() {
 var i=0;
 
 // reset cboState
 document.form1.State.options.length=0;
 
 // get selected country
 gLngSelectedCountry=document.form1.Country.selectedIndex;
 
 // get number of states for selected country
 gLngNumberStates=gArCountryInfo[[gLngSelectedCountry][2]];
 
 // update options in cboState
 for (i=0;i<gLngNumberStates;i++) {
  document.form1.State.options[i]=new
    Option(gArStateInfo[[gLngSelectedCountry][i][0]]);
 }
 gLngSelectedState=
  document.contact_form.State.options.selectedIndex;
 
 return;
}

/* 
 * FillStates() function works.
 * Fills cboState from aStates
 */
function Fill_States() {
	var i=0, iLen=0, iNumStates=0;
	// reset cboState
	//document.contact_form.State.options.length=0;
	document.contact_form.State.options.length=0;

	// get selected country
	gLngSelectedCountry=document.contact_form.Country.selectedIndex;
	
	var curSelect_index;
	if(gLngSelectedCountry==0)
		document.contact_form.State.options[0]=new Option('------Select State-----','');
	else if(gLngSelectedCountry==1)
	 curSelect_index = gLngSelectedCountry-1;
	 else
	 curSelect_index = gLngSelectedCountry-2;
	
	var str = aStates[curSelect_index];
	
		
		str = str.split("|");
		

	iNumStates = str.length;

	// file the state combobox with the list of states
	document.contact_form.State.options[0]=new Option('------Select State-----','');
	for (i=1;i<iNumStates;i++) {
		a = i-1;
		document.contact_form.State.options[i]=new 
			Option(aStates[curSelect_index].split("|")[a]);
	}
	/*for (i=1;i<iNumStates;i=i+2) {
		for(j=2; j<iNumStates; j=j+2){
			if(i==1){
				a=0;
			}else{
				a=i-((i-1)/2);
				a=a-1;
			}
		document.contact_form.State.options[i]=new 
			Option(aStates[document.contact_form.Country.selectedIndex].split("|")[a]);

		document.contact_form.State.options[j]=new Option('------------------------------');
		document.contact_form.State.options[j].disabled = true;
		}
	}*/
	return;
}

/*
 * FillCountry()
 * gArCountryInfo matrix holds the following information:
 * (0) Country name
 * (1) Name length
 * (2) Number of states
 * (3) Max state length
 */
function Fill_Country() {
	alert
	var i=0;
	var sCountryName="";
 
	
	document.contact_form.Country.options.length=0;
	// get number of countries from the string
 
	// ----------------------------------------------------
	// gArCountryInfo = new Array(gLngNumberCountries, 4);
	// ----------------------------------------------------
	for (i=0;i<gLngNumberCountries;i++)
	{
		gArCountryInfo[i]=new Array(4);
	}
	document.contact_form.Country.options[0]=new Option('------Select Country-----','');
	document.contact_form.Country.options[1]=new Option('USA');
 	document.contact_form.Country.options[2]=new Option('---------------------------------------------');
	document.contact_form.Country.options[2].disabled=true;
	for (i=1;i<gLngNumberCountries;i++) {
		a = i+2;
		document.contact_form.Country.options[a]=new Option(sCountryString.split("|")[i]);
		sCountryName=document.contact_form.Country.options[a];

		//document.contact_form.txtState.value=sCountryName;

		// gArCountryInfo[i][0]=sCountryName;
		// gArCountryInfo[i][1]=sCountryName.length;
		// gArCountryInfo[i][2]=aStates.split("|")[i].length;
		// gArCountryInfo[i][3]=0;
		gArCountryInfo[a]=
			[sCountryName, 
				parseInt(sCountryName.length),
				aStates,
			0];
	}
	document.contact_form.Country.selectedIndex=0;
	Fill_States();
	fInitgArStateInfo();

	return;
}

function updSelectState(lngState) {
	if (gLngSelectedCountry>0) {
		document.contact_form.State.selectedIndex = lngState;
	}
}



//-->
