function ocultaProvincia(id)
{
  var mapaArray=new Array('valencia_hover','alicante_hover','castellon_hover','murcia_hover','toledo_hover','cuenca_hover','albacete_hover','guadalajara_hover','ciudad_real_hover','badajoz_hover','caceres_hover','huelva_hover','sevilla_hover','cordoba_hover','jaen_hover','cadiz_hover','malaga_hover','granada_hover','almeria_hover','madrid_hover','teruel_hover','zaragoza_hover','salamanca_hover','avila_hover','segovia_hover','soria_hover','burgos_hover','palencia_hover','valladolid_hover','zamora_hover','leon_hover','ourense_hover','huesca_hover','pontevedra_hover','acorunia_hover','lugo_hover','asturias_hover','cantabria_hover','vizcaya_hover','guipuzcua_hover','alava_hover','larioja_hover','navarra_hover','huesca_hover','lleida_hover','girona_hover','barcelona_hover','tarragona_hover','ibiza_hover','formentera_hover','mallorca_hover','menorca_hover','lapalma_hover','elhierro_hover','lagomera_hover','tenerife_hover','grancanaria_hover','fuerteventura_hover','lanzarote_hover','santjulia_hover','lavella_hover','escaldes_hover','encamp_hover','lamassana_hover','ordino_hover','canillo_hover','lavella_hover','andorra_spain_hover','corcega_hover','norte_hover','picardia_hover','anormandia_hover','bnormandia_hover','iledefrance_hover','champaña_hover','lorena_hover','alsacia_hover','franco_hover','borgoña_hover','centro_hover','loira_hover','bretagna_hover','poitou_hover','lemosin_hover','auvernia_hover','rodano_hover','provenza_hover','languedoc_hover','mediodia_hover','aquitania_hover','andorra_france_hover',"borgoa_hover");
  for (i=0;i < mapaArray.length;i++){
    if (document.getElementById(mapaArray[i])!=null)document.getElementById(mapaArray[i]).style.display='none';
    }
	if (id!='0')
		{
			if (document.getElementById(id)!=null)document.getElementById(id).style.display='block';
		}
}

function muestraPaises(id)
{
	document.getElementById('andorra_map').style.display='none';
	document.getElementById('espana').style.display='none';
	document.getElementById('francia').style.display='none';
  document.getElementById('europa').style.display='block';

	if (id!='0')
		{
		document.getElementById(id).style.display='block';
    document.getElementById('europa').style.display='none';
		}
}

String.prototype.removeAccents = function ()
{
  	var __r = {
		  'À':'A','Á':'A','Â':'A','Ã':'A','Ä':'A','Å':'A','Æ':'E',
		  'È':'E','É':'E','Ê':'E','Ë':'E',
			'Ì':'I','Í':'I','Î':'I','Ï':'I',
			'Ò':'O','Ó':'O','Ô':'O','Ö':'O',
			'Ù':'U','Ú':'U','Û':'U','Ü':'U',
			'Ñ':'N','Ç':'C'};

	return this.replace(/[ÀÁÂÃÄÅÆÈÉÊËÌÍÎÏÒÓÔÖÙÚÛÜÑÇ]/gi, function(m){
		var ret = __r[m.toUpperCase()];

		if (m === m.toLowerCase())
			ret = ret.toLowerCase();

		return ret;
			});
};

function eliminaBarra(str)
{
  cadenaArray = new Array();
  cadenaArray = str.split("/");
  //alert(cadenaArray[0]+"<-->"+cadenaArray[1]);
  return cadenaArray[0]
  //var result = str.replace("/", "");
  //return result;
}

function eliminaAcento(str)
{
  var result = str.replace("'", "");
  //alert(str+ "--"+result);
  return result;
}

function convertSpaces(str)
{
  var nt = "";
  for(var q=0;q <str.length; q++)
    {
    (str.charAt(q)==' ')?nc='_':nc=str.charAt(q);
    nt+=nc;
    }
  return nt;
}

/*
Without the second parameter, Javascript function will trim these characters:

    * " " (ASCII 32 (0x20)), an ordinary space.
    * "\t" (ASCII 9 (0x09)), a tab.
    * "\n" (ASCII 10 (0x0A)), a new line (line feed).
    * "\r" (ASCII 13 (0x0D)), a carriage return.
    * "\0" (ASCII 0 (0x00)), the NUL-byte.
    * "\x0B" (ASCII 11 (0x0B)), a vertical tab.
*/

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function formatText(str)
{
  str=str.removeAccents();
  str=eliminaBarra(str);
  str=trim(str);
  str=convertSpaces(str);
  str=eliminaAcento(str);
  return str;
}

function enviaFormMapa(nombreMostrar)
{
    var urlAction="";
    var P="";W="";C="";D="";Z="";A="";N="";R="";E="";
    var textoUrlDeVacaciones="";
    var textoUrlEn="";
    var textoUrlDeVacaciones="-"+textoDeVacaciones;
    if (document.getElementById('FRMProvincia'))var E=document.getElementById('FRMProvincia').value;
    if (document.getElementById('Idioma')) var I=document.getElementById('Idioma').value;
    if (document.getElementById('tiposPlural')) var tiposPlural=document.getElementById('tiposPlural').value;
    if (document.getElementById('FRMClase')) var C=document.getElementById('FRMClase').value;
	  if (document.getElementById('FRMRegion')) var R=document.getElementById('FRMRegion').value;

  if (C)
    {
    var obClase=document.getElementById('FRMClase');
    var clase=obClase.options[obClase.selectedIndex].innerHTML;
    clase=formatText(clase);
    var textoClase=pluralClass[obClase.options[obClase.selectedIndex].value];
    }
    else {var textoClase=tiposPlural;}
if (P)
   {
    var obPais=document.getElementById('FRMPais');
    var pais=nombreMostrar;
    pais=formatText(pais);
    var textoUrlEn="-"+textoEn+"-"+pais;
    }
  if (Z)
   {
    var obZona=document.getElementById('FRMZona');
    var zona=nombreMostrar;
    zona=formatText(zona);
    var textoUrlEn="-"+textoEn+"-"+zona;
    var P="";
    textoUrlDeVacaciones="";
    }
   if (R)
   {
    var obRegion=document.getElementById('FRMRegion');
    var region=nombreMostrar;
    region=formatText(region);
    var textoUrlEn="-"+textoEn+"-"+region;
    var P="";
    var Z="";
    }
   if (E)
   {
    var obProvincia=document.getElementById('FRMProvincia');
    var provincia=nombreMostrar;
    provincia=formatText(provincia);
    var textoUrlEn="-"+textoEn+"-"+provincia;
    var P="";
    var Z="";
    var R="";
    textoUrlDeVacaciones="";
    }
   if (D)
   {
    var obDestino=document.getElementById('FRMDestino');
    var destino=nombreMostrar;
    destino=formatText(destino);
    var textoUrlEn="-"+textoEn+"-"+destino;
    var P="";
    var Z="";
    var R="";
    var E="";
    textoUrlDeVacaciones="";
    }
    else
      {var destino="";
      if (zona) {destino=zona;}
      else if (clase!=textoAlquiler){clase=textoAlquiler+"-"+clase;}
    }
     if (N)
   {
    var obBarrio=document.getElementById('FRMBarrio');
    var barrio=nombreMostrar;
    barrio=formatText(barrio);
    var textoUrlEn="-"+textoEn+"-"+barrio;
    var P="";
    var Z="";
    var R="";
    var E="";
    var D="";
    textoUrlDeVacaciones="";
    }

    var textURL=textoAlquiler+"-"+textoClase+textoUrlDeVacaciones+textoUrlEn;
    urlAction=textURL.toLowerCase()+"-W"+W+"B"+B+"C"+C+"P"+P+"Z"+Z+"R"+R+"E"+E+"D"+D+"N"+N+"A"+A+"I"+I+".html?newsearch=1";
		document.formBusquedaAlquileres.action = urlAction;
		document.formBusquedaAlquileres.submit();
}
