/******************* File Comments **************************
Filename:		cscombo.js
Description:	This file populates comboboxes with all
	known countries (as of 03/26/2003).  When the user
	selects a country the state combobox will be populated
	with the states associated with the country selected.
Compatibility:
	MSIE 4, 5, 6
	Netscape 4.7, 6, 7
	WebTV
	Opera	
Usage:		I generally have this command executed just before
	the closing < / body > tag.  Also in the onChange event
	of the Country combobox.
Warnings:	There is a bug in IE that requires the focus to 
	be shifted any other control on the form or the defaults
	will be off by one.  There is a fix within the code however 
	if causes focus to be sent to either the country or state
	combobox.  Quick fix would be to add a *.focus();
	event to fire to a textbox on the form.

Example 1:
	...page...
	< SCRIPT >
		FillCountry(document.form1.Country, document.form1.State, 'USA');
		FillState(document.form1.Country, document.form1.State, 'Florida');
		document.form1.Title.focus();
	< / SCRIPT >
	< / body >
	< / html >
	...end...
Example 2:
	 onChange="FillState(document.form1.Country, document.form1.State, 'Florida')"

This file was created by Brian Reeves  (ketapillar'ayat'hotmail.com)
Open Source feel free to take.  I do appreciate feedback as
well.  BTW vote at www.planet-source-code.com thanks.

Created:	@12/01/2002		brian
Modified:	3/26/2003		brian
	Modified so that the whole contents work by passing the
	comboboxes to the function.  Also changed the coding so
	that it resides in a script include.  No longer requires
	minimal ASP.
*************************************************************/

/******************* FillCountry() Comments *****************
This function needs to be called first to populate the country
combobox.  

Created:	@12/01/2002		brian
Modified:	3/26/2003		brian
	Modified to allow the passing of combo's instead of hard
	coding them.  Also created the default capabilities of
	passing a default country to be selected.

Example:  FillCountry(NameOfCountryCombo, NameOfStateCombo, DefaultCountry)
*************************************************************/
function FillCountry(cboCountry, cboState, sDefaultCountry){
	var sDefaultCountry, sDefault, sCountry
		
	cboCountry.options.length=0
	for(i=0;i<sCountryString.split("|").length;i++){
		sCountry = sCountryString.split("|")[i];

		if (sDefaultCountry == sCountry) {
			sDefault=true;
			if (navigator.appName=="Microsoft Internet Explorer"){cboState.focus();}
		}
		else {sDefault=false;}
		
		if (sDefault) {cboCountry.options[i]=new Option(sCountry,sCountry,sDefault,sDefault);}
		else {cboCountry.options[i]=new Option(sCountryString.split("|")[i]);}
	}
}
if (navigator.appName=="Netscape"){
isNav=true
}

/******************* FillState() Comments *******************
This function needs to be called after the FillCountry() to
populate the State combobox.  Also from the onChange of the
country combobox.

Created:	@12/01/2002		brian
Modified:	3/26/2003		brian
	Modified to allow the passing of combo's instead of hard
	coding them.  Also created the default capabilities of
	passing a default country to be selected.

Example:  FillState(NameOfCountryCombo, NameOfStateCombo, DefaultState)
*************************************************************/
function FillState(cboCountry, cboState, sDefaultState){
	var sDefaultState, sState, sDefault
		
	cboState.options.length=0
	for(i=0;i<sStateArray[cboCountry.selectedIndex].split("|").length;i++){
		sState = sStateArray[cboCountry.selectedIndex].split("|")[i];
		
		if(sDefaultState == sState) {
			sDefault=true;
			if (navigator.appName=="Microsoft Internet Explorer"){cboState.focus();}
		} 
		else {sDefault=false;}
		
		if(sDefault) {cboState.options[i]=new Option(sState,sState,sDefault,sDefault)}
		else {cboState.options[i]=new Option(sState,sState);}
	}
}

var sCountryString = "--SelectState--|Andhra Pradesh|Arunchal pradesh|Assam|Bihar|Chattisgarh|Delhi|Goa|Gujrat|Haryana|Himachal Pradesh|Jammu and Kashmir|Jharkhand |Karnataka|Kerala|Madhya Pradesh|Maharashtra|Manipur|Meghalaya|Mizoram|Nagaland|Orissa|Punjab|Rajasthan|Sikkim|Tamil Nadu|Tripura|Uttar Pradesh|Uttaranchal|West Bengal"

                		var sStateArray = new Array()
                		sStateArray[0]="--Select City--"
                		sStateArray[1]="Anantapur|Chitoor|Cuddapah|Guntur|Hyderabad|Kakinada|Kurnool|Nellore|Nizamabad|Puttaparthi|Rajahmundry|Tirupati|Vijayawada|Visakhapatnam|Warangal"
                		sStateArray[2]="Itanagar"
                		sStateArray[3]="Guwahati|Jorhat|Silchar"
                		sStateArray[4]="Bhagalpur|Gaya|Jamshedpur|Patna"
                		sStateArray[5]="Bhilai|Bilaspur|Raipur"
                		sStateArray[6]="New Delhi| Old Delhi"
                		sStateArray[7]="Panaji"
                		sStateArray[8]="Ahmedabad|Anand|Barod|Bharuch|Bhavnagar|Dwarka|Jamnagar|Junagadh|Nadiad|Porbandar|Rajkot|Surat|Valsad|Vapi"
                		sStateArray[9]="Ambala|Faridabad|Gurgaon|Hissar|Karnal|Kurukshetra|Panipat|Rohtak|Yamunanagar"
                		sStateArray[10]="Dalhousie|Kullu|Shimla|Solan"
                		sStateArray[11]="Srinagar|Jammu|Ladakh"
                		sStateArray[12]="Dhanbad|Ranchi"
                		sStateArray[13]="Bangalore|Belgaum|Bellary|Bhatkal|Bidar|Bijapur|Chikmagalur|Chitradurga|Davanagere|Dharwad|Gadag|Gulbarga|Hampi|Hassan|Hospet|Karwar|Kolar|Madikeri|Mandya|Mangalore|Manipal|Mysore|Raichur|Shimoga|Sirsi|Sringeri|Srirangapatna|Tumkur|Udupi"
                		sStateArray[14]="Alleppey|Alwaye|Idukki|Kannur|Kochi|Kollam|Kottayam|Kovalam|Kozhikode|Malappuram|Palakkad|Pathanamthitta|Perumbavoor|Trichur|Trivandrum"
                		sStateArray[15]="Bhopal|Dewas|Gwalior|Indore|Jabalpur|Jagdalpur|Ratlam"
                		sStateArray[16]="Ahmednagar|Akola|Amravati|Aurangabad|Dhule|Jalgaon|Kolhapur|Mahabaleshwar|Mumbai|Nagpur|Nanded|Nashik|Pune|Sangli|Satara|Sholapur|Thane|Wardha"
                		sStateArray[17]="Imphal"
                		sStateArray[18]="Shillong"
                		sStateArray[19]="Aizawl"
                		sStateArray[20]="Kohima"
                		sStateArray[21]="Balasore|Berhampur|Bhubaneswar|Cuttack|Rourkela|Sambalpur"
                		sStateArray[22]="Amritsar|Bhatinda|Jalandhar|Ludhiana|Pathankot|Patiala"
                		sStateArray[23]="Ajmer|Alwar|Bharatpur|Bhilwara|Bikaner|Jaipur|Jaisalmer|Jodhpur|Kota|Pilani|Udaipur"
                		sStateArray[24]="Gangtok"
                		sStateArray[25]="Chennai|Chidambaram|Chingleput|Coimbatore|Courtallam|Cuddalore|Dharmapuri|Dindigul|Erode|Hosur|Kanchipuram|Kanyakumari|Karaikudi|Karur|Kodaikanal|Kovilpatti|Kumbakonam|Madurai|Mayiladuthurai|Nagarcoil|Namakkal|Neyveli|Ooty|Palani|Pollachi|Pudukotai|Rajapalayam|Ramanathapuram|Salem|Sivakasi|Thanjavur|Tirunelveli|Tirupur|Tiruvannamalai|Trichy|Tuticorin|Vellore|Villupuram|Virudunagar|Yercaud"
                		sStateArray[26]="Agartala"
                		sStateArray[27]="Agra|Aligarh|Allahabad|Amethi|Bareilly|Ghaziabad|Gorakhpur|Jhansi|Kanpur|Kumaon|Lucknow|Mathura|Meerut|Moradabad|Noida|Pantnagar|Roorkee|Saharanpur|Varanasi"
                		sStateArray[28]="Almora|Dehradun|Haridwar|Mussoorie|Nainital"
                       sStateArray[29]="Bardhaman|Darjeeling|Kolkata|Murshidabad"