function enviar_formulario_informacion() {
	if (document.formulario.Nombre.value.length==0){
		alert("Debe cumplimentar los campos obligatorios");
		document.formulario.Nombre.focus();
		return;
	}
	if (document.formulario.Email.value.length==0){
		alert("Debe cumplimentar los campos obligatorios");
		document.formulario.Email.focus();
		return;
	}
	if ( (document.formulario.Email.value.indexOf ('@', 0) == -1) || (document.formulario.Email.value.length < 5) ) { 
    alert("Escriba una dirección de correo válida en el campo \"E-mail\".");
		document.formulario.Email.focus();
		document.formulario.Email.select();
  	return;
	}
	document.formulario.submit();
}

function mostrar_sucursal (id_sucursal) {
	if (document.getElementById || document.all || document.layers) {
		var tag_to_hide = eval('document.getElementById("' + id_sucursal + '").style');
	}
	
	if (tag_to_hide.display == "none")
		tag_to_hide.display="block"
	else
		tag_to_hide.display="none"
}

function ver_mapa(ida,idd,ancho) {
  document.getElementById("ifrm_gmaps").src="http://www.aevav.com/gmap.php?ida=" + ida + "&idd=" + idd + "&width=" + ancho;
}

function getCheckedValue(radioObj) {
  if(!radioObj)
    return "";
  var radioLength = radioObj.length;
  if(radioLength == undefined)
    if(radioObj.checked)
      return radioObj.value;
    else
      return "";
  for(var i = 0; i < radioLength; i++) {
    if(radioObj[i].checked) {
      return radioObj[i].value;
    }
  }
  return "";
}

function check_fecha(cadena) {
/*
	if (cadena.length ==0) {
     return true;
  };
*/
  if (cadena.length !=10) {
		return false;
	}

	dia = cadena.substr(0,2)*1;
	mes = cadena.substr(3,2)*1;
	anyo = cadena.substr(6,4)*1;

	if ((mes >12) || (mes < 1)) {
     return false;
  }
  if ((dia >31) || (dia < 1)) {
     return false;
  }
  if ((anyo >2010) || (anyo < 2002)) {
     return false;
  }
  if ((mes == 2) && (dia > 28)) {
     return false;
  }
  if ((dia >30) && (mes != 1) && (mes != 3) && (mes != 5) && (mes != 7) && (mes != 8) && (mes != 10) && (mes != 12)) {
     return false;
  }
  return true;
}

function check_form_vuelos() {
  falta = "";

  if (document.buscador_vuelos.originAirportName.value == "" || document.buscador_vuelos.originCountryName.value == "") {
    falta += "\n     -  Origen";
  }

  if (document.buscador_vuelos.destinationAirportName.value == "" || document.buscador_vuelos.destinationCountryName.value=="") {
    falta += "\n     -  Destino";
  }

  if (document.buscador_vuelos.departureDate1AsString.value == "" || !check_fecha(document.buscador_vuelos.departureDate1AsString.value)) {
    falta += "\n     -  Fecha salida (o no es correcta)";
  }

  if(getCheckedValue(document.forms['buscador_vuelos'].elements['oneWay'])=="false") {
    if (document.buscador_vuelos.departureDate2AsString.value == "" || !check_fecha(document.buscador_vuelos.departureDate2AsString.value)) {
      falta += "\n     -  Fecha regreso (o no es correcta)";
    }
 
    if (document.buscador_vuelos.departureDate1AsString.value == document.buscador_vuelos.departureDate2AsString.value)
      document.buscador_vuelos.departureHour2.value="2300";
  }
 
  if (falta != "") {
    falta ="_____________________________\n" +
    "Te ha faltado introducir los siguientes datos:\n" +
    falta + "\n_____________________________" +
    "\n¡Por favor pulsa enter, rellena los datos y prueba de nuevo!";
    alert(falta);
    return false;
  } else {
    document.buscador_vuelos.totalTravellers.value=parseInt(document.buscador_vuelos.adults.options[document.buscador_vuelos.adults.selectedIndex].value)+parseInt(document.buscador_vuelos.children.options[document.buscador_vuelos.children.selectedIndex].value)+parseInt(document.buscador_vuelos.infants.options[document.buscador_vuelos.infants.selectedIndex].value);

    document.buscador_vuelos.submit();
  }
}

function redim() {
  //Redimensiona un iframe pasando su id como parametro y la anchura/altura
  parent.document.getElementById('reservas_online').style.height=800;
  parent.document.getElementById('reservas_online').style.width=700;
  var miIframe=document.getElementById('frame_inicio');
  miIframe.style.height=800;
  miIframe.style.width=700;

}

function bookmarksite(title,url) {
	if (window.sidebar) { 													// firefox
		window.sidebar.addPanel(title, url, "");
	} else if(window.opera && window.print) { 			// opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} else if(document.all) { 											// ie
		window.external.AddFavorite(url, title);
	}
}