// **********************************************************************************
function loadMuni(combo,muni)
{
	var selec=0;
	var comboMuni = combo.form.ciudad;
	//alert("comboMuni.length=" + comboMuni.length + "\rmuni=" + muni);
	for(var i=comboMuni.length;i>0;i--)
	{
		comboMuni.options[i] = null;
	}
	if(combo[combo.selectedIndex].value!=""&&combo[combo.selectedIndex].value!=0)
	{
		var arrayMuni = aM[combo[combo.selectedIndex].value].split("||");
		for(i=0;i<arrayMuni.length;i++)
		{
			comboMuni.options[comboMuni.length] = new Option(arrayMuni[i].split("|")[0], arrayMuni[i].split("|")[1]);
		}
		selec=1;
		if(loadMuni.arguments.length==2)
		{
			selec+=muni;
		}
	}
	comboMuni.options[selec].selected = true;
}
// **********************************************************************************
function imInfo(sId,sCapa,sMapa){}
// **********************************************************************************
function End()
{
	movie.TSetProperty("/CuadroEscala",7,0);
}
// **********************************************************************************
function cargarPais(fPais)
//realiza : refresca la pantalla cuando cambiamos de pais
{
	document.oculto.pais.value = document.callejero.pais.value;
	document.oculto.paisanterior.value = fPais;
	document.oculto.provincia.value = document.callejero.provincia.value;
	document.oculto.provinciaanterior.value = document.callejero.provincia.value;
	document.oculto.ciudad.value = document.callejero.ciudad.value;
	document.oculto.direccion.value = document.callejero.direccion.value;
	document.oculto.portal.value = document.callejero.portal.value;
	document.oculto.barrio.value = document.callejero.barrio.value;
	//document.oculto.cpostal.value = document.callejero.cpostal.value;
	if (document.callejero.cont.value != 0)
	{
		document.oculto.TipoVia.value = document.callejero.TipoVia.value;
	}
	document.oculto.opcion.value = 0;
	document.oculto.submit();
	return (true);
}
// **********************************************************************************
function cargarProvincia(fProvincia)
//realiza : refresca la pantalla cuando cambiamos de provincia
{
	document.oculto.pais.value = document.callejero.pais.value;
	document.oculto.paisanterior.value = document.callejero.paisanterior.value;
	document.oculto.provincia.value = document.callejero.provincia.value;
	document.oculto.provinciaanterior.value = fProvincia;
	document.oculto.ciudad.value = document.callejero.ciudad.value;
	document.oculto.direccion.value = document.callejero.direccion.value;
	document.oculto.portal.value = document.callejero.portal.value;
	document.oculto.barrio.value = document.callejero.barrio.value;
	//document.oculto.cpostal.value = document.callejero.cpostal.value;
	if (document.callejero.cont.value != 0)
	{
		document.oculto.TipoVia.value = document.callejero.TipoVia.value;
	}
	document.oculto.opcion.value = 0;
	document.oculto.submit();
	return (true);
}
// **********************************************************************************
function Refrescar()
{
	 if (document.callejero.provincia.value == 0)
		{
			document.callejero.provincia.focus();
		}
	else if (document.callejero.ciudad.value == 0)
		{
			document.callejero.ciudad.focus();
		}
	else
		{
			document.callejero.direccion.focus();
		}
	return (true);
}
// **********************************************************************************
function RefrescarLista(i)
{
	document.oculto.contador.value = i;
	document.oculto.submit();
}
// **********************************************************************************
function CargarCalles( sID, sDireccion)
{
	document.oculto.id.value = sID;
	document.oculto.direccion.value = sDireccion;
	document.oculto.submit();
}
// **********************************************************************************
function CargarBarrios( sID, x, y)
{
	document.oculto.id.value = sID;
	document.oculto.barrio.value = sID;
	document.oculto.x.value = x;
	document.oculto.y.value = y;
	document.oculto.submit();
}
// **********************************************************************************
function irCiudad(fIdioma)
//realiza : cuando queremos buscar simplemente una ciudad
{
	if (document.callejero.ciudad.value == 0) 
	{
		if (fIdioma == "ES") 
		{
			alert("Seleccione una ciudad");
		} 
		else 
		{
			alert("Select a city");
		}
		document.callejero.opcion.value = 0;
		document.callejero.ciudad.focus();
	} 
	else 
	{
		document.callejero.paisanterior.value = document.callejero.pais.value;
		document.callejero.opcion.value = 1;
		document.callejero.submit();
		return (true);	
	}
}
// **********************************************************************************
function irCalle(fIdioma)
{
	bCorrecto = true;
	//ciudad
	if (document.callejero.ciudad.value == 0) {
		if (fIdioma == "ES") {
			alert("Seleccione una ciudad");
		} else {
			alert("Select a city");
		}
		document.callejero.ciudad.focus();
		bCorrecto = false;
	}
	//dirección
	if (bCorrecto == true) {
		if (document.callejero.direccion.value != 0) {
	
			if (document.callejero.direccion.value.length < 3) {
				if (fIdioma == "ES") {
					alert("Introduzca una calle de al menos tres letras");
				} else {
					alert("Write an address of more than three characters");
				}
			
				document.callejero.direccion.focus();
				bCorrecto = false;
			}
			if (document.callejero.portal.value != 0) {
				if (isNaN(document.callejero.portal.value)) {
					if (fIdioma == "ES") {
						alert("Introduzca un valor numérico");
					} else {
						alert("Write a numeric value");
					}
				
					document.callejero.portal.focus();
					bCorrecto = false;
				}
			}
		} else {
			if (fIdioma == "ES") {
				alert("Introduzca una calle.");
			} else {
				alert("Write an address.");
			}
			
			document.callejero.direccion.focus();
			bCorrecto = false;
		}
	}
	if (bCorrecto == true)
	{
		document.callejero.opcion.value = 2;
		document.callejero.submit();
		return (true);	
	} else {
		document.callejero.opcion.value = 0;
	}
}
// **********************************************************************************
function irBarrio(fIdioma)
{
	bCorrecto = true;
	//ciudad
	if (document.callejero.ciudad.value == 0) {
		if (fIdioma == "ES") {
			alert("Seleccione una ciudad");
		} else {
			alert("Select a city");
		}
		
		document.callejero.ciudad.focus();
		bCorrecto = false;
	}
	//tenemos una ciudad, tenemos que comprobar el barrio
	if (bCorrecto == true) {
		if (document.callejero.barrio.value == 0) {

			if (fIdioma = "ES") {
				alert("Introduzca un barrio.");
			} else {
				alert("Write a zone.");
			}

			document.callejero.barrio.focus();
			bCorrecto = false;
		
		} else {
			if (document.callejero.barrio.value.length < 3) {
				if (fIdioma = "ES") {
					alert("Introduzca un barrio de al menos tres letras");
				} else {
					alert("Write a zone of more than three characters");
				}
			
				document.callejero.barrio.focus();
				bCorrecto = false;
			}
		}
	}
	if (bCorrecto == true) {
		document.callejero.opcion.value = 3;		
		document.callejero.submit();
		return (true);	
	} else {
		document.callejero.opcion.value = 0;
	}
}
// **********************************************************************************
function irCPostal(fIdioma)
{
	bCorrecto = true;
	//ciudad
	if (document.callejero.ciudad.value == 0) {
		if (fIdioma == "ES") {
			alert("Seleccione una ciudad");
		} else {
			alert("Select a city");
		}
		
		document.callejero.ciudad.focus();
		bCorrecto = false;
	}
	//código postal
	if (bCorrecto == true) {
	
		if (document.callejero.cpostal.value == 0) {
			
			if (fIdioma = "ES") {
				alert("Introduzca un código postal");
			} else {
				alert("Write a postal code");
			}

			document.callejero.cpostal.focus();
			bCorrecto = false;
		
		} else {
		
			if (document.callejero.cpostal.value.length < 4) {

				if (fIdioma = "ES") {
					alert("Introduzca un código postal");
				} else {
					alert("Write a postal code");
				}

				document.callejero.cpostal.focus();
				bCorrecto = false;
			} 

			if (isNaN(document.callejero.cpostal.value)) {
				if (fIdioma = "ES") {
					alert("Introduzca un código postal");
				} else {
					alert("Write a postal code");
				}
			
				document.callejero.cpostal.focus();
				bCorrecto = false;
			}

		}
	}
	if (bCorrecto == true) {
		document.callejero.opcion.value = 4;
		document.callejero.submit();
		return (true);	
	} else {
		document.callejero.opcion.value = 0;
	}
}
// **********************************************************************************