function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}

function removeAllOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
selectbox.remove(i);
}
}

function SelectProv(){
marcados=0;
removeAllOptions(document.f.concello);
addOption(document.f.concello, "(ningún)", "00-00");

if(document.f.provincia.selectedIndex>0) marcados=1;

if (marcados>1) return;
// Ubicación marcelapriore@uol.com.ar
// Concellos de A Coruña //
if(document.f.provincia.selectedIndex==1){
addOption(document.f.concello,"Abegondo", "13-16"); 
addOption(document.f.concello,"Ames", "20-12"); 
addOption(document.f.concello,"Aranga", "12-23"); 
addOption(document.f.concello,"Ares", "08-18"); 
addOption(document.f.concello,"Arteixo", "11-16"); 
addOption(document.f.concello,"Arzúa", "18-18"); 
addOption(document.f.concello,"A Baña", "17-09"); 
addOption(document.f.concello,"Betanzos", "11-19"); 
addOption(document.f.concello,"Boimorto", "17-19"); 
addOption(document.f.concello,"Boiro", "24-09"); 
addOption(document.f.concello,"Boqueixón", "20-16"); 
addOption(document.f.concello,"Brión", "20-11"); 
addOption(document.f.concello,"Cabana de Bergantiños", "13-07"); 
addOption(document.f.concello,"Cabanas", "08-20"); 
addOption(document.f.concello,"Camariñas", "13-04"); 
addOption(document.f.concello,"Cambre", "11-17"); 
addOption(document.f.concello,"A Capela", "08-22"); 
addOption(document.f.concello,"Carballo", "12-13"); 
addOption(document.f.concello,"Cariño", "03-25"); 
addOption(document.f.concello,"Carnota", "22-05"); // Corrixido marisalvar
addOption(document.f.concello,"Carral", "12-17"); 
addOption(document.f.concello,"Cedeira", "03-22"); 
addOption(document.f.concello,"Cee", "19-5"); // Corrixido anamp
addOption(document.f.concello,"Cerceda", "13-14");
addOption(document.f.concello,"Cerdido", "05-22"); 
addOption(document.f.concello,"Cesuras", "14-18"); 
addOption(document.f.concello,"Coirós", "12-22");
addOption(document.f.concello,"Corcubión", "19-04"); // Corrixido casdeiro
addOption(document.f.concello,"Coristanco", "13-11"); 
addOption(document.f.concello,"A Coruña", "10-16");
addOption(document.f.concello,"Culleredo", "11-16"); 
addOption(document.f.concello,"Curtis", "14-21"); 
addOption(document.f.concello,"Dodro", "22-11"); 
addOption(document.f.concello,"Dumbría", "17-04");
addOption(document.f.concello,"Fene", "08-20"); 
addOption(document.f.concello,"Ferreira de Valadouro", "06-31");
addOption(document.f.concello,"Ferrol", "07-19"); 
addOption(document.f.concello,"Fisterra", "19-03"); 
addOption(document.f.concello,"Frades", "16-17"); 
addOption(document.f.concello,"Irixoa", "11-22"); 
addOption(document.f.concello,"A Laracha", "11-14"); 
addOption(document.f.concello,"Laxe", "13-06");
addOption(document.f.concello,"Lourenza", "08-33");
addOption(document.f.concello,"Lousame", "21-10"); 
addOption(document.f.concello,"Malpica de Bergantiños", "11-09"); 
addOption(document.f.concello,"Mañón", "04-26"); 
addOption(document.f.concello,"Mazaricos", "21-06"); // Corrixido marisalvar
addOption(document.f.concello,"Melide", "18-20"); 
addOption(document.f.concello,"Mesía", "15-18"); 
addOption(document.f.concello,"Miño", "10-20"); 
addOption(document.f.concello,"Moeche", "06-22");
addOption(document.f.concello,"Mondoñedo", "09-32");
addOption(document.f.concello,"Monfero", "11-22"); 
addOption(document.f.concello,"Mugardos", "08-19");
addOption(document.f.concello,"Muros", "22-06"); // Corrixido marisalvar
addOption(document.f.concello,"Muxía", "15-04"); 
addOption(document.f.concello,"Narón", "06-21"); 
addOption(document.f.concello,"Neda", "07-21"); 
addOption(document.f.concello,"Negreira", "18-10"); 
addOption(document.f.concello,"Noia", "21-09"); 
addOption(document.f.concello,"Oleiros", "10-18"); 
addOption(document.f.concello,"Ordes", "15-15");
addOption(document.f.concello,"Oroso", "17-15"); 
addOption(document.f.concello,"Ortigueira", "03-25"); 
addOption(document.f.concello,"Outes", "22-07"); // Corrixido marisalvar
addOption(document.f.concello,"Oza Dos Ríos", "13-21"); 
addOption(document.f.concello,"Paderne", "11-21"); 
addOption(document.f.concello,"Padrón", "22-12"); 
addOption(document.f.concello,"O Pino", "19-16"); 
addOption(document.f.concello,"A Pobra do Caramiñal", "25-08"); 
addOption(document.f.concello,"Ponteceso", "12-10");
addOption(document.f.concello,"Pontedeume", "09-20"); 
addOption(document.f.concello,"As Pontes de García Rodríguez", "08-25");
addOption(document.f.concello,"Porto do Son", "22-07"); 
addOption(document.f.concello,"Rianxo", "24-09"); 
addOption(document.f.concello,"Ribeira", "26-07"); 
addOption(document.f.concello,"Rois", "22-11"); 
addOption(document.f.concello,"Sada", "10-19"); 
addOption(document.f.concello,"San Sadurniño", "06-21"); 
addOption(document.f.concello,"Santa Comba", "16-09"); 
addOption(document.f.concello,"Santiago de Compostela", "19-14"); 
addOption(document.f.concello,"Santiso", "19-19"); 
addOption(document.f.concello,"Sobrado", "16-22"); 
addOption(document.f.concello,"As Somozas", "06-23"); 
addOption(document.f.concello,"Teo", "21-14"); 
addOption(document.f.concello,"Toques", "17-23"); 
addOption(document.f.concello,"Tordoia", "15-13"); 
addOption(document.f.concello,"Touro", "19-17"); 
addOption(document.f.concello,"Trabada", "08-35");
addOption(document.f.concello,"Trazo", "16-14"); 
addOption(document.f.concello,"Val do Dubra", "16-12"); 
addOption(document.f.concello,"Valdoviño", "05-21");
addOption(document.f.concello,"Vedra", "21-15");  
addOption(document.f.concello,"Vilarmaior", "10-21"); 
addOption(document.f.concello,"Vilasantar", "15-20"); 
addOption(document.f.concello,"Vimianzo", "15-06"); 
addOption(document.f.concello,"Zas", "15-08"); 
} else if (document.f.provincia.selectedIndex==2){
// Concellos de Lugo //
addOption(document.f.concello,"Abadín", "09-29"); 
addOption(document.f.concello,"Alfoz", "06-32"); 
addOption(document.f.concello,"Antas De Ulla", "21-23"); 
addOption(document.f.concello,"Baleira", "17-35");
addOption(document.f.concello,"Baralla", "00-00"); 
addOption(document.f.concello,"Barreiros", "06-35"); 
addOption(document.f.concello,"Becerreá", "21-35"); 
addOption(document.f.concello,"Begonte", "14-28"); 
addOption(document.f.concello,"Bóveda", "24-29"); 
addOption(document.f.concello,"Burela", "05-33"); 
addOption(document.f.concello,"Carballedo", "25-25"); 
addOption(document.f.concello,"Castro de Rei", "13-31"); 
addOption(document.f.concello,"Castroverde", "16-33"); 
addOption(document.f.concello,"Cervantes", "20-37"); 
addOption(document.f.concello,"O Corgo", "18-30"); 
addOption(document.f.concello,"Cospeito", "12-29"); 
addOption(document.f.concello,"Chantada", "24-25");
addOption(document.f.concello,"Folgoso do Courel", "24-35"); 
addOption(document.f.concello,"A Fonsagrada", "15-36"); 
addOption(document.f.concello,"Foz", "06-34"); 
addOption(document.f.concello,"Friol", "16-26"); 
addOption(document.f.concello,"Guitiriz", "14-24"); 
addOption(document.f.concello,"Guntín", "19-26"); 
addOption(document.f.concello,"O Incio", "23-32"); 
addOption(document.f.concello,"Láncara", "19-30"); 
addOption(document.f.concello,"Lourenzá", "08-33"); 
addOption(document.f.concello,"Lugo", "17-29"); 
addOption(document.f.concello,"Meira", "13-33"); 
addOption(document.f.concello,"Mondoñedo", "09-32"); 
addOption(document.f.concello,"Monforte de Lemos", "25-29"); 
addOption(document.f.concello,"Monterroso", "21-24"); 
addOption(document.f.concello,"Muras", "21-06"); 
addOption(document.f.concello,"Navia de Suarna", "18-38"); 
addOption(document.f.concello,"Negueira de Muñiz", "14-40"); 
addOption(document.f.concello,"As Nogais", "21-37"); 
addOption(document.f.concello,"Ourol", "06-28"); 
addOption(document.f.concello,"Outeiro de Rei", "15-29");
addOption(document.f.concello,"Palas de Rei", "19-23"); 
addOption(document.f.concello,"Pantón", "26-28"); 
addOption(document.f.concello,"Paradela", "22-28"); 
addOption(document.f.concello,"O Páramo", "20-29"); 
addOption(document.f.concello,"A Pastoriza", "11-31"); 
addOption(document.f.concello,"Pedrafita do Cebreiro", "23-38"); 
addOption(document.f.concello,"A Pobra do Brollón", "25-32"); 
addOption(document.f.concello,"Pol", "14-32"); 
addOption(document.f.concello,"A Pontenova", "10-34"); 
addOption(document.f.concello,"Portomarín", "21-27"); 
addOption(document.f.concello,"Quiroga", "27-33"); 
addOption(document.f.concello,"Rábade", "15-29"); 
addOption(document.f.concello,"Ribadeo", "07-37"); 
addOption(document.f.concello,"Ribas de Sil", "27-33"); 
addOption(document.f.concello,"Ribeira de Piquín", "13-34"); 
addOption(document.f.concello,"Riotorto", "11-33");
addOption(document.f.concello,"Samos", "22-33"); 
addOption(document.f.concello,"Sarria", "21-31"); 
addOption(document.f.concello,"O Saviñao", "25-27");
addOption(document.f.concello,"Sober", "28-29"); 
addOption(document.f.concello,"Taboada", "23-25");
addOption(document.f.concello,"Trabada", "08-35"); 
addOption(document.f.concello,"Triacastela", "22-35"); 
addOption(document.f.concello,"O Valadouro", "06-31"); 
addOption(document.f.concello,"O Vicedo", "02-28"); 
addOption(document.f.concello,"Vilalba", "11-27"); 
addOption(document.f.concello,"Viveiro", "04-29"); 
addOption(document.f.concello,"Xermade", "10-25"); 
addOption(document.f.concello,"Xove", "03-30"); 
} else if (document.f.provincia.selectedIndex==3){
// Concellos de Ourense //
addOption(document.f.concello,"Allariz", "33-26"); 
addOption(document.f.concello,"Amoeiro", "29-24"); 
addOption(document.f.concello,"Arnoia", "32-19"); 
addOption(document.f.concello,"Avión", "29-19"); 
addOption(document.f.concello,"Baltar", "39-27"); 
addOption(document.f.concello,"Bande", "37-22"); 
addOption(document.f.concello,"Baños de Molgas", "32-29"); 
addOption(document.f.concello,"Barbadás", "32-25"); 
addOption(document.f.concello,"O Barco de Valdeorras", "29-38"); 
addOption(document.f.concello,"Beade", "31-21"); 
addOption(document.f.concello,"Beariz", "27-19"); 
addOption(document.f.concello,"Os Blancos", "38-26"); 
addOption(document.f.concello,"Boborás", "28-21"); 
addOption(document.f.concello,"A Bola", "34-25"); 
addOption(document.f.concello,"O Bolo", "30-37"); 
addOption(document.f.concello,"Calvos de Randín", "39-23"); 
addOption(document.f.concello,"Carballeda de Avia", "32-20"); 
addOption(document.f.concello,"Carballeda de Valdeorras", "30-39");
addOption(document.f.concello,"O Carballiño", "28-22"); 
addOption(document.f.concello,"Cartelle", "33-23"); 
addOption(document.f.concello,"Castrelo de Miño", "31-22"); 
addOption(document.f.concello,"Castrelo do Val", "38-32"); 
addOption(document.f.concello,"Castro Caldelas", "29-33"); 
addOption(document.f.concello,"Celanova", "34-23"); 
addOption(document.f.concello,"Cenlle", "31-22"); 
addOption(document.f.concello,"Coles", "28-26"); 
addOption(document.f.concello,"Cortegada", "33-19"); 
addOption(document.f.concello,"Cualedro", "38-28"); 
addOption(document.f.concello,"Chandrexa de Queixa", "31-33"); 
addOption(document.f.concello,"Entrimo", "39-20"); 
addOption(document.f.concello,"Esgos", "31-29"); 
addOption(document.f.concello,"Gomesende", "34-21"); 
addOption(document.f.concello,"A Gudiña", "37-35");
addOption(document.f.concello,"O Irixo", "26-21"); 
addOption(document.f.concello,"Larouco", "30-35"); 
addOption(document.f.concello,"Laza", "36-30"); 
addOption(document.f.concello,"Leiro", "30-21"); 
addOption(document.f.concello,"Lobeira", "38-21"); 
addOption(document.f.concello,"Lobios", "40-21"); 
addOption(document.f.concello,"Maceda", "32-30"); 
addOption(document.f.concello,"Manzaneda", "31-36");
addOption(document.f.concello,"Maside", "29-22");
addOption(document.f.concello,"Melón", "32-19"); 
addOption(document.f.concello,"A Merca", "33-24"); 
addOption(document.f.concello,"A Mezquita", "38-37");
addOption(document.f.concello,"Montederramo", "32-33"); 
addOption(document.f.concello,"Monterrei", "39-30"); 
addOption(document.f.concello,"Muiños", "38-22");
addOption(document.f.concello,"Nogueira de Ramuín", "28-28"); 
addOption(document.f.concello,"Oimbra", "40-30"); 
addOption(document.f.concello,"Ourense", "31-26"); 
addOption(document.f.concello,"Paderne de Allariz", "00-00"); 
addOption(document.f.concello,"Padrenda", "35-20"); 
addOption(document.f.concello,"Parada de Sil", "29-31"); 
addOption(document.f.concello,"Pereiro de Aguiar", "30-27"); 
addOption(document.f.concello,"A Peroxa", "28-27"); 
addOption(document.f.concello,"Petín", "29-36"); 
addOption(document.f.concello,"Piñor", "26-23"); 
addOption(document.f.concello,"A Pobra de Trives", "30-35"); 
addOption(document.f.concello,"Pontedeva", "28-12");
addOption(document.f.concello,"Porqueira", "38-24"); 
addOption(document.f.concello,"Punxín", "30-23");
addOption(document.f.concello,"Quintela de Leirado", "34-20"); 
addOption(document.f.concello,"Rairiz de Veiga", "36-24"); 
addOption(document.f.concello,"Ramirás", "34-23"); 
addOption(document.f.concello,"Ribadavia", "32-21"); 
addOption(document.f.concello,"Riós", "38-33"); 
addOption(document.f.concello,"A Rúa", "29-36"); 
addOption(document.f.concello,"Rubiá", "28-39"); 
addOption(document.f.concello,"San Amaro", "30-22"); 
addOption(document.f.concello,"San Cibrao das Viñas", "31-26"); 
addOption(document.f.concello,"San Cristovo de Cea", "27-23"); 
addOption(document.f.concello,"San Xoan de Río", "29-34"); 
addOption(document.f.concello,"Sandiás", "35-26"); 
addOption(document.f.concello,"Sarreaus", "35-29"); 
addOption(document.f.concello,"Taboadela", "32-25"); 
addOption(document.f.concello,"A Teixeira", "29-32"); 
addOption(document.f.concello,"Toén", "31-23"); 
addOption(document.f.concello,"Trasmiras", "37-27"); 
addOption(document.f.concello,"A Veiga", "32-38"); 
addOption(document.f.concello,"Verea", "31-23"); 
addOption(document.f.concello,"Verín", "39-31"); 
addOption(document.f.concello,"Viana do Bolo", "34-35"); 
addOption(document.f.concello,"Vilamarín", "27-25"); 
addOption(document.f.concello,"Vilamartín de Valdeorras", "28-36"); 
addOption(document.f.concello,"Vilar de Barrio", "34-29"); 
addOption(document.f.concello,"Vilar de Santos", "36-25"); 
addOption(document.f.concello,"Vilardevós", "40-32"); 
addOption(document.f.concello,"Vilariño de Conso", "34-34"); 
addOption(document.f.concello,"Xinzo de Limia", "36-26"); 
addOption(document.f.concello,"Xunqueira de Ambía", "33-28");
addOption(document.f.concello,"Xunqueira de Espadanedo", "31-30");
} else if (document.f.provincia.selectedIndex==4){
// Concellos de Pontevedra //
addOption(document.f.concello,"Agolada", "22-21"); 
addOption(document.f.concello,"Arbo", "35-17"); 
addOption(document.f.concello,"Baiona", "35-09"); 
addOption(document.f.concello,"Barro", "26-13"); 
addOption(document.f.concello,"Bueu", "32-10"); // Corrixido Anamp
addOption(document.f.concello,"Caldas De Reis", "25-12"); 
addOption(document.f.concello,"Cambados", "27-10"); 
addOption(document.f.concello,"Campo Lameiro", "26-15"); 
addOption(document.f.concello,"Cangas", "33-10"); // Corrixido Anamp
addOption(document.f.concello,"A Cañiza", "33-18"); 
addOption(document.f.concello,"Catoira", "24-10"); 
addOption(document.f.concello,"Cerdedo", "26-18"); 
addOption(document.f.concello,"Cotobade", "27-16");
addOption(document.f.concello,"O Covelo", "32-16"); 
addOption(document.f.concello,"Crecente", "34-18"); 
addOption(document.f.concello,"Cuntis", "24-15"); 
addOption(document.f.concello,"Dozón", "25-21"); 
addOption(document.f.concello,"A Estrada", "23-15"); 
addOption(document.f.concello,"Forcarei", "25-18"); 
addOption(document.f.concello,"Fornelos de Montes", "30-16"); 
addOption(document.f.concello,"Gondomar", "35-11"); 
addOption(document.f.concello,"O Grove", "27-09"); 
addOption(document.f.concello,"A Guarda", "39-09"); 
addOption(document.f.concello,"A Illa de Arousa", "26-09"); 
addOption(document.f.concello,"Lalín", "23-20"); 
addOption(document.f.concello,"A Lama", "29-15"); 
addOption(document.f.concello,"Marín", "31-11"); // Corrixido Anamp
addOption(document.f.concello,"Meaño", "28-10"); 
addOption(document.f.concello,"Meis", "27-12"); 
addOption(document.f.concello,"Moaña", "32-11"); // Corrixido Anamp
addOption(document.f.concello,"Mondariz", "33-15");
addOption(document.f.concello,"Mondariz-Balneario", "33-13"); 
addOption(document.f.concello,"Moraña", "25-14"); 
addOption(document.f.concello,"Mos", "33-12"); 
addOption(document.f.concello,"As Neves", "35-15"); 
addOption(document.f.concello,"Nigrán", "34-09"); 
addOption(document.f.concello,"Oia", "37-08"); 
addOption(document.f.concello,"Poio", "30-10"); // Corrixido Anamp
addOption(document.f.concello,"Ponteareas", "33-14");
addOption(document.f.concello,"Ponte-Caldelas", "29-14");
addOption(document.f.concello,"Pontecesures", "23-12"); 
addOption(document.f.concello,"Pontevedra", "30-11"); // Corrixido Anamp
addOption(document.f.concello,"O Porriño", "34-12"); 
addOption(document.f.concello,"Portas", "29-12"); 
addOption(document.f.concello,"Redondela", "31-13"); 
addOption(document.f.concello,"Ribadumia", "27-11"); 
addOption(document.f.concello,"Rodeiro", "23-22"); 
addOption(document.f.concello,"O Rosal", "38-09"); 
addOption(document.f.concello,"Salceda De Caselas", "35-13"); 
addOption(document.f.concello,"Salvaterra De Miño", "35-14"); 
addOption(document.f.concello,"Sanxenxo", "30-09"); // Corrixido Anamp
addOption(document.f.concello,"Silleda", "22-18");
addOption(document.f.concello,"Soutomaior", "30-13"); 
addOption(document.f.concello,"Tomiño", "37-10"); 
addOption(document.f.concello,"Tui", "36-11"); 
addOption(document.f.concello,"Valga", "23-13"); 
addOption(document.f.concello,"Vigo", "34-11"); // Corrixida Manu (antes 33-11)
addOption(document.f.concello,"Vila De Cruces", "21-19"); 
addOption(document.f.concello,"Vilaboa", "30-12"); 
addOption(document.f.concello,"Vilagarcía De Arousa", "25-11"); 
addOption(document.f.concello,"Vilanova De Arousa", "26-09"); 
}

}

function ubicarConcello() {
xubi=0;
yubi=0;
//alert(document.f.concello.value);

if(ns4)obj=document.ubicacionConcello;
if(ie4)obj=self.ubicacionConcello.style;
if(ns6)obj=document.getElementById("ubicacionConcello");

if(ns4){
	tx=document.tabelaMapa.pixelLeft;
	ty=document.tabelaMapa.pixelTop;
	}
if(ie4){
	tx=self.tabelaMapa.style.pixelLeft;
	ty=self.tabelaMapa.style.pixelTop;
	}
if(ns6){
	tx=document.getElementById("tabelaMapa").style.pixelLeft;
	ty=document.getElementById("tabelaMapa").style.pixelTop;
	}
	
//alert("Tabela: "+tx+","+ty);

if (document.f.concello.value.length>5 || document.f.concello.value=="00-00") {
	xubi=1;
	yubi=1;
	alert("Non podo ubicar ese concello. :-(");
} else { // Ollo, as coordenadas está ao revés nas ubicacións das celdas YY-XX
	xubi=document.f.concello.value.substring(3,5)*10-1-10;
	yubi=document.f.concello.value.substring(0,2)*10-42*10-10-1;
	repositionTo(obj,xubi,yubi);
	showObject(obj);
	document.f.Ubicar.value=document.f.concello.value;
}

}

function amosarMapaConcellos() {
xubi=0;
yubi=0;

if(ns4)obj=document.mapaConcellos;
if(ie4)obj=self.mapaConcellos.style;
if(ns6)obj=document.getElementById("mapaConcellos");

tx=268; // Por omisión por se a ubicación da tabela non rula
ty=10; // ídem

/* parece que non chuta!!!
if(ns4){
	tx=document.tabelaMapa.pixelLeft;
	ty=document.tabelaMapa.pixelTop;
	}
if(ie4){
	tx=self.tabelaMapa.style.pixelLeft;
	ty=self.tabelaMapa.style.pixelTop;
	}
if(ns6){
	tx=document.getElementById("tabelaMapa").style.pixelLeft;
	ty=document.getElementById("tabelaMapa").style.pixelTop;
	}
	*/
	
//alert("Tabela: "+tx+","+ty);

	xubi=tx;
	yubi=ty;
	repositionTo(obj,xubi,yubi);
	showObject(obj);

}

function agacharMapaConcellos() {

if(ns4)obj=document.mapaConcellos;
if(ie4)obj=self.mapaConcellos.style;
if(ns6)obj=document.getElementById("mapaConcellos");


	hideObject(obj);

}

function flipMapaConcellos() {

if(ns4)obj=document.mapaConcellos;
if(ie4)obj=self.mapaConcellos.style;
if(ns6)obj=document.getElementById("mapaConcellos");

if (obj.style.visibility=='visible') {
	agacharMapaConcellos();
	} else {
	amosarMapaConcellos();
	}

}
