function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function nuevoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E) {
			xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
} 
function cargarCombo (url, comboAnterior, element_id) { 
    //Obtenemos el contenido del div 
    //donde se cargaran los resultados 
    var element =  document.getElementById(element_id); 
    //Obtenemos el valor seleccionado del combo anterior 
    var valordepende = document.getElementById(comboAnterior) 
    var x = valordepende.value 
    //construimos la url definitiva 
    //pasando como parametro el valor seleccionado 
    var fragment_url = url+x; 
	ajax=nuevoAjax(); 	
    element.innerHTML = 'cargando...'; 
	//abrimos la url 
	//alert(fragment_url);
    ajax.open("GET", fragment_url, true);
	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	
	ajax.onreadystatechange = function() { 
       if (ajax.readyState == 4) { 
			//escribimos la respuesta 
			element.innerHTML = ajax.responseText; 
       } 
    } 
		
    ajax.send(null); 
} 
function listadestinos (element_id,id_idioma) { 
    //Obtenemos el contenido del div 
    //donde se cargaran los resultados
	var campovalor='destino';
	var url='/aplicacion/clases/datos/destinos.php?id_idioma='+id_idioma+'&destino='
    var element =  document.getElementById(element_id); 
    //Obtenemos el valor seleccionado del combo anterior 
    var valordepende = document.getElementById(campovalor) 
    var x = valordepende.value 
	//comprobar si longitud es mayor a 3 caracteres
	tamTotal = valordepende.value.length;
	
	if (tamTotal > 2){
		var fragment_url = url+x; 
		ajax=nuevoAjax(); 			
			
	}
	else{
			return false;
	}
	
	//alert (fragment_url);
	//alert(fragment_url);
    ajax.open("GET", fragment_url, true);
	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	
	ajax.onreadystatechange = function() { 
       if (ajax.readyState == 4) { 
			//escribimos la respuesta 
			element.style.display='block';
			element.innerHTML = ajax.responseText; 
			//cargar campos con primer con primer valor aunque no seleccione
			auxseldestino();			
       } 
    } 
		
    ajax.send(null); 
} 

function alerta(mensaje){
	alert(mensaje);
}
function seldestino (textpro,id_pais,id_provincia,id_municipio,distrito) { 
    var Iddestino =  document.getElementById('destino'); 
	var Idpais =  document.getElementById('pais'); 
	var Iddest =  document.getElementById('dest'); 
	var Idmunicipio =  document.getElementById('municipio'); 
	var Iddistrito =  document.getElementById('distrito'); 
	//alert (textpro);
    Iddestino.value=textpro;
	Idpais.value=id_pais;
	Iddest.value=id_provincia;
	Idmunicipio.value=id_municipio;
	Iddistrito.value=distrito;
	//ocultar detalles capa cdest
	var Idcdest =  document.getElementById('cdest'); 	
	Idcdest.innerHTML = '';
	Idcdest.style.display='none';

	//activar botón formulario
	var Idcenviar =  document.getElementById('cenviar'); 
	return false;
} 
function auxseldestino () {
	//destinos
    var Iddestino =  document.getElementById('destino'); 
	var Idpais =  document.getElementById('pais'); 
	var Iddest =  document.getElementById('dest'); 
	var Idmunicipio =  document.getElementById('municipio'); 
	var Iddistrito =  document.getElementById('distrito');
	//origenes
	var IauxIddestino =  document.getElementById('auxdestino'); 
	var IauxIdpais =  document.getElementById('auxpais'); 
	var IauxIddest =  document.getElementById('auxdest'); 
	var IauxIdmunicipio =  document.getElementById('auxmunicipio'); 
	var IauxIddistrito =  document.getElementById('auxdistrito');
	
	//alert (textpro);
    //Iddestino.value=IauxIddestino.value;
	Idpais.value=IauxIdpais.value;
	Iddest.value=IauxIddest.value;
	Idmunicipio.value=IauxIdmunicipio.value;
	Iddistrito.value=IauxIddistrito.value;

	return true;
} 
function enviarformularios1(){ //funcion para enviar mas resultados

	var idform1=document.getElementById('form1');
	idpais=document.getElementById('pais');
	iddest=document.getElementById('dest');
	idfechaentrada=document.getElementById('fechaentrada');
	idnumero_de_noches=document.getElementById('numero_de_noches');
	iddestino=document.getElementById('destino');
	//alert (iddest.value);	
	if (iddest.value==""){
		alert ("Es necesario seleccionar un destino");
		iddestino.focus();
		return false;			
	}
	if (idfechaentrada.value==""  || idfechaentrada.value=="dd/mm/aaaa"){
		alert ("Es necesario indicar la fecha de entrada");
		idfechaentrada.focus();
		return false;			
	}
	if (idnumero_de_noches.value==""){
		alert ("Es necesario indicar el numero de noches");
		idnumero_de_noches.focus();
		return false;			
	}
		
	idform1.submit();
	return;

}
function enviarreserva(){ //funcion para enviar mas resultados

	var x = 1;
	
    //var x = valordepende.value 
	if (x ==0){
		alert ("Es necesario seleccionar una zona");
		formentrada.dest.focus();
		return false;	
	}
	
	form2.submit();
	//return (true);

}

function formulario_Validar(theForm)
{

  if (theForm.contacto.value == "")
  {
  alert("Es necesario introducir un nombre");
  theForm.contacto.focus();
  return (false);
  } 
  
  if (theForm.emailcontacto.value == "")
  {
  alert("Es obligatoria una dirección de e-mail");
  theForm.emailcontacto.focus();
  return (false);
  }
  if (theForm.asunto.value == "")
  {
  alert("Escriba el motivo");
  theForm.asunto.focus();
  return (false);
  }
  
  if (theForm.Contenido.value == "")
  {
  alert("Realice su consulta");
  theForm.Contenido.focus();
  return (false);
  }
  if (theForm.Contenido.value.length < 3)
  {
  alert("Realice su consulta");
  theForm.Contenido.focus();
  return (false);
  }

  if (theForm.emailcontacto.value.length < 5)
  {
  alert("Es obligatoria una dirección de e-mail");
  theForm.emailcontacto.focus();
  return (false);
  }

  return (true);
}
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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function abre(pag,ancho,alto)  {
  var parametro3=',resizable,width='+ancho+',height='+alto
  var ventana= window.open(pag,'_blank',parametro3);  
  ventana.opener = self;
  ventana.focus();           
}  
