/******************* 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);}
	}
}

function FillStatetemp(cboCountry, cboState, sDefaultState){
	var sDefaultState, sState, sDefault
		
	cboState.options.length=0
	for(i=0;i<sStateArray1[cboCountry.selectedIndex].split("|").length;i++){
		sState = sStateArray1[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);}
	}
}

function FillStateciudad(cboCountry, cboState, sDefaultState, ciudades){
	var sDefaultState, sState, sDefault, ciudad, j, ciudad1
	
	/*if (cboCountry.value == "Alicante") { /*ciudad = ciudades.substr(1,8);*/ /*ciudad = "111111111" }
		else {*/ ciudad = "111111111";/* }*/
	/*if (cboCountry == 'A Coruña') { ciudad = ciudades.substr(9,16); }
	if (cboCountry == 'Barcelona') { ciudad = ciudades.substr(17,24); }
	if (cboCountry == 'Bilbao') { ciudad = ciudades.substr(25,32); }
	if (cboCountry == 'Burgos') { ciudad = ciudades.substr(33,40); }
	if (cboCountry == 'Castellón') { ciudad = ciudades.substr(41,48); }
	if (cboCountry == 'Costa del Sol') { ciudad = ciudades.substr(49,56); }
	if (cboCountry == 'Cuenca') { ciudad = ciudades.substr(57,64); }
	if (cboCountry == 'C. Gibraltar') { ciudad = ciudades.substr(65,72); }
	if (cboCountry == 'Gijón') { ciudad = ciudades.substr(73,80); }
	if (cboCountry == 'Girona') { ciudad = ciudades.substr(81,88); }
	if (cboCountry == 'Granada') { ciudad = ciudades.substr(89,96); }
	if (cboCountry == 'Huelva') { ciudad = ciudades.substr(97,104); }
	if (cboCountry == 'Ibiza') { ciudad = ciudades.substr(105,112); }
	if (cboCountry == 'Las Palmas') { ciudad = ciudades.substr(113,120); }
	if (cboCountry == 'Lleida') { ciudad = ciudades.substr(121,128); }
	if (cboCountry == 'León') { ciudad = ciudades.substr(129,136); }
	if (cboCountry == 'Logroño') { ciudad = ciudades.substr(137,144); }
	if (cboCountry == 'Málaga') { ciudad = ciudades.substr(145,152); }
	if (cboCountry == 'Madrid') { ciudad = ciudades.substr(153,160); }
	if (cboCountry == 'Madrid Norte') { ciudad = ciudades.substr(161,168); }
	if (cboCountry == 'Mallorca') { ciudad = ciudades.substr(169,176); }
	if (cboCountry == 'Oviedo') { ciudad = ciudades.substr(177,184); }
	if (cboCountry == 'Pamplona') { ciudad = ciudades.substr(185,192); }
	if (cboCountry == 'Pontevedra / Vigo') { ciudad = ciudades.substr(193,200); }
	if (cboCountry == 'San Sebastián') { ciudad = ciudades.substr(201,208); }
	if (cboCountry == 'Santa Cruz de Tenerife') { ciudad = ciudades.substr(249,256); }
	if (cboCountry == 'Santander') { ciudad = ciudades.substr(209,216); }
	if (cboCountry == 'Santiago de Compostela') { ciudad = ciudades.substr(217,224); }
	if (cboCountry == 'Sevilla') { ciudad = ciudades.substr(225,232); }
	if (cboCountry == 'Sitges') { ciudad = ciudades.substr(233,240); }
	if (cboCountry == 'Tarragona / Reus') { ciudad = ciudades.substr(241,248); }
	
	if (cboCountry == 'Toledo') { ciudad = ciudades.substr(257,264); }
	if (cboCountry == 'Valencia') { ciudad = ciudades.substr(265,272); }
	if (cboCountry == 'Valladolid') { ciudad = ciudades.substr(273,280); }
	if (cboCountry == 'Vitoria') { ciudad = ciudades.substr(281,288); }
	if (cboCountry == 'Zaragoza') { ciudad = ciudades.substr(289,296); }*/
	
	/*ciudad1 = ciudad.substr(0,1);*/
	cboState.options.length=0
/*	for(i=0;i<sStateArray2[cboCountry.selectedIndex].split("|").length;i++){*/
	for(i=0;i<sStateArray2[0].split("|").length;i++){
		if (ciudad.substr(i,1) == "1") {
		sState = sStateArray2[0].split("|")[i];
		/*sState = sStateArray2[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);}
		}
		/*j=j+1;*/
	}
}


var sCountryString = "Bar|Cine|Cultura|Gimnasio|Restaurante|Teatro|Tiendas|Turismo"
		
var sStateArray = new Array()
sStateArray[0]=""
sStateArray[1]="Todas|A Coruña|Narón|Santiago de Compostela"
sStateArray[2]="Todas|Cigoitia|Vitoria"
sStateArray[3]="Todas|Albacete"
sStateArray[4]="Todas|Alcoy|Alicante|Benidorm|Denia|Elche|Elda|Finestrat|Petrer|San Juan|San Vicente del Raspeig|Torrevieja|Villajoyosa|Villena"
sStateArray[5]="Todas|Almería|El Ejido|Roquetas de Mar"
sStateArray[6]="Todas|Avilés|Corvera|El Entrego|Gijón|La Calzada|Oviedo|Paredes-Lugones"
sStateArray[7]="Todas|Ávila"
sStateArray[8]="Todas|Almendralejo|Badajoz|Don Benito|Mérida"
sStateArray[9]="Todas|Ibiza|Palma de Mallorca"
sStateArray[10]="Todas|Arenys de Mar|Badalona|Barberá del Vallés|Barcelona|Berga|Castelldefels|Cerdanyola|Cornellá de Llobregat|Granollers|L´Hospitalet de Llobregat|Igualada|Manresa|Mataró|Mollet del Vallés|Ripoll|Sabadell|Sant Andreu de la Barca|Sant Cugat del Vallés|Sant Feliu de Llobregat|Terrassa|Vic"
sStateArray[11]="Todas|Burgos"
sStateArray[12]="Todas|Cáceres|Coria"
sStateArray[13]="Todas|Cádiz|Jerez de la Frontera|Los Barrios|San Fernando|Sanlúcar de Barrameda"
sStateArray[14]="Todas|Camargo|Santander"
sStateArray[15]="Todas|Benicarló|Castellón|Villareal"
sStateArray[16]="Todas|Ceuta"
sStateArray[17]="Todas|Alcázar de San Juan|Ciudad Real"
sStateArray[18]="Todas|Córdoba|Lucena|Puente Genil"
sStateArray[19]="Todas|Cuenca"
sStateArray[20]="Todas|Figueres|Girona|Olot|Platja d´Aro|Roses|Salt"
sStateArray[21]="Todas|Granada|Pulianas"
sStateArray[22]="Todas|Guadalajara"
sStateArray[23]="Todas|Irún|Rentería|San Sebastián|Txikierdi"
sStateArray[24]="Todas|Huelva|Islantilla|Lepe"
sStateArray[25]="Todas|Barbastro|Binefar|Fraga|Graus|Huesca|Jaca|Monzón|Sabiñánigo|Tamarite de Litera"
sStateArray[26]="Todas|Jaén|Linares|Úbeda"
sStateArray[27]="Todas|Calahorra|Logroño"
sStateArray[28]="Todas|Fuerteventura|Las Palmas de Gran Canaria|Santa Lucía de Tirajana"
sStateArray[29]="Todas|León|Ponferrada"
sStateArray[30]="Todas|Alfarrás|Balaguer|Cervera|Linyola|Lleida|Mollerussa|Pobla de Segur|Pont de Suert|Solsona|Sort|Tárrega|Tremp|Vielha"
sStateArray[31]="Todas|Lugo"
sStateArray[32]="Todas|Alcalá de Henares|Alcobendas|Alcorcón|Arroyomolinos|Collado Villalba|Colmenar Viejo|Coslada|Fuenlabrada|Getafe|Leganés|Madrid|Majadahonda|Parla|Pinto|Pozuelo de Alarcón|Rivas Vaciamadrid|San Sebastián de los Reyes|Torrejón de Ardoz|Tres Cantos"
sStateArray[33]="Todas|Antequera|Coín|Fuengirola|Málaga|Marbella|Rincón de la Victoria|Vélez"
sStateArray[34]="Todas|Melilla"
sStateArray[35]="Todas|Águilas|Cartagena|Lorca|Los Alcázares|Molina de Segura|Murcia"
sStateArray[36]="Todas|Cordovilla|Estella|Huarte|Pamplona|Tudela|Viiana"
sStateArray[37]="Todas|Ourense"
sStateArray[38]="Todas|Palencia"
sStateArray[39]="Todas|Lalín|Pontevedra|Vigo"
sStateArray[40]="Todas|Salamanca|Santa Marta de Tormes"
sStateArray[41]="Todas|La Laguna|La Orotava|Santa Cruz de Tenerife"
sStateArray[42]="Todas|Segovia"
sStateArray[43]="Todas|Alcalá de Guadaira|Bormujos|Camas|Dos Hermanas|Sevilla|Tomares|Utrera"
sStateArray[44]="Todas|Almazan|El Burgo de Osma|Soria"
sStateArray[45]="Todas|El Vendrell|Montblanc|Roquetas|Tarragona"
sStateArray[46]="Todas|Teruel"
sStateArray[47]="Todas|Toledo|Torrijos"
sStateArray[48]="Todas|Aldaia|Alfafar|Alzira|Carcaixent|Cullera|Gandía|Gandía Playa|La Eliana|Paterna|Sedaví|Valencia|Xirivella"
sStateArray[49]="Todas|Valladolid|Zaratán"
sStateArray[50]="Todas|Barakaldo|Basauri|Bilbao|Leioa"
sStateArray[51]="Todas|Zamora"
sStateArray[52]="Todas|Calatayud|Mequinenza|Zaragoza"


var sStateArray1 = new Array()
sStateArray1[0]="After Hours|Café|Cervecería|Cibercafé|Disco/Música en vivo|Pub|Tapas|Otros"
sStateArray1[1]="Cine"
sStateArray1[2]="Centro Cultural|Enseñanza|Universidad"
sStateArray1[3]="Gimnasio"
sStateArray1[4]="C. Asiática|C. Castellana|C. Catalana|C. Española|C. Italiana|C. Mejicana|C. Vasca|C. Variada|C. Vegetariana|Otros"
sStateArray1[5]="Teatro"
sStateArray1[6]="Centro Comercial|Complementos|Estética|Moda|Música|Peluquería|Otros"
sStateArray1[7]="Hotel|Oficina Turismo"

var sStateArray2 = new Array()
sStateArray2[0]="todos los locales|Bar|Cine|Cultura|Gimnasio|Restaurante|Rest-Bar|Teatro|Tiendas|Turismo"

var sStateArray3 = new Array()
sStateArray3[0]="Alicante|A Coruña|Barcelona|Bilbao|Burgos|Castellón|Costa del Sol|Cuenca|C. Gibraltar"

