var http_peticion = false;
var http_capa = "";

function hazPeticion(url,capa)
{
  http_peticion = false;
  document.getElementById(capa).innerHTML='CARGANDO ...';

  if (window.XMLHttpRequest)
  { // Mozilla, Safari,...
    http_peticion = new XMLHttpRequest();
    if (http_peticion.overrideMimeType)
    {
      http_peticion.overrideMimeType('text/xml');
    }
  }
  else if (window.ActiveXObject)
  { // IE
    try
    {
      http_peticion = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        http_peticion = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e) {}
    }
  }else{
    alert("Navegador no compatible con AJAX.");
  }

  if (!http_peticion)
  {
    alert('No de puede crear una instancia XMLHTTP');
    return false;
  }
  http_capa = capa;
  http_peticion.onreadystatechange = muestraContenido;
  http_peticion.open('GET', url, true);
  http_peticion.send(null);
}

function muestraContenido()
{
  if (http_peticion.readyState == 4)
  {
    if (http_peticion.status == 200)
    {
      document.getElementById(http_capa).innerHTML=http_peticion.responseText;
    }
    else
    {
      alert('Hay un problema en la petición AJAX.');
    }
  }
}

var http_peticion2 = false;
var http_capa2 = "";

function hazPeticion2(url,capa)
{
  http_peticion2 = false;
  document.getElementById(capa).innerHTML='CARGANDO ...';

  if (window.XMLHttpRequest)
  { // Mozilla, Safari,...
    http_peticion2 = new XMLHttpRequest();
    if (http_peticion2.overrideMimeType)
    {
      http_peticion2.overrideMimeType('text/xml');
    }
  }
  else if (window.ActiveXObject)
  { // IE
    try
    {
      http_peticion2 = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        http_peticion2 = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e) {}
    }
  }else{
    alert("Navegador no compatible con AJAX.");
  }

  if (!http_peticion2)
  {
    alert('No de puede crear una instancia XMLHTTP');
    return false;
  }
  http_capa2 = capa;
  http_peticion2.onreadystatechange = muestraContenido2;
  http_peticion2.open('GET', url, true);
  http_peticion2.send(null);
}

function muestraContenido2()
{
  if (http_peticion2.readyState == 4)
  {
    if (http_peticion2.status == 200)
    {
      document.getElementById(http_capa2).innerHTML=http_peticion2.responseText;
    }
    else
    {
      alert('Hay un problema en la petición AJAX.');
    }
  }
}

function volver()
{
  history.back();
}

function imprimir()
{
  window.print();
}

function info_practica()
{
  document.getElementById("capa_conoce_la_region").style.display = "none";
  document.getElementById("capa_costa").style.display = "none";
  document.getElementById("capa_rural").style.display = "none";
  document.getElementById("capa_ciudad").style.display = "none";
  if (document.getElementById("capa_info_practica").style.display == "none")
  {
    document.getElementById("capa_info_practica").style.display = "block";
    if (document.getElementById("capa_home")){
      document.getElementById("capa_home").style.display = "none";
      document.getElementById("capa_home_oculta").style.display = "block";
    }
  }else{
    document.getElementById("capa_info_practica").style.display = "none";
    if (document.getElementById("capa_home")){
      document.getElementById("capa_home").style.display = "block";
      document.getElementById("capa_home_oculta").style.display = "none";
    }
  }
}

function conoce_la_region()
{
  document.getElementById("capa_info_practica").style.display = "none";
  document.getElementById("capa_costa").style.display = "none";
  document.getElementById("capa_rural").style.display = "none";
  document.getElementById("capa_ciudad").style.display = "none";
  if (document.getElementById("capa_conoce_la_region").style.display == "none")
  {
    document.getElementById("capa_conoce_la_region").style.display = "block";
    if (document.getElementById("capa_home")){
      document.getElementById("capa_home").style.display = "none";
      document.getElementById("capa_home_oculta").style.display = "block";
    }
  }else{
    document.getElementById("capa_conoce_la_region").style.display = "none";
    if (document.getElementById("capa_home")){
      document.getElementById("capa_home").style.display = "block";
      document.getElementById("capa_home_oculta").style.display = "none";
    }
  }
}

function costa()
{
  document.getElementById("capa_info_practica").style.display = "none";
  document.getElementById("capa_conoce_la_region").style.display = "none";
  document.getElementById("capa_rural").style.display = "none";
  document.getElementById("capa_ciudad").style.display = "none";
  document.getElementById("capa_costa").style.display = "block";
}

function rural()
{
  document.getElementById("capa_info_practica").style.display = "none";
  document.getElementById("capa_conoce_la_region").style.display = "none";
  document.getElementById("capa_costa").style.display = "none";
  document.getElementById("capa_ciudad").style.display = "none";
  document.getElementById("capa_rural").style.display = "block";
}

function ciudad()
{
  document.getElementById("capa_info_practica").style.display = "none";
  document.getElementById("capa_conoce_la_region").style.display = "none";
  document.getElementById("capa_costa").style.display = "none";
  document.getElementById("capa_rural").style.display = "none";
  document.getElementById("capa_ciudad").style.display = "block";
}

function cerrar_menu()
{
  document.getElementById("capa_conoce_la_region").style.display = "none";
  document.getElementById("capa_info_practica").style.display = "none";
  document.getElementById("capa_costa").style.display = "none";
  document.getElementById("capa_rural").style.display = "none";
  document.getElementById("capa_ciudad").style.display = "none";
  if (document.getElementById("capa_home")){
    document.getElementById("capa_home").style.display = "block";
    document.getElementById("capa_home_oculta").style.display = "none";
  }
}

function ver_fondos()
{
  document.getElementById("capa_todo").style.display = "none";
  document.getElementById("capa_nada").style.display = "block";
}

function ocultar_fondos()
{
  document.getElementById("capa_todo").style.display = "block";
  document.getElementById("capa_nada").style.display = "none";
}

function r_municipios(valor,nombre,idi,clase,estilo,capa)
{  
  hazPeticion("./turismo.funciones.municipios?idioma="+idi+"&nombre="+nombre+"&destino="+valor+"&clase="+clase+"&estilo="+estilo,capa);
}

function buscar()
{  
  var texto = document.getElementById("texto").value;
  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto; 
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function comprobar() {
  GetCookie('CarroTotal');
  for(i=0;i<GetCookie('CarroTotal');i++)
  {
	  if (GetCookie('Pagina'+i) == document.title+ "|" +document.location) {
	 	  document.getElementById("carrito").href="javascript:hecho();";
  		return true;	
  	}
  }
  return false;
}

function hecho (){
  alert ('La página ya ha sido añadida a "Mis Notas"');
}  

function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
		endstr = document.cookie.length;  
		return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
	var j = i + alen;    
	if (document.cookie.substring(i, j) == arg)      
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}

function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function AlCarro ()
{  
  if (!comprobar())
  {
    var total = GetCookie('CarroTotal');
  
    if (total==null) {
      SetCookie('Pagina0', document.title + "|" + document.location);
      total++;
      SetCookie ('CarroTotal', total);
    }
    else{
      SetCookie('Pagina'+ total, document.title + "|" + document.location);
      total++;
      SetCookie ('CarroTotal', total);
    }
    document.getElementById("carrito").href="javascript:hecho();"
    alert ('Documento añadido a "Mis Notas"');
  } else {
    alert ('La página ya ha sido añadida a "Mis Notas"');
  } 
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function buscar_agencias_viajes()
{  
  var texto = document.getElementById("texto").value;
  var tipo = document.getElementById("tipo").value;
  var reservas_online = "";
  var calidad_q = "";
  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (document.getElementById("reservas_online").checked) reservas_online = "S";
  if (document.getElementById("calidad_q").checked) calidad_q = "S";

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (tipo != "")  if (url != "") url = url + "&tipo="+tipo; else url = url + "tipo="+tipo;
  if (reservas_online != "") if (url != "") url = url + "&reservas_online="+reservas_online; else url = url + "reservas_online="+reservas_online;
  if (calidad_q != "") if (url != "") url = url + "&calidad_q="+calidad_q; else url = url + "calidad_q="+calidad_q;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function siguiente_fondo()
{
  if (contador < fondos.length-1)
    contador++;
  else
    contador = 0;

  document.getElementById("fondos_portal").background = "http://www.murciaturistica.es/PORTAL-2006/img_general/" + fondos[contador];
}

function anterior_fondo()
{
  if (contador > 0)
    contador--;
  else
    contador = fondos.length-1;

  document.getElementById("fondos_portal").background = "http://www.murciaturistica.es/PORTAL-2006/img_general/" + fondos[contador];
}

function buscar_compras()
{  
  var texto = document.getElementById("texto").value;
  var tipo = document.getElementById("tipo").value;
  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (url != "") url = "?" + url;

  location.href = tipo + url;
}

function buscar_artesania()
{  
  buscar_compras();
}

function buscar_deportes()
{  
  buscar_compras();
}

function buscar_recetas()
{  
  var texto = document.getElementById("texto").value;
  var tipo = document.getElementById("tipo").value;
  var dieta_mediterranea = "";
  var url = "buscar=S";

  if (document.getElementById("dieta_mediterranea").checked) dieta_mediterranea = "S";

  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (tipo != "")  if (url != "") url = url + "&tipo="+tipo; else url = url + "tipo="+tipo;
  if (dieta_mediterranea != "") if (url != "") url = url + "&dieta_mediterranea="+dieta_mediterranea; else url = url + "dieta_mediterranea="+dieta_mediterranea;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function buscar_restaurantes()
{  
  var texto = document.getElementById("texto").value;
  var categoria = document.getElementById("categoria").value;
  var primera_linea_playa = "";
  var calidad_q = "";
  var gastronomia_murciana = "";
  var estrella_michelin = "";
  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (document.getElementById("primera_linea_playa").checked) primera_linea_playa = "1";
  if (document.getElementById("calidad_q").checked) calidad_q = "1";
  if (document.getElementById("gastronomia_murciana").checked) gastronomia_murciana = "1";
  if (document.getElementById("estrella_michelin").checked) estrella_michelin = "1";

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (categoria != "")  if (url != "") url = url + "&categoria="+categoria; else url = url + "categoria="+categoria;
  if (primera_linea_playa != "") if (url != "") url = url + "&primera_linea_playa="+primera_linea_playa; else url = url + "primera_linea_playa="+primera_linea_playa;
  if (calidad_q != "") if (url != "") url = url + "&calidad_q="+calidad_q; else url = url + "calidad_q="+calidad_q;
  if (gastronomia_murciana != "") if (url != "") url = url + "&gastronomia_murciana="+gastronomia_murciana; else url = url + "gastronomia_murciana="+gastronomia_murciana;
  if (estrella_michelin != "") if (url != "") url = url + "&estrella_michelin="+estrella_michelin; else url = url + "estrella_michelin="+estrella_michelin;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function buscar_espacios_naturales()
{  
  var texto = document.getElementById("texto").value;
  var tipo = document.getElementById("tipo").value;
  var pdestino = "";
  var calidad_q = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  if (document.getElementById("calidad_q").checked) calidad_q = "S";

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (tipo != "")  if (url != "") url = url + "&tipo="+tipo; else url = url + "tipo="+tipo;
  if (calidad_q != "") if (url != "") url = url + "&calidad_q="+calidad_q; else url = url + "calidad_q="+calidad_q;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function buscar_playas()
{  
  var texto = document.getElementById("texto").value;
  var pdestino = "";
  var calidad_q = "";
  var discapacitados = "";
  var primera_linea = "";
  var bandera_azul = "";
  var url = "";

  if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;
  if (document.getElementById("calidad_q").checked) calidad_q = "S";
  if (document.getElementById("discapacitados").checked) discapacitados = "S";
  if (document.getElementById("primera_linea").checked) primera_linea = "S";
  if (document.getElementById("bandera_azul").checked) bandera_azul = "S";

  if (pdestino != "") url = url + "destino="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (calidad_q != "") if (url != "") url = url + "&calidad_q="+calidad_q; else url = url + "calidad_q="+calidad_q;
  if (discapacitados != "") if (url != "") url = url + "&discapacitados="+discapacitados; else url = url + "discapacitados="+discapacitados;
  if (primera_linea != "") if (url != "") url = url + "&primera_linea="+primera_linea; else url = url + "primera_linea="+primera_linea;
  if (bandera_azul != "") if (url != "") url = url + "&bandera_azul="+bandera_azul; else url = url + "bandera_azul="+bandera_azul;
  if (url != "") url = url + "&buscar=S"; else url = url + "buscar=S";
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function buscar_patrimonio_cultural()
{  
  buscar_compras();
}

function buscar_monumentos()
{  
  var texto = document.getElementById("texto").value;
  var categoria = document.getElementById("categoria").value;
  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (categoria != "")  if (url != "") url = url + "&categoria="+categoria; else url = url + "categoria="+categoria;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function buscar_museos()
{  
  var texto = document.getElementById("texto").value;
  var tipo = document.getElementById("tipo").value;
  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (tipo != "")  if (url != "") url = url + "&tipo="+tipo; else url = url + "tipo="+tipo;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function buscar_enlaces()
{  
  buscar_museos();
}

function buscar_arte_rupestre()
{  
  var texto = document.getElementById("texto").value;
  var pdestino = "";
  var url = "buscar=S";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (pdestino != "") if (url != "") url = url + "&localidad="+pdestino; else url = url + "localidad="+pdestino; 
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto; 
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function enviar_consulta()
{  
  var error = "";
  var boletin = "N";

  if (document.getElementById("descripcion").value == "") error = "ERROR: Debe completar el cambo DESCRIPCIÓN.";
  if (document.getElementById("email").value == "") error = "ERROR: Debe completar el cambo EMAIL.";
  if (document.getElementById("direccion").value == "") error = "ERROR: Debe completar el cambo DIRECCIÓN.";
  if (document.getElementById("nombre").value == "") error = "ERROR: Debe completar el cambo NOMBRE.";
  if (document.getElementById("boletin").checked) boletin = "S";

  if (error != "") alert(error);
  else{
   location.href = document.getElementById("formulario").action + '?nombre=' + document.getElementById("nombre").value +
   '&direccion=' + document.getElementById("direccion").value + '&email=' + document.getElementById("email").value +
   '&descripcion=' + document.getElementById("descripcion").value + '&boletin=' + boletin;
  }
}

function enviar_url()
{  
  var error = "";
  var copia = "N";

  if (document.getElementById("mensaje").value == "") error = "ERROR: Debe completar el cambo MENSAJE.";
  if (document.getElementById("para_email").value == "") error = "ERROR: Debe completar el cambo PARA (EMAIL).";
  if (document.getElementById("para_nombre").value == "") error = "ERROR: Debe completar el cambo PARA (NOMBRE).";
  if (document.getElementById("de_email").value == "") error = "ERROR: Debe completar el cambo DE (EMAIL).";
  if (document.getElementById("de_nombre").value == "") error = "ERROR: Debe completar el cambo DE (NOMBRE).";
  if (document.getElementById("copia").checked) copia = "S";

  if (error != "") alert(error);
  else{
   location.href = document.getElementById("formulario").action + '?de_nombre=' + document.getElementById("de_nombre").value +
   '&de_email=' + document.getElementById("de_email").value + '&to_nombre=' + document.getElementById("para_nombre").value +
   '&to_email=' + document.getElementById("para_email").value + '&mensaje=' + document.getElementById("mensaje").value + '&copia=' + copia +
   '&url=' + document.getElementById("url").value;
  }
}

function buscar_salud_y_belleza()
{  
  buscar_compras();
}

function buscar_ocio_y_diversion()
{  
  buscar_compras();
}

function buscar_ferias_y_congresos()
{  
  buscar_compras();
}

function buscar_videos()
{  
  var texto = document.getElementById("texto").value;
  var url = "";

  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto; 
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function previsualizar_postal()
{  
  var error = "";

  if (document.getElementById("texto").value == "") error = "ERROR: Debe completar el cambo TEXTO.";
  if (document.getElementById("titulo").value == "") error = "ERROR: Debe completar el cambo TÍTULO.";
  if (document.getElementById("email_destinatario").value == "") error = "ERROR: Debe completar el cambo EMAIL DESTINATARIO.";
  if (document.getElementById("nombre_destinatario").value == "") error = "ERROR: Debe completar el cambo NOMBRE DESTINATARIO.";
  if (document.getElementById("email").value == "") error = "ERROR: Debe completar el cambo TU EMAIL.";
  if (document.getElementById("nombre").value == "") error = "ERROR: Debe completar el cambo TU NOMBRE.";

  if (error != "") alert(error);
  else{
   location.href = document.getElementById("formulario").action + '?nombre=' + document.getElementById("nombre").value +
   '&email=' + document.getElementById("email").value + '&nombre_destinatario=' + document.getElementById("nombre_destinatario").value +
   '&email_destinatario=' + document.getElementById("email_destinatario").value +'&titulo=' + document.getElementById("titulo").value +
   '&texto=' + document.getElementById("texto").value + '&postal=' + document.getElementById("postal").value;
  }
}

function enviar_postal()
{  
  previsualizar_postal();
}

function buscar_turismo_informa()
{  
  var texto = document.getElementById("texto").value;
  var tipo = document.getElementById("tipo").value;
  var anu = document.getElementById("anu").value;
  var url = "";

  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (tipo != "")  if (url != "") url = url + "&tipo="+tipo; else url = url + "tipo="+tipo;
  if (url != "") url = url + "&anu="+anu; else url = url + "anu="+anu;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function buscar_novedades()
{  
  var texto = document.getElementById("texto").value;
  var categoria = document.getElementById("categoria").value;
  var anu = document.getElementById("anu").value;
  var url = "";

  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (url != "") url = url + "&categoria="+categoria; else url = url + "categoria="+categoria;
  if (url != "") url = url + "&anu="+anu; else url = url + "anu="+anu;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function buscar_historico()
{
  buscar_novedades();
}

function buscar_panoramas()
{
  buscar_museos();
}

function buscar_hoteles()
{  
  var texto = document.getElementById("texto").value;
  var categoria = document.getElementById("categoria").value;
  var primera_linea_playa = "";
  var calidad_q = "";
  var discapacitados = "";
  var reservas_online = "";
  var parador = "";

  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (document.getElementById("primera_linea_playa").checked) primera_linea_playa = "S";
  if (document.getElementById("calidad_q").checked) calidad_q = "S";
  if (document.getElementById("discapacitados").checked) discapacitados = "S";
  if (document.getElementById("reservas_online").checked) reservas_online = "S";
  if (document.getElementById("parador").checked) parador = "S";

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (categoria != "")  if (url != "") url = url + "&categoria="+categoria; else url = url + "categoria="+categoria;
  if (primera_linea_playa != "") if (url != "") url = url + "&primera_linea_playa="+primera_linea_playa; else url = url + "primera_linea_playa="+primera_linea_playa;
  if (calidad_q != "") if (url != "") url = url + "&calidad_q="+calidad_q; else url = url + "calidad_q="+calidad_q;
  if (discapacitados != "") if (url != "") url = url + "&discapacitados="+discapacitados; else url = url + "discapacitados="+discapacitados;
  if (reservas_online != "") if (url != "") url = url + "&reservas_online="+reservas_online; else url = url + "reservas_online="+reservas_online;
  if (parador != "") if (url != "") url = url + "&parador="+parador; else url = url + "parador="+parador;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function buscar_apartamentos()
{  
  buscar_hoteles();
}

function buscar_alojamientos_rurales()
{  
  buscar_hoteles();
}

function buscar_casas_rurales()
{  
  buscar_hoteles();
}

function buscar_hospederias_rurales()
{  
  buscar_hoteles();
}

function buscar_campings()
{  
  buscar_hoteles();
}

function buscar_alojamientos_vacacionales()
{  
  buscar_hoteles();
}

function buscar_complejos_turisticos()
{  
  buscar_hoteles();
}

function buscar_albergues()
{  
  buscar_hoteles();
}


function r_categorias(valor,nombre,idi,clase,estilo,capa)
{  
  hazPeticion("./turismo.funciones.categorias?idioma="+idi+"&nombre="+nombre+"&destino="+valor+"&clase="+clase+"&estilo="+estilo,capa);
}

function buscar_alojamientos()
{  
  var texto = document.getElementById("texto").value;
  var categoria = document.getElementById("categoria").value;
  var primera_linea_playa = "";
  var calidad_q = "";
  var discapacitados = "";
  var reservas_online = "";
  var parador = "";

  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (document.getElementById("primera_linea_playa").checked) primera_linea_playa = "S";
  if (document.getElementById("calidad_q").checked) calidad_q = "S";
  if (document.getElementById("discapacitados").checked) discapacitados = "S";
  if (document.getElementById("reservas_online").checked) reservas_online = "S";
  if (document.getElementById("parador").checked) parador = "S";

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (categoria != "")  if (url != "") url = url + "&categoria="+categoria; else url = url + "categoria="+categoria;
  if (primera_linea_playa != "") if (url != "") url = url + "&primera_linea_playa="+primera_linea_playa; else url = url + "primera_linea_playa="+primera_linea_playa;
  if (calidad_q != "") if (url != "") url = url + "&calidad_q="+calidad_q; else url = url + "calidad_q="+calidad_q;
  if (discapacitados != "") if (url != "") url = url + "&discapacitados="+discapacitados; else url = url + "discapacitados="+discapacitados;
  if (reservas_online != "") if (url != "") url = url + "&reservas_online="+reservas_online; else url = url + "reservas_online="+reservas_online;
  if (parador != "") if (url != "") url = url + "&parador="+parador; else url = url + "parador="+parador;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("tipo").value + url;
}

function consultar_disponibilidad()
{
  var error = "";
  var personas = document.getElementById("pax").value;
  var fecha_ini = document.getElementById("fec_ini").value;
  var fecha_fin = document.getElementById("fec_fin").value;
  var establecimiento = document.getElementById("proveedor").value;
  var servicio = document.getElementById("servicio").value;
  var diahoy = document.getElementById("dia").value;
  var meshoy = document.getElementById("mes").value;
  var anohoy = document.getElementById("anu").value;
  var diad = 0;
  var mesd = 0;
  var anod = 0;
  var diah = 0;
  var mesh = 0;
  var anoh = 0;

  diad = fecha_ini.substring(0,2);
  mesd = fecha_ini.substring(3,5);
  anod = fecha_ini.substring(6,10);
  diah = fecha_fin.substring(0,2);
  mesh = fecha_fin.substring(3,5);
  anoh = fecha_fin.substring(6,10);
	
  if ((anod < anohoy) || ((anod == anohoy) && (mesd < meshoy)) || ((anod == anohoy) && (mesd == meshoy) && (diad < diahoy)))
    error = "ERROR: La fecha de inicio no puede ser menor que la fecha actual o ha sido introducida incorrectamente, use el formato 'DD/MM/AAAA'";
  if ((anod > anoh) || ((anod == anoh) && (mesd > mesh)) || ((anod == anoh) && (mesd == mesh) && (diad >= diah)))
    error = "ERROR: La fecha final debe ser posterior a la fecha Inicial o ha sido introducida incorrectamente, use el formato 'DD/MM/AAAA'";
  if (fecha_fin == "") error = "ERROR: Debe indicar la fecha de finalización de la reserva.";
  if (fecha_ini == "") error = "ERROR: Debe indicar la fecha de inicio de la reserva.";
  if (personas == "") error = "ERROR: Debe indicar el número de personas.";

  if (error != "") alert(error);
  else
    location.href = document.getElementById("formulario").action + "?fec_ini="+fecha_ini+"&fec_fin="+fecha_fin+"&personas="+personas+"&hotel="+establecimiento+"&unservicio="+servicio;
}

function buscar_ofertas()
{  
  var texto = document.getElementById("texto").value;
  var tipo = document.getElementById("tipo").value;
  var tipo_recurso = document.getElementById("tipo_recurso").value;
  var categoria = document.getElementById("categoria").value;
  var fecha_inicio = document.getElementById("fecha_inicio").value;
  var fecha_fin = document.getElementById("fecha_fin").value;

  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (tipo != "")  if (url != "") url = url + "&tipo="+tipo; else url = url + "tipo="+tipo;
  if (tipo_recurso != "")  if (url != "") url = url + "&tipo_recurso="+tipo_recurso; else url = url + "tipo_recurso="+tipo_recurso;
  if (categoria != "")  if (url != "") url = url + "&categoria="+categoria; else url = url + "categoria="+categoria;
  if (fecha_inicio != "")  if (url != "") url = url + "&fecha_inicio="+fecha_inicio; else url = url + "fecha_inicio="+fecha_inicio;
  if (fecha_fin != "")  if (url != "") url = url + "&fecha_fin="+fecha_fin; else url = url + "fecha_fin="+fecha_fin;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function buscar_reservas()
{  
  var texto = document.getElementById("texto").value;
  var categoria = document.getElementById("categoria").value;
  var fecha_inicio = document.getElementById("fecha_inicio").value;
  var fecha_fin = document.getElementById("fecha_fin").value;
  var personas = document.getElementById("personas").value;
  var precio = document.getElementById("precio").value;
  var error = "";
  var diahoy = document.getElementById("dia").value;
  var meshoy = document.getElementById("mes").value;
  var anohoy = document.getElementById("anu").value;
  var diad = 0;
  var mesd = 0;
  var anod = 0;
  var diah = 0;
  var mesh = 0;
  var anoh = 0;

  diad = fecha_inicio.substring(0,2);
  mesd = fecha_inicio.substring(3,5);
  anod = fecha_inicio.substring(6,10);
  diah = fecha_fin.substring(0,2);
  mesh = fecha_fin.substring(3,5);
  anoh = fecha_fin.substring(6,10);

  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (categoria != "")  if (url != "") url = url + "&categoria="+categoria; else url = url + "categoria="+categoria;
  if (fecha_inicio != "")  if (url != "") url = url + "&fecha_inicio="+fecha_inicio; else url = url + "fecha_inicio="+fecha_inicio;
  if (fecha_fin != "")  if (url != "") url = url + "&fecha_fin="+fecha_fin; else url = url + "fecha_fin="+fecha_fin;
  if (personas != "")  if (url != "") url = url + "&personas="+personas; else url = url + "personas="+personas;
  if (precio != "")  if (url != "") url = url + "&precio="+precio; else url = url + "precio="+precio;
  if (url != "") url = "?" + url;

  if ((anod < anohoy) || ((anod == anohoy) && (mesd < meshoy)) || ((anod == anohoy) && (mesd == meshoy) && (diad < diahoy)))
    error = "ERROR: La fecha de inicio no puede ser menor que la fecha actual o ha sido introducida incorrectamente, use el formato 'DD/MM/AAAA'";
  if ((anod > anoh) || ((anod == anoh) && (mesd > mesh)) || ((anod == anoh) && (mesd == mesh) && (diad >= diah)))
    error = "ERROR: La fecha final debe ser posterior a la fecha Inicial o ha sido introducida incorrectamente, use el formato 'DD/MM/AAAA'";
  if (fecha_fin == "") error = "ERROR: Debe indicar la fecha de finalización de la reserva.";
  if (fecha_inicio == "") error = "ERROR: Debe indicar la fecha de inicio de la reserva.";
  if (personas == "") error = "ERROR: Debe indicar el número de personas.";

  if (error != "") alert(error);
  else
    location.href = document.getElementById("tipo").value + url;
}

function consultar_reserva()
{  
  var localizador = document.getElementById("localizador").value;
  var codigo_seguridad = document.getElementById("codigo_seguridad").value;
  var error = "";

  if (codigo_seguridad == "") error = "ERROR: Debe indicar el código de seguridad de su reserva.";
  if (localizador == "") error = "ERROR: Debe indicar el localizador de su reserva.";

  if (error != "") alert(error);
  else
    location.href = document.getElementById("url_consultas").value + "?localizador="+localizador+"&codigo_seguridad="+codigo_seguridad;
}

function buscar_eventos()
{  
  var texto = document.getElementById("texto").value;
  var seccion = document.getElementById("seccion").value;
  var fecha_inicio = document.getElementById("fecha_inicio").value;
  var fecha_fin = document.getElementById("fecha_fin").value;
  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (seccion != "")  if (url != "") url = url + "&seccion="+seccion; else url = url + "seccion="+seccion;
  if (fecha_inicio != "")  if (url != "") url = url + "&fecha_inicio="+fecha_inicio; else url = url + "fecha_inicio="+fecha_inicio;
  if (fecha_fin != "")  if (url != "") url = url + "&fecha_fin="+fecha_fin; else url = url + "fecha_fin="+fecha_fin;
  if (url != "") url = url + "&rango="; else url = url + "rango=";
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function r_cines(valor,nombre,idi,clase,estilo,capa)
{  
  hazPeticion("./turismo.funciones.cines?idioma="+idi+"&nombre="+nombre+"&destino="+valor+"&clase="+clase+"&estilo="+estilo,capa);
}

function r_peliculas(valor,nombre,idi,clase,estilo,capa)
{  
  hazPeticion("./turismo.funciones.peliculas?idioma="+idi+"&nombre="+nombre+"&destino="+valor+"&clase="+clase+"&estilo="+estilo,capa);
}

function buscar_peliculas()
{  
  var localidad = document.getElementById("localidad").value;
  var cine = document.getElementById("cine").value;
  var pelicula = document.getElementById("pelicula").value;
  var estreno = "";
  var url = "";

  if (document.getElementById("estreno").checked) estreno = "S";

  if (localidad != "") if (url != "") url = url + "&localidad="+localidad; else url = url + "localidad="+localidad;
  if (cine != "")  if (url != "") url = url + "&cine="+cine; else url = url + "cine="+cine;
  if (pelicula != "") if (url != "") url = url + "&pelicula="+pelicula; else url = url + "pelicula="+pelicula;
  if (estreno != "") if (url != "") url = url + "&estreno="+estreno; else url = url + "estreno="+estreno;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function r_valores(valor,nombre,idi,clase,estilo,capa)
{  
  hazPeticion("./turismo.funciones.valores?idioma="+idi+"&nombre="+nombre+"&destino="+valor+"&clase="+clase+"&estilo="+estilo,capa);
}

function r_destinos(valor,valor2,nombre,idi,clase,estilo,capa)
{  
  hazPeticion2("./turismo.funciones.criterios?idioma="+idi+"&nombre="+nombre+"&destino="+valor+"&destino2="+valor2+"&clase="+clase+"&estilo="+estilo,capa);
}

function buscar_mas_de_100_ideas()
{  
  var localidad = document.getElementById("localidad").value;
  var criterio = document.getElementById("criterio").value;
  var valor = document.getElementById("valor").value;
  var url = "";

  if (localidad != "") if (url != "") url = url + "&localidad="+localidad; else url = url + "localidad="+localidad;
  if (criterio != "")  if (url != "") url = url + "&criterio="+criterio; else url = url + "criterio="+criterio;
  if (valor != "") if (url != "") url = url + "&valor="+valor; else url = url + "valor="+valor;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function buscar_fiestas()
{  
  var texto = document.getElementById("texto").value;
  var interes = document.getElementById("interes").value;
  var religiosa = document.getElementById("religiosa").value;
  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto; 
  if (interes != "") if (url != "") url = url + "&interes="+interes; else url = url + "interes="+interes; 
  if (religiosa != "") if (url != "") url = url + "&religiosa="+religiosa; else url = url + "religiosa="+religiosa; 
  if (url != "") url = url + "&buscar=S"; else url = url + "buscar=S"; 
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function buscar_turismo_activo()
{  
  var texto = document.getElementById("texto").value;
  var tipo = document.getElementById("tipo").value;
  var reservas_online = "";
  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (document.getElementById("reservas_online").checked) reservas_online = "S";

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (tipo != "")  if (url != "") url = url + "&tipo="+tipo; else url = url + "tipo="+tipo;
  if (reservas_online != "") if (url != "") url = url + "&reservas_online="+reservas_online; else url = url + "reservas_online="+reservas_online;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function consultar_servicios()
{
  var error = "";
  var personas = document.getElementById("pax").value;
  var fecha_ini = document.getElementById("fec_ini").value;
  var fecha_fin = document.getElementById("fec_ini").value;
  var establecimiento = document.getElementById("proveedor").value;
  var servicio = document.getElementById("servicio").value;
  var diahoy = document.getElementById("dia").value;
  var meshoy = document.getElementById("mes").value;
  var anohoy = document.getElementById("anu").value;
  var diad = 0;
  var mesd = 0;
  var anod = 0;
  var diah = 0;
  var mesh = 0;
  var anoh = 0;

  diad = fecha_ini.substring(0,2);
  mesd = fecha_ini.substring(3,5);
  anod = fecha_ini.substring(6,10);
  diah = fecha_fin.substring(0,2);
  mesh = fecha_fin.substring(3,5);
  anoh = fecha_fin.substring(6,10);
	
  if ((anod < anohoy) || ((anod == anohoy) && (mesd < meshoy)) || ((anod == anohoy) && (mesd == meshoy) && (diad < diahoy)))
    error = "ERROR: La fecha de inicio no puede ser menor que la fecha actual o ha sido introducida incorrectamente, use el formato 'DD/MM/AAAA'";
  if (fecha_ini == "") error = "ERROR: Debe indicar la fecha de inicio de la reserva.";
  if (personas == "") error = "ERROR: Debe indicar el número de personas.";

  if (error != "") alert(error);
  else
    location.href = document.getElementById("formulario").action + "?fec_ini="+fecha_ini+"&fec_fin="+fecha_fin+"&personas="+personas+"&hotel="+establecimiento+"&unservicio="+servicio;
}

function buscar_boletines_digitales()
{  
  var texto = document.getElementById("texto").value;
  var anu = document.getElementById("anu").value;
  var url = "";

  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto;
  if (url != "") url = url + "&anu="+anu; else url = url + "anu="+anu;
  if (url != "") url = "?" + url;

  location.href = document.getElementById("formulario").action + url;
}

function redirecciona(valor)
{
  document.getElementById("caja_buscador").disabled = true;
  window.location=valor;
}

function destacado(valor,enlace)
{
  document.getElementById("fondos_destacados").style.backgroundImage = "url(http://www.murciaturistica.es/PORTAL-2006/img_general/" + fondos_destacados[valor][0] + ")";
  document.getElementById("url_destacados").href = fondos_destacados[valor][1];
  document.getElementById("url_destacados").target = fondos_destacados[valor][3];
  document.getElementById("imagen_destacados").title = fondos_destacados[valor][2];
  document.getElementById("texto_destacados").innerHTML = fondos_destacados[valor][2];
  for (i=1;i<=contador3;i++)
    document.getElementById("opc_"+i).style.fontWeight = "";
  document.getElementById(enlace).style.fontWeight = "bold";
}

function agenda(valor,enlace)
{
  document.getElementById("fondos_agenda").style.backgroundImage = "url(" + fondos_agenda[valor][0] + ")";
  document.getElementById("url_agenda").href = fondos_agenda[valor][1];
  document.getElementById("imagen_agenda").title = fondos_agenda[valor][2];
  document.getElementById("url_agenda").target = fondos_agenda[valor][3];
  for (i=1;i<=contador4;i++)
    document.getElementById("age_"+i).style.fontWeight = "";
  document.getElementById(enlace).style.fontWeight = "bold";
}

function siguiente_evento()
{
  if (contador2 < eventos.length-1)
    contador2++;
  else
    contador2 = 0;

  document.getElementById("eventos_agenda").innerHTML = eventos[contador2];
}

function anterior_evento()
{
  if (contador2 > 0)
    contador2--;
  else
    contador2 = eventos.length-1;

  document.getElementById("eventos_agenda").innerHTML = eventos[contador2];
}

function mail(texto){ 
    var mailres = true;             
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-"; 
     
    var arroba = texto.indexOf("@",0); 
    if ((texto.lastIndexOf("@")) != arroba) arroba = -1; 
     
    var punto = texto.lastIndexOf("."); 
                 
     for (var contador = 0 ; contador < texto.length ; contador++){ 
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){ 
            mailres = false; 
            break; 
     } 
    } 

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1)) 
     mailres = true; 
    else 
     mailres = false; 
                 
    return mailres; 
} 

function buscar_fiestas_y_festivales()
{  
  var texto = document.getElementById("texto").value;
  var tipo = document.getElementById("tipo").value;
  var interes = document.getElementById("interes").value;
  var religiosa = document.getElementById("religiosa").value;
  var pdestino = "";
  var url = "";

  if (document.getElementById("localidad").value != "") pdestino = document.getElementById("localidad").value;
  else if (document.getElementById("destino").value != "") pdestino = document.getElementById("destino").value;

  if (pdestino != "") url = url + "localidad="+pdestino;
  if (texto != "") if (url != "") url = url + "&texto="+texto; else url = url + "texto="+texto; 
  if (tipo == "1"){
    if (interes != "") if (url != "") url = url + "&interes="+interes; else url = url + "interes="+interes; 
    if (religiosa != "") if (url != "") url = url + "&religiosa="+religiosa; else url = url + "religiosa="+religiosa; 
    if (url != "") url = url + "&buscar=S"; else url = url + "buscar=S"; 
    if (url != "") url = "?" + url;
    location.href = document.getElementById("formulario").action + url;
  }else{
    if (url != "") url = "?" + url;
    location.href = document.getElementById("formulario2").value + url;
  }
}

function cambia_lista_ff()
{
  var tipo = document.getElementById("tipo").value;

  if (tipo == "1"){
    document.getElementById("interes").disabled = false;
  }else{
    document.getElementById("interes").disabled = true;
  }
}

var aFinMes = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

function finMes(nMes, nAno){
   return aFinMes[nMes - 1] + (((nMes == 2) && (nAno % 4) == 0)? 1: 0);
}
 
function padNmb(nStr, nLen, sChr){
    var sRes = String(nStr);
    for (var i = 0; i < nLen - String(nStr).length; i++)
     sRes = sChr + sRes;
    return sRes;
}
 
function makeDateFormat(nDay, nMonth, nYear){
    var sRes;
    sRes = padNmb(nDay, 2, "0") + "/" + padNmb(nMonth, 2, "0") + "/" + padNmb(nYear, 4, "0");
    return sRes;
}

function incDate(sFec0){
   var nDia = parseInt(sFec0.substr(0, 2), 10);
   var nMes = parseInt(sFec0.substr(3, 2), 10);
   var nAno = parseInt(sFec0.substr(6, 4), 10);
   nDia += 1;
   if (nDia > finMes(nMes, nAno)){
    nDia = 1;
    nMes += 1;
    if (nMes == 13){
     nMes = 1;
     nAno += 1;
    }
   }
   return makeDateFormat(nDia, nMes, nAno);
}
 
function decDate(sFec0){
   var nDia = Number(sFec0.substr(0, 2));
   var nMes = Number(sFec0.substr(3, 2));
   var nAno = Number(sFec0.substr(6, 4));
   nDia -= 1;
   if (nDia == 0){
    nMes -= 1;
    if (nMes == 0){
     nMes = 12;
     nAno -= 1;
    }
    nDia = finMes(nMes, nAno);
   }
   return makeDateFormat(nDia, nMes, nAno);
}

function addToDate(sFec0, sInc){
   var nInc = Math.abs(parseInt(sInc));
   var sRes = sFec0;
   if (parseInt(sInc) >= 0)
    for (var i = 0; i < nInc; i++) sRes = incDate(sRes);
   else
    for (var i = 0; i < nInc; i++) sRes = decDate(sRes);
   return sRes;
}


function sumardias(fecha,incremento)
{
  var aux = addToDate(fecha, incremento);
  return aux;
}


function consultar_disponibilidad_paquetes()
{
  var error = "";
  var personas = document.getElementById("pax").value;
  var fecha_ini = document.getElementById("fec_ini").value;
  var fecha_fin = fecha_ini;
//  var fecha_fin = sumardias(fecha_ini, 1);
  var establecimiento = document.getElementById("proveedor").value;
  var servicio = document.getElementById("servicio").value;
  var diahoy = document.getElementById("dia").value;
  var meshoy = document.getElementById("mes").value;
  var anohoy = document.getElementById("anu").value;
  var diad = 0;
  var mesd = 0;
  var anod = 0;
  var diah = 0;
  var mesh = 0;
  var anoh = 0;

  diad = fecha_ini.substring(0,2);
  mesd = fecha_ini.substring(3,5);
  anod = fecha_ini.substring(6,10);
  diah = fecha_fin.substring(0,2);
  mesh = fecha_fin.substring(3,5);
  anoh = fecha_fin.substring(6,10);
	
  if ((anod < anohoy) || ((anod == anohoy) && (mesd < meshoy)) || ((anod == anohoy) && (mesd == meshoy) && (diad < diahoy)))
    error = "ERROR: La fecha de inicio no puede ser menor que la fecha actual o ha sido introducida incorrectamente, use el formato 'DD/MM/AAAA'";
//  if ((anod > anoh) || ((anod == anoh) && (mesd > mesh)) || ((anod == anoh) && (mesd == mesh) && (diad >= diah)))
//    error = "ERROR: La fecha final debe ser posterior a la fecha Inicial o ha sido introducida incorrectamente, use el formato 'DD/MM/AAAA'";
  if (fecha_fin == "") error = "ERROR: Debe indicar la fecha de finalización de la reserva.";
  if (fecha_ini == "") error = "ERROR: Debe indicar la fecha de inicio de la reserva.";
  if (personas == "") error = "ERROR: Debe indicar el número de personas.";

  if (error != "") alert(error);
  else
    location.href = document.getElementById("formulario").action + "?fec_ini="+fecha_ini+"&fec_fin="+fecha_fin+"&personas="+personas+"&hotel="+establecimiento+"&unservicio="+servicio;
}
