function rutaEnCoche( prj ) {
	switch( prj.toUpperCase() ) {
		case "MADRID":
		case "BARNA":
			return true
		default:
			return false
	}
}

function rutaTransporte( prj ) {
	switch( prj.toUpperCase() ) {
		case "MADRID":
			return true
		default:
			return false
	}
}


function rutaAPie( prj) {
	switch( prj.toUpperCase() ) {
		case "ALAQUAS":
		case "ALBACETE":
		case "ALBAL":
		case "ALBORAYA":
		case "ALCALA":
		case "ALCOBEND":
		case "ALCORCON":
		case "ALCOY":
		case "ALDAIA":
		case "ALFAFAR":
		case "ALGECIRA":
		case "ALICANTE":
		case "ALMASSER":
		case "ALMERIA":
		case "ARANJUEZ":
		case "ARGANDA":
		case "AVILA":
		case "AVILES":
		case "BADAJOZ":
		case "BADALONA":
		case "BALEARES":
		case "BARAKALD":
		case "BARBERA":
		case "BARNA":
		case "BENETUST":
		case "BENIDORM":
		case "BENIMAME":
		case "BERANGO":
		case "BILBAO":
		case "BOADILLA":
		case "BONREPOS":
		case "BURGOS":
		case "BURJASSO":
		case "CACERES":
		case "CADIZ":
		case "CANARIAS":
		case "CARTAGEN":
		case "CASTELLO":
		case "CATARROJ":
		case "CERDANYO":
		case "CEUTA":
		case "COLMENAR":
		case "CORDOBA":
		case "CORNELLA":
		case "CORUNYA":
		case "COSLADA":
		case "CREAL":
		case "CUENCA":
		case "DENIA":
		case "DONOSTIA":
		case "DOSHERMA":
		case "ELCHE":
		case "ELDA":
		case "ELEJIDO":
		case "ELPRAT":
		case "ERANDIO":
		case "ESPLUGUE":
		case "FERROL":
		case "FIGUERES":
		case "FUENLABR":
		case "GANDIA":
		case "GAVA":
		case "GETAFE":
		case "GETXO":
		case "GIJON":
		case "GIRONA":
		case "GODELLA":
		case "GRANADA":
		case "GRANOLLE":
		case "GUADALAJ":
		case "HUELVA":
		case "HUESCA":
		case "IBIZA":
		case "IRUN":
		case "JAEN":
		case "LAGUNA":
		case "LEGANES":
		case "LEIOA":
		case "LEON":
		case "LLEIDA":
		case "LOGRONYO":
		case "LUGO":
		case "MADRID":
		case "MAHON":
		case "MAJADAHO":
		case "MALAGA":
		case "MANISES":
		case "MANRESA":
		case "MARBELLA":
		case "MASNOU":
		case "MASSANA":
		case "MATARO":
		case "MELILLA":
		case "MERIDA":
		case "MISLATA":
		case "MOLLET":
		case "MONTGAT":
		case "MOSTOLES":
		case "MOTRIL":
		case "MURCIA":
		case "ORENSE":
		case "OVIEDO":
		case "PAIPORTA":
		case "PALENCIA":
		case "PAMPLONA":
		case "PARLA":
		case "PATERNA":
		case "PICANYA":
		case "PINTO":
		case "PLASENCI":
		case "PONTEVED":
		case "POZUELO":
		case "PREMIA":
		case "PRTUGALE":
		case "PSTMARIA":
		case "QUART":
		case "REUS":
		case "RIVAS":
		case "RONDA":
		case "ROZAS":
		case "RUBI":
		case "SABADELL":
		case "SAGUNTO":
		case "SALAMANC":
		case "SANFER":
		case "SANFERNM":
		case "SANSEBAS":
		case "SANTADRI":
		case "SANTANDE":
		case "SANTBOI":
		case "SANTCUGA":
		case "SANTFELI":
		case "SANTIAGO":
		case "SANTJOAN":
		case "SANTURZI":
		case "SEDAVI":
		case "SEGOVIA":
		case "SESTAO":
		case "SEVILLA":
		case "SONDIKA":
		case "SORIA":
		case "STCOLOMA":
		case "TALAVERA":
		case "TARRAGON":
		case "TAVERNES":
		case "TENERIFE":
		case "TERRASSA":
		case "TERUEL":
		case "TOLEDO":
		case "TORREJON":
		case "TORRELAV":
		case "TORRENT":
		case "TORREVIE":
		case "TORTOSA":
		case "TRAPAGA":
		case "TRESCANT":
		case "VALENCIA":
		case "VALLADOL":
		case "VIGO":
		case "VILAGARC":
		case "VILLALBA":
		case "VILLAVIC":
		case "VITORIA":
		case "XIRIVELL":
		case "ZAMORA":
		case "ZARAGOZA":
			return true
			break
		default:
			return false
			break
	}
}	

//
// a partir de aquí funciones relacionadas con la home de planos urbanos
//



function setOptionText(modifSel, modifArray, modifArray_proy)
{
	var aux2 = modifSel.options.length;

	var total=100;
	var i=0;
	var option = new Array();
	while (aux2 && ++i<=total) modifSel.options[1] = null;
		for (loop=1; loop < modifArray.length+1; loop++)
	{
		var option = new Option(loop, loop);
		eval("modifSel.options[loop]=option");
	}
		//alert(aux2);
		if (aux2) modifSel.options[0].selected=true;
	for (loop=1; loop < modifSel.options.length; loop++)
	{
		modifSel.options[loop].text = modifArray[loop-1];
		modifSel.options[loop].value = modifArray_proy[loop-1];
		if (modifSel.options[loop].value == g_Localidad){
			modifSel.options[loop].selected=true;
		}
	}  
	if (modifArray.length > 0)
	{
		if (window.document.busqueda.select4)
			window.document.busqueda.select4.disabled=false;
		if (window.document.busqueda.select5)
			window.document.busqueda.select5.disabled=false;
		}
}


function swapOptions(array_name)
{	

if(array_name != 'separador' && array_name!=0){
	if (window.document.busqueda.select4)
	window.document.busqueda.select4.disabled=true;
	if (window.document.busqueda.select5)
	window.document.busqueda.select5.disabled=true;
	if (window.document.busqueda.select4)
	var numbers_select = window.document.busqueda.select4;
	var modifArray = eval(array_name);
	var modifArray_proy = eval(array_name + "_PROY");	
	if (window.document.busqueda.select4)
	setOptionText(window.document.busqueda.select4, modifArray, modifArray_proy);

}
else {
	if (array_name!=0){
	if (window.document.busqueda.select4)
	window.document.busqueda.select4.disabled;
	if (window.document.busqueda.select5)
	window.document.busqueda.select5.disabled;
	alert("Debes seleccionar una provincia.");
}
	}
}


//NUEVA FUNCIÓN PARA ENVIAR LOS DATOS DE LA BÚSQUEDA DE DIRECCIÓN

function envio_planos()
{	
	var gisArray
	var localidadGis
	var prov=document.busqueda.select3.options[document.busqueda.select3.selectedIndex].value;
	var local=document.busqueda.select4.options[document.busqueda.select4.selectedIndex].text;
	var tipovia=document.busqueda.select5.options[document.busqueda.select5.selectedIndex].value;
	if (window.document.busqueda.select3.options[document.busqueda.select3.selectedIndex].value!=0) {
	 gisArray = eval(window.document.busqueda.select3.options[document.busqueda.select3.selectedIndex].value + "_GIS");
	 localidadGis = gisArray[document.busqueda.select4.selectedIndex-1];
	}
	if (tipovia=="") tipovia="0";
	var nombrevia=document.busqueda.textfield32.value;
	var numerovia=document.busqueda.textfield22.value; 
	if (numerovia=='') numerovia=1;
	//alert(prov);
	//alert(local);
	//alert(tipovia);
	//alert(gisArray);
	//alert(localidadGis);
	//alert(nombrevia);
	//alert(numerovia);
	//BUSCO EL PROYECTO ASOCIADO A LA LOCALIDAD
	if(prov != 0)
	{
		var indice;
		var proy;
		var nomvec = eval(prov);
		for(i=0;i<nomvec.length;i++)
		{
			if(nomvec[i] == local)
			{
				indice = i;
				
				break;
			}
		}
		nomvec = eval(prov + '_PROY')
		proy = nomvec[indice];
	
	  
	}
	
// ******* Inicio proximidad *******
	//PROXIMIDAD
	var actividad = document.busqueda.actividad.options[document.busqueda.actividad.selectedIndex].value;
	var radio = document.getElementById('radio').value;
	var OtrActiv = document.getElementById('nombre').value;
	var idbusq = document.getElementById('idbusq').value;
	if (actividad != '') 
	{
		if (radio == "0")
		{
			alert("Debe elegir un valor para el radio si desea realizar una búsqueda por proximidad.")
			return;
		}
	}
	else
	{
		if (OtrActiv != '')
		{
			actividad = OtrActiv;
			if (radio == "0")
			{
				alert("Debe elegir un valor para el radio si desea realizar una búsqueda por proximidad.")
				return;
			}
		}
	}
// ******* Fin proximidad *******
	if (actividad!=''){
		actividad = actividad + "&id_busq=" + idbusq;
	}
	var url='/includes/mapa/mapdirprox.asp?proy=' + proy + '&nombrevia=' + nombrevia + '&tipovia=' + tipovia + '&numvia=' + numerovia + '&localidad=' + local + '&localidadgis=' + localidadGis;

	url = url + '&actividad=' + actividad + '&radio=' + radio;
	/*if (actividad != ''){
		url = url + '&pgpv=1';
	}*/
	
	var objexpreg=/\s/g;
	url=url.replace(objexpreg,'%20');
	if ((document.busqueda.select3.selectedIndex==0) || (document.busqueda.select4.selectedIndex==0) || (nombrevia==''))
		alert("Los campos Provincia, Ciudad y Nombre de la Via son Obligatorios.");		
	else{
		// Enviamos las cookies de localidad y provincia
		SetCookie ("planociudad", proy + "#" + prov );
		// Cambio la ventana de salida
		// document.location.href=url;
    
	top.location.href=url;
	}
	
	return;
}

function PintaTipoVia()
{
	document.write('<option value="0" selected>Elige  --&gt</option>')
	for (i=0; i < tiposvia.length; i++) 
	{
		document.write('<option value="' + tiposviagis[i]+ '">' + tiposvia[i]+'</option>')					
	}
}