/****************************************************************
/ Nombre: getHTTPObject
/ Implentacion: 
/ Revision: 301106
/ Descripcion: Manejo del AJAX
'***************************************************************/
function getHTTPObject() {
	var xmlhttp;      
  
  /*@cc_on
  @if (@_jscript_version >= 5)
	try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	  try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
		xmlhttp = false;
	  }
	}
  @else
  xmlhttp = false;
  @end @*/
  
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {  
		try {
		  xmlhttp = new XMLHttpRequest();
		} catch (e) {
		  xmlhttp = false;
		}
	}
	return xmlhttp;
}
    
//--
var http = getHTTPObject(); 


//************ SECCION PRODCUTOS **************************************************
//*********************************************************************************
function ampliaProducto(pagina,id,tipo,galeria){
	if (tipo == 1){
//		alert(tipo);
		var ref = document.getElementById("pk_info"+id).value;
		if (ref != ""){
			document.getElementById("formularioAmplia" + id).action = document.getElementById("formularioAmplia" + id).action + "&ref="+ref;
		}
	}
	document.getElementById("formularioAmplia" + id).numPagina.value=pagina
	document.getElementById("formularioAmplia" + id).numGaleria.value=galeria
	document.getElementById("formularioAmplia" + id).submit();
}


/****************************************************************
/ Nombre: Paginacion
/ Implentacion: 
/ Revision: 301106
/ Descripcion: funcion para realizar la paginacion de los productos
'***************************************************************/
function paginacion(pagina){
	document.getElementById("formularioPaginacion").numPagina.value=pagina
	document.getElementById("formularioPaginacion").submit();
}

function volverCatalogo(pagina){
	document.getElementById("formularioVolver").numPagina.value=pagina
	document.getElementById("formularioVolver").submit();
}


/****************************************************************
/ Nombre: cambiaFondo
/ Implentacion: JBernalte
/ Revision: 301106
/ Descripcion: Cambia el fondo del obj como ID
'***************************************************************/
function cambiaFondo(pagina, obj){
		var fondo;
		fondo="";
		switch(pagina){
			
			case 1: 
				fondo= "url(images/top-background-grupo.jpg)";
				break;
			default:
				fondo= "url(images/top-background.jpg)";
		}
		document.getElementById(obj).style.backgroundImage =fondo;
	}


/****************************************************************
/ Nombre: cambiaClaseFamilia
/ Implentacion
/ Revision: 301106
/ Descripcion: Cambia ela clase del obj pasado como ID
'***************************************************************/
function cambiaClaseFamilia(obj){
	
	switch(obj){
			
			case 1: 
				clase= "x";
				break;
			default:
				clase= "x";
		}
	
	document.getElementById(obj).className=clase;
}


function quitaClaseFamilia(familia,marcado){
	
	if (familia==1 && marcado==0){
		clase="x";
	}
	
	document.getElementById("familia" + familia).className=clase;
}

//****************** SECCION CONTACTO ******************************************************************************************************************************/

/****************************************************************
/ Nombre: validarEmail
/ Implentacion
/ Revision: 301106
/ Descripcion: Valida el formato del email
'***************************************************************/
function validarEmail(valor){
//funcion para validar el formato del email
	return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor));
	
}


function validarAsistencia(idioma){
//Funcion para la validar los datos enviados desde el formulario de contacto
	var texto,texto_en,texto_fr,texto_val;
	texto = "";
	texto_en = "";
	texto_fr = "";
	texto_val = "";
	texto_de = "";

	var cadenaEnvio;
	cadenaEnvio = "";
	
	//Aqui validamos que los campos obligatorios tengan valor y se añaden a la cadena de envio
	if (!document.getElementById('acepto').checked){
		texto+="- Debe aceptar los términos.<br>";
	}


	if ( document.getElementById("formularioAsistencia").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre.<br>";
		texto_en+=" * You must enter your name.<br>";
		texto_fr+=" * Vous devez indiquer votre nom.<br>";
		texto_val+=" * Deu indicar el seu nom.<br>";
		texto_de+=" * Ihren Namen bitte.\n";
	}else{
			if (!validarTexto(document.getElementById("formularioAsistencia").nombre.value)){
				texto+="* El nombre tiene carácteres no permitidos.<br>";
			} else {
				cadenaEnvio="nombre=" + document.getElementById("formularioAsistencia").nombre.value;
			}
	}
	
	if ( document.getElementById("formularioAsistencia").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.<br>";
		texto_en+=" * You must enter your e-mail.<br>";
		texto_fr+=" * Vous devez indiquer votre email.<br>";
		texto_val+=" * Deu indicar el seu e-mail.<br>";
		texto_de+=" * Ihre E-Mail Adresse bitte.\n";
	}
	
	if(document.getElementById("formularioAsistencia").email.value!=""){
		if(!validarEmail(document.getElementById("formularioAsistencia").email.value)){
				texto+=" * Formato de E-mail incorrecto.<br>";
				texto_en+=" * The E-mail format is wrong.<br>";
				texto_fr+=" * Format d'email incorrect.<br>";
				texto_val+=" * Format de E-mail incorrecte.<br>";
				texto_de+=" * E-Mail Format ist nicht richtig.\n";
		}else{
			if (!validarTexto(document.getElementById("formularioAsistencia").email.value)){
				texto+="* El E-mail tiene carácteres no permitidos.<br>";
			} else {
				cadenaEnvio+="&email=" + document.getElementById("formularioAsistencia").email.value;
			}
		}
	}
	if ( document.getElementById("formularioAsistencia").comentarios.value == "" ){
		texto+=" * Debe incluir el motivo de su consulta.<br>";
		texto_en+=" * You must enter your comments.<br>";
		texto_fr+=" * Vous devez indiquer l'objet de votre demande.<br>";
		texto_val+=" * Deu incloure el motiu de la seua consulta.<br>";
	}else{
			if (!validarTexto(document.getElementById("formularioAsistencia").comentarios.value)){
				texto+=" * El campo comentarios tiene carácteres no permitidos.<br>";
			} else {
				cadenaEnvio+="&comentarios=" + document.getElementById("formularioAsistencia").comentarios.value;
			}
	}	
	
	if ( document.getElementById("formularioAsistencia").telefono.value != "" ){
		cadenaEnvio+="&telefono=" + document.getElementById("formularioAsistencia").telefono.value;
	}
	
	if ( document.getElementById("formularioAsistencia").referencia.value == "" ){
		texto+=" * Debe indicar la referencia.<br>";
		texto_en+=" * You must enter your comments.<br>";
		texto_fr+=" * Vous devez indiquer l'objet de votre demande.<br>";
		texto_val+=" * Deu incloure el motiu de la seua consulta.<br>";
	}else{
			if (!validarTexto(document.getElementById("formularioAsistencia").referencia.value)){
				texto+=" * La referencia tiene carácteres no permitidos.<br>";
			} else {
				cadenaEnvio+="&referencia=" + document.getElementById("formularioAsistencia").referencia.value;
			}
	}	
	
	
/*	if(document.getElementById("formularioAsistencia").referencia.value!=""){
		if(!validarEmail(document.getElementById("formularioAsistencia").referencia.value)){
				texto+=" * Referencia incorrecta.<br>";
				texto_en+=" * Reference is wrong.<br>";
				texto_fr+=" * Format d'email incorrect.<br>";
				texto_val+=" * Format de E-mail incorrecte.<br>";
				texto_de+=" * E-Mail Format ist nicht richtig.\n";
		}else{
			cadenaEnvio+="&referencia=" + document.getElementById("formularioAsistencia").referencia.value;
		}
	}*/
		

	
	//Si falta algun campo obligatorio o el email no tiene un formato correcto
	//mostramos un mensaje de aviso
	
	if ( texto != "" ){
			switch (idioma) { 
				case 'en': 
					document.getElementById("mensajeError").innerHTML=texto_en;
				   break 
				case 'fr': 
					document.getElementById("mensajeError").innerHTML=texto_fr;
				   break 
				case 'val': 
					document.getElementById("mensajeError").innerHTML=texto_val;
				   break 
				case 'de': 
					document.getElementById("mensajeError").innerHTML=texto_de;
				   break 
				default: 
					document.getElementById("mensajeError").innerHTML=texto;
			} 
		document.getElementById("capaError").style.display='block';
		
	}else{
		//alert(cadenaEnvio);
		document.getElementById("mensaje-respuesta").innerHTML="";
		document.getElementById("mensajeError").innerHTML="";
		document.getElementById("capaError").style.display='none';
		http.open("GET", "actualizer/formcorreosMultiple/envioSinBd.asp?" + cadenaEnvio+"&seccion=K02", true);
		http.onreadystatechange = handleHttpResponseAsistencia;
		http.send(null);
	}
	
}


function handleHttpResponseAsistencia() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
//			alert(http.responseText);
		document.getElementById("mensaje-respuesta").innerHTML = http.responseText;	
		document.getElementById("formularioAsistencia").reset();
	}    
}

/****************************************************************
/ Nombre: validar
/ Implentacion
/ Revision: 301106
/ Descripcion: Valida los campos del formulario
'***************************************************************/
function validar(idioma){
//Funcion para la validar los datos enviados desde el formulario de contacto
	var texto,texto_en,texto_fr,texto_val;
	texto = "";
	texto_en = "";
	texto_fr = "";
	texto_val = "";
	texto_de = "";

	var cadenaEnvio;
	cadenaEnvio = "";
	
	//Aqui validamos que los campos obligatorios tengan valor y se añaden a la cadena de envio
	if (!document.getElementById('acepto').checked){
		texto+="- Debe aceptar los términos.<br>";
	}


	if ( document.getElementById("formularioContacto").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre.<br>";
		texto_en+=" * You must enter your name.<br>";
		texto_fr+=" * Vous devez indiquer votre nom.<br>";
		texto_val+=" * Deu indicar el seu nom.<br>";
		texto_de+=" * Ihren Namen bitte.\n";
	}else{
		if(!validarTexto(document.getElementById("formularioContacto").nombre.value)){
			texto+=" * El nombre tiene carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio="nombre=" + document.getElementById("formularioContacto").nombre.value;
		   }
	}
	
	if ( document.getElementById("formularioContacto").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.<br>";
		texto_en+=" * You must enter your e-mail.<br>";
		texto_fr+=" * Vous devez indiquer votre email.<br>";
		texto_val+=" * Deu indicar el seu e-mail.<br>";
		texto_de+=" * Ihre E-Mail Adresse bitte.\n";
	}
	
	if(document.getElementById("formularioContacto").email.value!=""){
		if(!validarEmail(document.getElementById("formularioContacto").email.value)){
				texto+=" * Formato de E-mail incorrecto.<br>";
				texto_en+=" * The E-mail format is wrong.<br>";
				texto_fr+=" * Format d'email incorrect.<br>";
				texto_val+=" * Format de E-mail incorrecte.<br>";
				texto_de+=" * E-Mail Format ist nicht richtig.\n";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formularioContacto").email.value;
		}
	}
	if ( document.getElementById("formularioContacto").comentarios.value == "" ){
		texto+=" * Debe incluir el motivo de su consulta.<br>";
		texto_en+=" * You must enter your comments.<br>";
		texto_fr+=" * Vous devez indiquer l'objet de votre demande.<br>";
		texto_val+=" * Deu incloure el motiu de la seua consulta.<br>";
	}else{
		if(!validarTexto(document.getElementById("formularioContacto").comentarios.value)){
			texto+=" * Los comentarios tienen carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio+="&comentarios=" + document.getElementById("formularioContacto").comentarios.value;
		  }
	}
	
	//Aqui vamos añadiendo los demas campos sino estan vacion
	
	if ( document.getElementById("formularioContacto").direccion.value != "" ){
		if(!validarTexto(document.getElementById("formularioContacto").direccion.value)){
			texto+=" * La dirección tiene carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio+="&direccion=" + document.getElementById("formularioContacto").direccion.value;
		   }
	}
	
	if ( document.getElementById("formularioContacto").poblacion.value != "" ){
		if(!validarTexto(document.getElementById("formularioContacto").poblacion.value)){
			texto+=" * La población tiene carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio+="&poblacion=" + document.getElementById("formularioContacto").poblacion.value;
		   }
	}
	
	if ( document.getElementById("formularioContacto").provincia.value != "" ){
		if(!validarTexto(document.getElementById("formularioContacto").provincia.value)){
			texto+=" * La provincia tiene carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio+="&provincia=" + document.getElementById("formularioContacto").provincia.value;
		   }
	}
	
	if ( document.getElementById("formularioContacto").telefono.value != "" ){
		if (isNaN(document.getElementById("formularioContacto").telefono.value)){ 
			texto+=" * El número de teléfono debe ser numérico.<br>";
		}
		else if(!validarTexto(document.getElementById("formularioContacto").telefono.value)){
				texto+=" * El teléfono tiene carácteres no válidos.<br>";
    	 	} else {
				cadenaEnvio+="&telefono=" + document.getElementById("formularioContacto").telefono.value;
		 	}
	}
		
	

	if ( document.getElementById("formularioContacto").cpostal.value != "" ){
		if ( isNaN(document.getElementById("formularioContacto").cpostal.value) ){
			texto+=" * El código postal debe ser numérico.<br>";
		} else if (document.getElementById("formularioContacto").cpostal.value.length > 5){
			texto+=" * El código postal debe tener un máximo de 5 dígitos.<br>";
				}
				else if(!validarTexto(document.getElementById("formularioContacto").cpostal.value)){
					texto+=" * El código postal tiene carácteres no válidos.<br>";
				}
					else {
						cadenaEnvio+="&cpostal=" + document.getElementById("formularioContacto").cpostal.value;
					}
	}

	if ( document.getElementById("formularioContacto").fax.value != "" ){
		if (isNaN(document.getElementById("formularioContacto").fax.value)){ 
			texto+=" * El fax debe ser numérico.<br>";
		}		
		else if(!validarTexto(document.getElementById("formularioContacto").fax.value)){
			texto+=" * El fax tiene carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio+="&fax=" + document.getElementById("formularioContacto").fax.value;
		 }
	}
	
	
	if ( document.getElementById("formularioContacto").movil.value != "" ){
		if (isNaN(document.getElementById("formularioContacto").movil.value)){ 
			texto+=" * El móvil debe ser numérico.<br>";
		}
		else if(!validarTexto(document.getElementById("formularioContacto").movil.value)){
				texto+=" * El móvil tiene carácteres no válidos.<br>";
    	 	} else {
				cadenaEnvio+="&movil=" + document.getElementById("formularioContacto").movil.value;
		 	}
		}
	

	//if ( document.getElementById("formularioContacto").pais2.value != "" ){
		cadenaEnvio+="&pais=" + document.getElementById("formularioContacto").pais.options[document.getElementById("formularioContacto").pais.selectedIndex].text
	//}
	
	//Si falta algun campo obligatorio o el email no tiene un formato correcto
	//mostramos un mensaje de avios
	
	if ( texto != "" ){
			switch (idioma) { 
				case 'en': 
					document.getElementById("mensajeError").innerHTML=texto_en;
				   break 
				case 'fr': 
					document.getElementById("mensajeError").innerHTML=texto_fr;
				   break 
				case 'val': 
					document.getElementById("mensajeError").innerHTML=texto_val;
				   break 
				case 'de': 
					document.getElementById("mensajeError").innerHTML=texto_de;
				   break 
				default: 
					document.getElementById("mensajeError").innerHTML=texto;
			} 
		document.getElementById("capaError").style.display='block';
		
	}else{
		//alert(cadenaEnvio);
		document.getElementById("mensaje-respuesta").innerHTML="";
		document.getElementById("mensajeError").innerHTML="";
		document.getElementById("capaError").style.display='none';
		http.open("GET", "actualizer/formcorreosMultiple/envioSinBd.asp?" + cadenaEnvio+"&seccion=K01", true);
		http.onreadystatechange = handleHttpResponseContacto;
		http.send(null);
	}
	
}


function validarForm(idioma){
//Funcion para la validar los datos enviados desde el formulario de contacto
	var texto,texto_en,texto_fr,texto_val;
	texto = "";
	texto_en = "";
	texto_fr = "";
	texto_val = "";
	texto_de = "";

	var cadenaEnvio;
	cadenaEnvio = "";
	
	//Aqui validamos que los campos obligatorios tengan valor y se añaden a la cadena de envio
	//if (!document.getElementById('acepto').checked){
	//	texto+="- Debe aceptar los términos.<br>";
	//}

	if ( document.getElementById("formNuevaAgencia").nombre.value == "" ) {
		texto+=" * Debe indicar el nombre de su agencia.<br>";
		texto_en+=" * You must enter your name.<br>";
		texto_fr+=" * Vous devez indiquer votre nom.<br>";
		texto_val+=" * Deu indicar el seu nom.<br>";
		texto_de+=" * Ihren Namen bitte.\n";
	}else{
		if(!validarTexto(document.getElementById("formNuevaAgencia").nombre.value)){
			texto+=" * El nombre tiene carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio="nombre=" + document.getElementById("formNuevaAgencia").nombre.value;
		 }
	}

	if ( document.getElementById("formNuevaAgencia").direccion.value == "" ) {
		texto+=" * Debe indicar la dirección de su agencia.<br>";
		texto_en+=" * You must enter your name.<br>";
		texto_fr+=" * Vous devez indiquer votre nom.<br>";
		texto_val+=" * Deu indicar el seu nom.<br>";
		texto_de+=" * Ihren Namen bitte.\n";
	}else{
		if(!validarTexto(document.getElementById("formNuevaAgencia").direccion.value)){
			texto+=" * La dirección tiene carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio+="&direccion=" + document.getElementById("formNuevaAgencia").direccion.value;
		 }
	}

	if ( document.getElementById("formNuevaAgencia").grupo.value == "" ) {
		texto+=" * Debe indicar el grupo.<br>";
		texto_en+=" * You must enter your name.<br>";
		texto_fr+=" * Vous devez indiquer votre nom.<br>";
		texto_val+=" * Deu indicar el seu nom.<br>";
		texto_de+=" * Ihren Namen bitte.\n";
	}else{
		if(!validarTexto(document.getElementById("formNuevaAgencia").grupo.value)){
			texto+=" * El grupo tiene carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio+="&grupo=" + document.getElementById("formNuevaAgencia").grupo.value;
		 }
	}

	if ( document.getElementById("formNuevaAgencia").email.value == "" ) {
		texto+=" * Debe indicar el e-mail.<br>";
		texto_en+=" * You must enter your e-mail.<br>";
		texto_fr+=" * Vous devez indiquer votre email.<br>";
		texto_val+=" * Deu indicar el seu e-mail.<br>";
		texto_de+=" * Ihre E-Mail Adresse bitte.\n";
	}
	
	if(document.getElementById("formNuevaAgencia").email.value!=""){
		if(!validarEmail(document.getElementById("formNuevaAgencia").email.value)){
				texto+=" * Formato de E-mail incorrecto.<br>";
				texto_en+=" * The E-mail format is wrong.<br>";
				texto_fr+=" * Format d'email incorrect.<br>";
				texto_val+=" * Format de E-mail incorrecte.<br>";
				texto_de+=" * E-Mail Format ist nicht richtig.\n";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formNuevaAgencia").email.value;
		}
	}
	
	//Aqui vamos añadiendo los demas campos sino estan vacioa

	if ( document.getElementById("formNuevaAgencia").comentarios.value != "" ){
		if(!validarTexto(document.getElementById("formNuevaAgencia").comentarios.value)){
			texto+=" * Los comentarios tiene carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio+="&comentarios=" + document.getElementById("formNuevaAgencia").comentarios.value;
		 }
	}

	if ( document.getElementById("formNuevaAgencia").amadeus[0].checked ){
		cadenaEnvio+="&amadeus=" + document.getElementById("formNuevaAgencia").amadeus[0].value;
	}
	if ( document.getElementById("formNuevaAgencia").amadeus[1].checked ){
		cadenaEnvio+="&amadeus=" + document.getElementById("formNuevaAgencia").amadeus[1].value;
	}
	
	if ( document.getElementById("formNuevaAgencia").iata[0].checked){
		cadenaEnvio+="&iata=" + document.getElementById("formNuevaAgencia").iata[0].value;
	}
	if ( document.getElementById("formNuevaAgencia").iata[1].checked){
		cadenaEnvio+="&iata=" + document.getElementById("formNuevaAgencia").iata[1].value;
	}
	
	if ( document.getElementById("formNuevaAgencia").telefono.value != "" ){
		if (isNaN(document.getElementById("formNuevaAgencia").telefono.value)){ 
			texto+=" * El número de teléfono debe ser numérico.<br>";
		}
		else if(!validarTexto(document.getElementById("formNuevaAgencia").telefono.value)){
				texto+=" * El teléfono tiene carácteres no válidos.<br>";
    	 	} else {
				cadenaEnvio+="&telefono=" + document.getElementById("formNuevaAgencia").telefono.value;
		 	}
		}
	

	if ( document.getElementById("formNuevaAgencia").cpostal.value != "" ){
		if ( isNaN(document.getElementById("formNuevaAgencia").cpostal.value) ){
			texto+=" * El código postal debe ser numérico.<br>";
		} else if (document.getElementById("formNuevaAgencia").cpostal.value.length > 5){
			texto+=" * El código postal debe tener un máximo de 5 dígitos.<br>";
				}
				else if(!validarTexto(document.getElementById("formNuevaAgencia").cpostal.value)){
					texto+=" * El código postal tiene carácteres no válidos.<br>";
				}
					else {
						cadenaEnvio+="&cpostal=" + document.getElementById("formNuevaAgencia").cpostal.value;
					}
	}

	if ( document.getElementById("formNuevaAgencia").fax.value != "" ){
		if (isNaN(document.getElementById("formNuevaAgencia").fax.value)){ 
			texto+=" * El fax debe ser numérico.<br>";
		}		
		else if(!validarTexto(document.getElementById("formNuevaAgencia").fax.value)){
			texto+=" * El fax tiene carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio+="&fax=" + document.getElementById("formNuevaAgencia").fax.value;
		 }
	}

	if ( document.getElementById("formNuevaAgencia").contacto1.value != "" ){
		if(!validarTexto(document.getElementById("formNuevaAgencia").contacto1.value)){
			texto+=" * El contacto tiene carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio+="&contacto1=" + document.getElementById("formNuevaAgencia").contacto1.value;
		 }
	}

	if ( document.getElementById("formNuevaAgencia").cif.value != "" ){
		if(!validarTexto(document.getElementById("formNuevaAgencia").cif.value)){
			texto+=" * El cif tiene carácteres no válidos.<br>";
    	 } else {
			cadenaEnvio+="&cif=" + document.getElementById("formNuevaAgencia").cif.value;
		 }
	}


	//if ( document.getElementById("formularioContacto").pais2.value != "" ){
		//cadenaEnvio+="&pais=" + document.getElementById("formularioContacto").pais.options[document.getElementById("formularioContacto").pais.selectedIndex].text
	//}
	
	//Si falta algun campo obligatorio o el email no tiene un formato correcto
	//mostramos un mensaje de avios
	
	if ( texto != "" ){
			switch (idioma) { 
				case 'en': 
					document.getElementById("mensajeError").innerHTML=texto_en;
				   break 
				case 'fr': 
					document.getElementById("mensajeError").innerHTML=texto_fr;
				   break 
				case 'val': 
					document.getElementById("mensajeError").innerHTML=texto_val;
				   break 
				case 'de': 
					document.getElementById("mensajeError").innerHTML=texto_de;
				   break 
				default: 
					document.getElementById("mensajeError").innerHTML=texto;
			} 
		document.getElementById("capaError").style.display='block';
		
	}else{
		//alert(cadenaEnvio);
		document.getElementById("mensaje-respuesta").innerHTML="";
		document.getElementById("mensajeError").innerHTML="";
		document.getElementById("capaError").style.display='none';
		http.open("GET", "actualizer/formcorreosMultiple/envioAgencias.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseNuevaAgencia;
		http.send(null);
	}
	
}




/****************************************************************
/ Nombre: cerrarAviso
/ Implentacion: 

/ Revision:
/ Descripcion: Cierra la capa del aviso del formulario
'***************************************************************/
function cerrarAviso(){
	document.getElementById("mensajeError").innerHTML="";
	document.getElementById("capaError").style.display='none';
}

function handleHttpResponseContacto() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
//			alert(http.responseText);
		document.getElementById("mensaje-respuesta").innerHTML = http.responseText;	
		document.getElementById("formularioContacto").reset();
	}    
}

function handleHttpResponseNuevaAgencia() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
//			alert(http.responseText);
		document.getElementById("mensaje-respuesta").innerHTML = http.responseText;	
		document.getElementById("formNuevaAgencia").reset();
	}    
}

/****************************************************************
/ Nombre: validar
/ Implentacion
/ Revision: 301106
/ Descripcion: Valida los campos del formulario
'***************************************************************/
function validarIns(tipo){
//Funcion para la validar los datos enviados desde el formulario de contacto
	var texto;
	texto = "";

	var cadenaEnvio;
	cadenaEnvio = "";
	
	//Aqui validamos que los campos obligatorios tengan valor y se añaden a la cadena de envio
	
/*	if ( document.getElementById("formRegistro").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre.\n";
	}else{
		cadenaEnvio="nombre=" + document.getElementById("formRegistro").nombre.value;
	}*/
	
	if ( document.getElementById("formRegistro").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.\n";
	}
	
	if(document.getElementById("formRegistro").email.value!=""){
		if(!validarEmail(document.getElementById("formRegistro").email.value)){
				texto+=" * Formato de E-mail incorrecto.\n";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formRegistro").email.value;
		}
	}
	if (( document.getElementById("formRegistro").telefono.value != "" ) && ( isNaN(document.getElementById("formRegistro").telefono.value)) ){
		document.getElementById("formRegistro").telefono.value = ""
		document.getElementById("formRegistro").telefono.focus();
		texto+=" * El número de teléfono debe ser numérico.\n";
	}
	if (( document.getElementById("formRegistro").movil.value != "" ) && ( isNaN(document.getElementById("formRegistro").movil.value)) ){
		document.getElementById("formRegistro").movil.value = ""
		document.getElementById("formRegistro").movil.focus();
		texto+=" * El número de móvil debe ser numérico.\n";
	}
	if ( isNaN(document.getElementById("formRegistro").cpostal.value) ){
		document.getElementById("formRegistro").cpostal.value = ""
		document.getElementById("formRegistro").cpostal.focus();
		texto+=" * El código postal debe ser numérico.\n";
	}

	if ( document.getElementById("formRegistro").nick.value == "" ) {
		texto+=" * Debe indicar su nick.\n";
	}else if ( document.getElementById("formRegistro").nick.value.length < 4 ) {
				texto+=" * El nick debe ser de al menos 4 carácteres.\n";
	}
	if ( document.getElementById("formRegistro").dia.value == "0" ) {
		texto+=" * Debe seleccionar el día de su fecha de nacimiento.\n";
	}
	if ( document.getElementById("formRegistro").mes.value == "0" ) {
		texto+=" * Debe seleccionar el mes de su fecha de nacimiento.\n";
	}
	if ( document.getElementById("formRegistro").anyo.value == "0" ) {
		texto+=" * Debe seleccionar el año de su fecha de nacimiento.\n";
	}
	
	//para controlar que las fechas sean correctas
	var dia, mes, anyo;
	
	dia = document.getElementById('formRegistro').dia.value;
	mes = document.getElementById('formRegistro').mes.value;
	anyo = document.getElementById('formRegistro').anyo.value;
	
	if (!compruebaFecha(dia, mes, anyo)){
		texto+=" * La fecha intorducida es incorrecta.\n";
	}

		cadenaEnvio+="&=" + document.getElementById("formRegistro").preferencias.value;

	if ( document.getElementById("formRegistro").condiciones.checked == false ) {
		texto+=" * Debe aceptar las condiciones legales para registrarse.\n";
	}
	
	var email = document.getElementById("formRegistro").email.value;
	var nick = document.getElementById("formRegistro").nick.value;
	
		if ( texto != "" ){
				alert(texto);
		}else{
			http.open("GET", "registro/compruebaEmail.asp?email=" + email +"&nick=" + nick, true);
			http.onreadystatechange = handleHttpResponseComprobar;
			http.send(null);
		}
	
	
}

function handleHttpResponseComprobar() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
			var t =  http.responseText;	
		if ( t != "" ){
				alert(t);
		}else{
				document.getElementById("formRegistro").op.value = 0;
				document.formRegistro.submit();
		}
	}    
}


/****************************************************************
/ Nombre: compruebaFecha()
/ Implentacion: Fperez

/ Revision:
/ Descripcion: Comprueba que las fechas sean correctas
'***************************************************************/
function compruebaFecha(dia, mes, anyo){
	var error;
	if ((dia > 30) && ((mes == 2) || (mes == 4) || (mes == 6) || (mes == 9) || (mes == 11))){
		return false;
	}
	if ((dia > 29) && (mes == 2)){
		return false;
	}
	var resto = parseInt(anyo)%4;
	if (resto != 0){
		if ((dia > 28) && (mes == 2)){
			return false;
		}
	}
	
	return true;
}




/*********************************************************************************
/ Nombre: mostrarReferencia
/ Implentacion: FPEREZ
/ Revision: 05-10-07
/ Descripcion: Cambia el precio y los datos de cada referencia
*********************************************************************************/
function mostrarReferencia(id){
		if (document.getElementById("pk_info"+id).value == ""){
			document.getElementById("referencia").innerHTML = "";
			document.getElementById("referencia").style.display = "block";	
			return false;
		}
		var idReferencia = document.getElementById("pk_info"+id).value;
		document.getElementById("enlace_"+id).href = document.getElementById("enlace_"+id).href + "&ref=" + idReferencia
		document.getElementById("enlace_imagen_"+id).href = document.getElementById("enlace_imagen_"+id).href + "&ref=" + idReferencia
		document.getElementById("enlace_titulo_"+id).href = document.getElementById("enlace_titulo_"+id).href + "&ref=" + idReferencia
		http.open("GET", "./includes/getReferencia.asp?id=" + idReferencia, true);
		http.onreadystatechange = handleHttpResponseReferencia;
		http.send(null);
	
}

function handleHttpResponseReferencia() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		var contenido = http.responseText.split("|");
		var id = contenido[1];
		
		if (contenido[0] != ""){
			document.getElementById("precio_referencia"+id).innerHTML = "POR&nbsp;<big><big><b>" +  contenido[0] + "</b></big></big>&nbsp;&euro;";	
		}
		document.getElementById("precio_referencia"+id).style.display = "block";	
	}    
}



/****************************************************************
/ Nombre: openWindow
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Abre un popup
'***************************************************************/
	function openWindow(theURL,winName,features){
 		window.open(theURL,winName,features);
		return
	}


/****************************************************************
/ Nombre: muestraTema
/ Implentacion:
/ Revision:
/ Descripcion: Muestra los temas
'***************************************************************/
function muestraTema(id,numero) {
	for (i=1;i<=numero;i++){
		if (id != i){
			if (document.getElementById("filaContenidoTema"+ i).style.display == "block"){
				document.getElementById("filaContenidoTema"+ i).style.display = "none";
			}
				document.getElementById("enlaceTema"+ i).className = "desmarcado";
		}
	}
	if (document.getElementById("filaContenidoTema"+ id).style.display == "block") { 
		document.getElementById("filaContenidoTema"+ id).style.display = "none"; }
	else { 
		document.getElementById("filaContenidoTema"+ id).style.display = "block";
		document.getElementById("enlaceTema"+ id).className = "marcado";
		}
}


/****************************************************************
/ Nombre: muestraTema
/ Implentacion:
/ Revision:
/ Descripcion: Muestra los temas
'***************************************************************/
function muestraTemaMapa(id) {

	
	window.location.href="index.asp?pagina=buscar-agencias&c=" + id;
}


/****************************************************************
/ Nombre: capaPosition
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Posiciona una capa en el centro de la pantalla +- los pixeles deseados
'***************************************************************/
function capaPosition(layer, position){
		element = document.getElementById(layer);
		screenCenterX = document.body.clientWidth / 2;
		element.style.left = screenCenterX + position;
		element.style.display = 'inline';
	}


/****************************************************************************************
/ Nombre: ampliaImagen
/ Implentacion: PACO
/ Revision:
/ Descripcion: Muestra el PopUp de ampliacion de las imagenes y lo redimensiona
'***************************************************************************************/
function ampliaImagen(url){
	document.getElementById('imagenAmpliada').src = "images/" + url;
	}

function redimensionarImagen(img){
	var anchoImagen,altoImagen,anchoPantalla,altoPantalla;
	img1 = new Image(); 
	img1.src = img.src;
	anchoImagen = img1.width;
	altoImagen = img1.height;
//	anchoPantalla = window.screen.width;
	anchoPantalla = 930
	altoPantalla = window.screen.height - 240;
	posicionx = (anchoPantalla/2) - (anchoImagen/2);
	posiciony = (altoPantalla/2) - (altoImagen/2);
	
	// coloca la capa de la imagen y la redimensiona
	document.getElementById('capaImagenAmpliada').style.top = posiciony + 'px';
	document.getElementById('capaImagenAmpliada').style.left = posicionx + 'px';
	document.getElementById('capaImagenAmpliada').style.width = anchoImagen + 'px';
	document.getElementById('capaImagenAmpliada').style.height = altoImagen + 'px';
	// coloca un poco más arriba la capa del enlace para cerrar
	posicionCerrar = posiciony - 19;
	document.getElementById('cerrarImagenAmpliada').style.top = posicionCerrar + 'px';
	document.getElementById('cerrarImagenAmpliada').style.left = posicionx + 'px';

	document.getElementById('capaImagenAmpliada').style.display = 'block';
	document.getElementById('cerrarImagenAmpliada').style.display = 'block';
	// en caso del formulario de contacto, ocultamos el combo
	document.getElementById('pais').style.visibility = 'hidden';
}

function cerrarImagenAmpliada(){
	document.getElementById('imagenAmpliada').src = "";
	document.getElementById('capaImagenAmpliada').style.display = 'none';
	document.getElementById('cerrarImagenAmpliada').style.display = 'none';
	document.getElementById('pais').style.visibility = 'visible';
}
//***************************************************************************
//***************************************************************************



/****************************************************************************************
/ Nombre: autentifica
/ Implentacion: JBERNALTE
/Parametros: [Type] (off) desautentifica (otra cosa) autentifica
/ Revision:
/ Descripcion: Login de usuario en la zona privada
'***************************************************************************************/
function autentifica(type){
	var strEnvio = '';
	if(type != 'off'){
		
		var campos = new Array();
		var mensajes = new Array();
		
		
		/* DENINE CAMPO A VALIDAR MENSAJE*/
		campos[0] = 'user'; mensajes[0] = 'Indique su usuario';
		campos[1] = 'password'; mensajes[1] = 'Indique su contraseña';
	
		
		valid = false; 
		i=0;
		
		for(campo in campos){
			valor = document.formLogin[campo].value;
			if (   (valor == '') || (valor == mensajes[i])  ) {
				document.formLogin[campo].value = mensajes[i];
				valid = false;
			}else{
				strEnvio += "" + campos[i] + "=" + document.formLogin[campo].value + "&";
				valid = true;
			}
			i++;
		}
		strEnvio += "login=on"
	}else{
		valid=true;
		strEnvio += "login=off"
		
	}
	
	
	
	if(valid){
//		window.location.href = "includes/loginEngine.asp?" + strEnvio;
		url = "includes/loginEngine.asp?" + strEnvio;
		
		http.open("GET", url , true);
		http.onreadystatechange = handleHttpResponseReload;
		http.send(null);		
	}else{
		return false;	
	}	
}


/****************************************************************************************
/ Nombre: autentifica
/ Implentacion: JBERNALTE
/Parametros: [Type] (off) desautentifica (otra cosa) autentifica
/ Revision:
/ Descripcion: Login de usuario en la zona privada
'***************************************************************************************/
function autentifica2(type){
	
	
	var strEnvio = '';
	
	if(type != 'off'){
		
		var campos = new Array();
		var mensajes = new Array();
		
		
		/* DENINE CAMPO A VALIDAR MENSAJE*/
		campos[0] = 'user'; mensajes[0] = 'Indique su usuario';
		campos[1] = 'password'; mensajes[1] = 'Indique su contraseña';
	
		
		valid = false; 
		i=0;
		
		for(campo in campos){
			valor = document.formLogin2[campo].value;
					if(!validarTexto(valor)){
						alert("Uno de los campos tiene carácteres no válidos.");	
						return;
			    	 } else {

						if (   (valor == '') || (valor == mensajes[i])  ) {
							document.formLogin2[campo].value = mensajes[i];
							valid = false;
						}else{
							strEnvio += "" + campos[i] + "=" + document.formLogin2[campo].value + "&";
							valid = true;
						}
						i++;
						 
					 }
		}
		strEnvio += "login=on"
	}else{
		valid=true;
		strEnvio += "login=off"
		
	}
	if(valid){
//		window.location.href = "includes/loginEngine.asp?" + strEnvio;
		url = "includes/loginEngine.asp?" + strEnvio;
		http.open("GET", url , true);
		http.onreadystatechange = handleHttpResponseReload;
		http.send(null);		
	}else{
		return false;	
	}	
}

function autentificaFlash(user, pass) {
//	alert(user); 
//	alert(pass);
	if (user=="" && pass==""){
		url = "includes/loginEngine.asp?login=off";
		http.open("GET", url , true);
		http.onreadystatechange = handleHttpResponseReloadFlash;
		http.send(null);
	}else{
		url = "includes/loginEngine.asp?login=on&user=" + user + "&password=" + pass;
		http.open("GET", url , true);
		http.onreadystatechange = handleHttpResponseReloadFlash;
		http.send(null);	
	}	
}


/****************************************************************************************
/ Nombre: edit, handleHttpResponseEdit
/ Implentacion: JBERNALTE
/Parametros: [Type] (off) previsualiza (otra cosa) edita
/ Revision:
/ Descripcion: Cambia a modo edicion en la zona privada
'***************************************************************************************/
function edit(type){
	var strEnvio = '';
	

		strEnvio += "edicionMode=" + type;


		url = "includes/loginEngine.asp?" + strEnvio;
		http.open("GET", url , true);
		http.onreadystatechange = handleHttpResponseReload;
		http.send(null);		
}


/****************************************************************************************
/ Nombre: edit, handleHttpResponseReload
/ Implentacion: JBERNALTE
/ Revision:13/06/2007
/ Descripcion: Recarga la pagina despues de ejecutar AJAX
'***************************************************************************************/
function handleHttpResponseReload() {
	if (http.readyState == 4) {
		//window.location.reload();
		var respuesta=http.responseText;
		
		
		
		if (respuesta=="no"){
			document.getElementById("mensaje-alerta").style.display='block';
		}
		if (respuesta=="si"){
			var pagina=document.getElementById("login").pagina.value;
			var subpagina=document.getElementById("login").subpagina.value;
			var c=document.getElementById("login").c.value;
			document.location="index.asp?pagina=" + pagina + "&subpagina=" + subpagina + "&c=" + c;
		}
		
		if (respuesta=="cierra"){
//			document.location="index.asp?pagina=" + pagina + "&subpagina=" + subpagina + "&c=" + c;
			document.location="index.asp?pagina=profesionales";
		}
	}    
}

function handleHttpResponseReloadFlash() {
	if (http.readyState == 4) {
		//window.location.reload();
		var respuesta=http.responseText;
		if (respuesta=="no"){
			//document.getElementById("mensaje-alerta").style.display='block';
		}
		if (respuesta=="salir"){
			document.location="index.asp?pagina=home";
		}
		if (respuesta=="si"){
			//var pagina=document.getElementById("login").pagina.value;
			//var subpagina=document.getElementById("login").subpagina.value;
			//var c=document.getElementById("login").c.value;
			document.location.href ="index.asp?pagina=zona-privada";
		}
	}    
}
/****************************************************************************************
/ Nombre: edit, handleHttpResponseEdit
/ Implentacion: JBERNALTE
/Parametros: [Type] (off) previsualiza (otra cosa) edita
/ Revision:
/ Descripcion: Cambia a modo edicion en la zona privada
'***************************************************************************************/
function edit2(type){
	var strEnvio = '';
	

		strEnvio += "edicionMode=" + type;


		url = "includes/loginEngine.asp?" + strEnvio;
		http.open("GET", url , true);
		http.onreadystatechange = handleHttpResponseReload2;
		http.send(null);		
}


/****************************************************************************************
/ Nombre: edit, handleHttpResponseReload
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Recarga la pagina despues de ejecutar AJAX
'***************************************************************************************/
function handleHttpResponseReload2() {
	if (http.readyState == 4) {
		window.location.href= "index.asp?pagina=ficha-de-usuario";
	}    
}



/****************************************************************************************
/ Nombre: changeAccountData, handleHttpResponseAccount
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Actualiza los datos del usuario
'***************************************************************************************/
function changeAccount(type){
	
	alert("GUAU! ( o )( o )");
	
	
	strEnvio='';
	
	//FALTA MONTAR EL ENVIO
	
	if(type == 'new'){
		strEnvio += "account=new"
	}else{
		strEnvio += "account=update"
	}
	
	url = "includes/AccountEngine.asp?" + strEnvio;
	http.open("GET", url , true);
	http.onreadystatechange = handleHttpResponseAccount;
	http.send(null);
}


function handleHttpResponseAccount() {
	if (http.readyState == 4) {    	
		document.getElementById("resultado").innerHTML = http.responseText;
	}    
}

/****************************************************************************************
/ Nombre: changePicture
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Cambia una imagen
'***************************************************************************************/
function changePicture(id, picture){
		
		document.getElementById(id).src = picture;
}

function muestraCapa(){
	document.getElementById('recordarPassword').style.display = 'block';
}
/****************************************************************************************
/ Nombre: enviarEmail
/ Implentacion: Fperez
/ Revision:
/ Descripcion: Envia el recordatorio de la contraseña por email
'***************************************************************************************/
function enviarEmail(email){
//	alert(document.formrecuerdo.email.value);
		cadenaEnvio = 'email='+document.formrecuerdo.email.value;
		http.open("GET", "actualizer/formcorreosMultiple/envioEmail.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseEmail;
		http.send(null);
}
function handleHttpResponseEmail() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		document.getElementById("recordarPassword").style.display = 'none';	
		document.getElementById("respuestaRecuerdo").style.display = 'block';	
		document.getElementById("respuestaRecuerdo").innerHTML = http.responseText;	
		document.getElementById("formrecuerdo").reset();
	}    
}



/****************************************************************************************
/ Nombre: submenuPosition
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Central el menu a partir del centro de la resolucion de pantalla
'***************************************************************************************/

	function submenuPosition(layer, position){
		subMenuHide();
		
		element = document.getElementById(layer);
		screenCenterX = document.body.clientWidth / 2;
		element.style.left = screenCenterX + position;
		element.style.display = 'inline';
		
		
	}
	

/****************************************************************************************
/ Nombre: subMenuHide
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Oculta el submenu, necesitamos definir cuantos existen
'***************************************************************************************/
	function subMenuHide(){
		
		cuantos = 4;
		
		//OCULTAMOS TODOS
		for(i=1; i<=cuantos; i++){
			document.getElementById('submenu' + i).style.display = "none";
		}

	}
	
	
/****************************************************************************************
/ Nombre: buscadorWeb
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Envia el formulario de busqueda
'***************************************************************************************/
function searchOnWeb(){			
	if (document.getElementById("textobusqueda").value.length<1){
		alert("Introduzca el texto de búsqueda");
	}
	else{
		document.getElementById("busqueda").cadenaBusqueda.value=document.getElementById("textobusqueda").value
		document.getElementById("busqueda").submit()
	}				
}





/****************************************************************
/ Nombre: validarvalidarSuscripcion
/ Implentacion: Fperez
/ Revision: 11-07-07
/ Descripcion: Valida los campos del formulario de suscripcion
'***************************************************************/
function validarSuscripcion2(idioma){

	
	var texto,texto_en,texto_fr,texto_val,texto_de;
	texto = "";
	texto_en = "";
	texto_fr = "";
	texto_val = "";
	texto_de = "";

	if ( document.getElementById("formularioSuscripcion").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre.<br>";
		texto_en+=" * You must enter your name.<br>";
		texto_fr+=" * Vous devez indiquer votre nom.<br>";
		texto_val+=" * Deu indicar el seu nom.<br>";
		texto_de+=" * Ihren Namen bitte.<br>";
	}else{
		cadenaEnvio="nombre=" + document.getElementById("formularioSuscripcion").nombre.value;
	}
	
	if ( document.getElementById("formularioSuscripcion").email.value == "" ) {
		texto+=" - Debe indicar su email.<br>";
		texto_en+=" * You must enter your e-mail.<br>";
		texto_fr+=" * Vous devez indiquer votre email.<br>";
		texto_val+=" * Deu indicar el seu e-mail.<br>";
		texto_de+=" * Ihre E-Mail Adresse bitte.<br>";
	}
	
	if(document.getElementById("formularioSuscripcion").email.value!=""){
		if(!validarEmail(document.getElementById("formularioSuscripcion").email.value)){
				texto+=" * Formato de E-mail incorrecto.<br>";
				texto_en+=" * The E-mail format is wrong.<br>";
				texto_fr+=" * Format d'email incorrect.<br>";
				texto_val+=" * Format de E-mail incorrecte.<br>";
				texto_de+=" * E-Mail Format ist nicht richtig.<br>";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formularioSuscripcion").email.value;
		}
	}
	//alert(cadenaEnvio);

	if (texto!=""){
		document.getElementById("textoSuscripcion").innerHTML="";

			switch (idioma) { 
				case 'en': 
					document.getElementById("textoSuscripcion").innerHTML=texto_en;
				   break 
				case 'fr': 
					document.getElementById("textoSuscripcion").innerHTML=texto_fr;
				   break 
				case 'val': 
					document.getElementById("textoSuscripcion").innerHTML=texto_val;
				   break 
				case 'de': 
					document.getElementById("textoSuscripcion").innerHTML=texto_de;
				   break 
				default: 
					document.getElementById("textoSuscripcion").innerHTML=texto;
			} 
		document.getElementById("textoSuscripcion").style.display="block";
	}else{
		
		http.open("GET", "actualizer/suscripcion/suscripcion.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseSuscripcion;
		http.send(null);
	}	
}


function validarSuscripcion(idioma)
{
	
	
	var texto,texto_en,texto_fr,texto_val,texto_de,cerrar;
	texto = "";
	texto_en = "";
	texto_fr = "";
	texto_val = "";
	texto_de = "";
	
	if (document.getElementById("formularioSuscripcion").nombre.value== "" )
	{
		texto+=" * Debe indicar su nombre<br>";
		texto_en+=" * You must enter your name.<br>";
		texto_fr+=" * Vous devez indiquer votre nom.<br>";
		texto_val+=" * Deu indicar el seu nom.<br>";
		texto_de+=" * Ihren Namen bitte.<br>";
		cerrar ="1";
	}
	else
	{
			if (!validarTexto(document.getElementById("formularioSuscripcion").nombre.value)){
				texto+=" * El nombre tiene carácteres no permitidos.<br>";
			} else {
				cadenaEnvio="nombre=" + document.getElementById("formularioSuscripcion").nombre.value;
			}
	}
//	alert(cadenaEnvio)
	if (document.getElementById("formularioSuscripcion").email.value == "" ) {
		if (cerrar == "0")
		{
			texto+="<div align='right'><a href='javascript:cerrarAvisosuscripcion();' style='color:#990000;font-weight:bold;'>[x]</a></div><br>* Debe indicar su email.<br> ";
		}
		else
		{
			texto+="* Debe indicar su email.<br>"	
		}
		texto_en+=" * You must enter your e-mail.<br>";
		texto_fr+=" * Vous devez indiquer votre email.<br>";
		texto_val+=" * Deu indicar el seu e-mail.<br>";
		texto_de+=" * Ihre E-Mail Adresse bitte.<br>";
		cerrar ="1";
	}

	if(document.getElementById("formularioSuscripcion").email.value != "")
	{
		if(!validarEmail(document.getElementById("formularioSuscripcion").email.value))
		{
			if (cerrar == "0")
			{
				texto+="<div align='right'><a href='javascript:cerrarAvisosuscripcion();' style='color:#990000;font-weight:bold;'>[x]</a></div> <br>* Formato de E-mail incorrecto.<br>";
			}
			else
			{
				texto+="* Formato de E-mail incorrecto<br>"	
			}
			texto_en+=" * The E-mail format is wrong.<br>";
			texto_fr+=" * Format d'email incorrect.<br>";
			texto_val+=" * Format de E-mail incorrecte.<br>";
			texto_de+=" * E-Mail Format ist nicht richtig.<br>";
			cerrar ="1";
		}
		else
		{
			if (!validarTexto(document.getElementById("formularioSuscripcion").email.value)){
				texto+=" * El E-mail tiene carácteres no permitidos.<br>";
			} else {
			   cadenaEnvio+="&email=" + document.getElementById("formularioSuscripcion").email.value;
			}
		}
	}
//	alert(cadenaEnvio)
	//alert(texto)
	if (texto != ""){
		document.getElementById("textoSuscripcion").innerHTML="";
			switch (idioma)
			{ 
				case 'en': 
					document.getElementById("textoSuscripcion").innerHTML=texto_en;
				   break 
				case 'fr': 
					document.getElementById("textoSuscripcion").innerHTML=texto_fr;
				   break 
				case 'val': 
					document.getElementById("textoSuscripcion").innerHTML=texto_val;
				   break 
				case 'de': 
					document.getElementById("textoSuscripcion").innerHTML=texto_de;
				   break 
				default: 
					document.getElementById("textoSuscripcion").innerHTML=texto;
			} 
		document.getElementById("textoSuscripcion").style.display="block";
		
	}else{
		document.getElementById("textoSuscripcion").style.display="none";
		document.getElementById("textoSuscripcion").innerHTML="";
		http.open("GET", "actualizer/suscripcion/suscripcion.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseSuscripcion;
		http.send(null);
		//document.getElementById("textoSuscripcion1").style.display="block";
	}	
}

function cerrarAvisosuscripcion(){
	/*document.getElementById("mensajeError").innerHTML="";*/
	document.getElementById("textoSuscripcion").style.display='none';
}

function handleHttpResponseSuscripcion() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		//alert(http.responseText);
		document.getElementById("textoSuscripcion").innerHTML = http.responseText;
		document.getElementById("textoSuscripcion").style.display="block";
		document.getElementById("formularioSuscripcion").reset();
	}    
}
function blanco(){
	if (document.getElementById('nombre').value == ' nombre') {
		document.getElementById('nombre').value = '';
	}
	if (document.getElementById('email').value == ' e-mail') {
		document.getElementById('email').value = '';
	}
}



/****************************************************************************************
/ Nombre: getProvincia
/ Implentacion: JDolz
/ Revision:
/ Descripcion: recoje el id de la provincia y muestra el contenido
'***************************************************************************************/
function getProvincia(provincia){
	
	http.open("GET", "includes/getDistribuidores.asp?provincia=" + provincia , true);
	http.onreadystatechange = handleHttpResponseDistribuidor;
	http.send(null);
}
function handleHttpResponseDistribuidor() {
	if (http.readyState == 4) { //   alert(http.responseText);	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		document.location = http.responseText;	
	}    
}


/****************************************************************
/ Nombre: validarContacto
/ Implentacion
/ Revision: 301106
/ Descripcion: Valida los campos del formulario de contacto
'***************************************************************/
function validarContacto(){
//Funcion para la validar los datos enviados desde el formulario de contacto
	var texto;
	texto = "";
	
	var cadenaEnvio;
	cadenaEnvio = "";
	
	//Aqui validamos que los campos obligatorios tengan valor y se añaden a la cadena de envio
	
	if ( document.getElementById("formularioContacto").nombre.value == "" ) {
		texto+=" - Debe indicar su nombre.<br>";
	}else{
		cadenaEnvio="nombre=" + document.getElementById("formularioContacto").nombre.value;
	}
	
	if ( document.getElementById("formularioContacto").email.value == "" ) {
		texto+=" - Debe indicar su email.<br>";
	}
	
	if(document.getElementById("formularioContacto").email.value!=""){
		if(!validarEmail(document.getElementById("formularioContacto").email.value)){
				texto+=" - Formato de E-mail incorrecto.<br>";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formularioContacto").email.value;
		}
	}
	if ( document.getElementById("formularioContacto").comentarios.value == "" ){
		texto+=" - Debe incluir el motivo de su consulta.<br>";
	}else{
		cadenaEnvio+="&comentarios=" + document.getElementById("formularioContacto").comentarios.value;
	}	
	
	//Aqui vamos añadiendo los demas campos sino estan vacion
	
	if ( document.getElementById("formularioContacto").direccion.value != "" ){
		cadenaEnvio+="&direccion=" + document.getElementById("formularioContacto").direccion.value;
	}
	
	if ( document.getElementById("formularioContacto").poblacion.value != "" ){
		cadenaEnvio+="&poblacion=" + document.getElementById("formularioContacto").poblacion.value;
	}
	
	if ( document.getElementById("formularioContacto").provincia.value != "" ){
		cadenaEnvio+="&provincia=" + document.getElementById("formularioContacto").provincia.value;
	}
	
	if ( document.getElementById("formularioContacto").telefono.value != "" ){
		cadenaEnvio+="&telefono=" + document.getElementById("formularioContacto").telefono.value;
	}
	
	if ( document.getElementById("formularioContacto").movil.value != "" ){
		cadenaEnvio+="&movil=" + document.getElementById("formularioContacto").movil.value;
	}
	
	if ( document.getElementById("formularioContacto").cpostal.value != "" ){
		cadenaEnvio+="&cpostal=" + document.getElementById("formularioContacto").cpostal.value;
	}

	if ( document.getElementById("formularioContacto").fax.value != "" ){
		cadenaEnvio+="&fax=" + document.getElementById("formularioContacto").fax.value;
	}
	//if ( document.getElementById("formularioContacto").pais2.value != "" ){
		cadenaEnvio+="&pais=" + document.getElementById("formularioContacto").pais.options[document.getElementById("formularioContacto").pais.selectedIndex].text
	//}
	
	//Si falta algun campo obligatorio o el email no tiene un formato correcto
	//mostramos un mensaje de avios
	
	if ( texto != "" ){
		document.getElementById("mensajeError").innerHTML=texto;
		document.getElementById("capaError").style.display='block';
	}else{
		//alert(cadenaEnvio);
		http.open("GET", "actualizer/formcorreosMultiple/envioSinBd.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseContacto;
		http.send(null);
	}
	
}

/****************************************************************
/ Nombre: borrarFormulario
/ Implentacion
/ Revision: 301106
/ Descripcion: borra los campos del formulario de contacto
'***************************************************************/

function borrarFormulario(){
	document.getElementById("formularioContacto").reset();
}

//*******************************************************************************
//******** PARA LAS SOLICITUDES DE INFORMACIÓN ******************************************
/****************************************************************
/ Implentacion FPerez
/ Revision: 280807
/ Descripcion: abre el formulario para solicitar informacion
'***************************************************************/

function formulario_solicitud(ref,depar){
	window.open("solicitud-informacion.asp?ref="+ref+"&depar="+depar,"Info","width=500 height=430 ");

}

/****************************************************************
/ Nombre: validarSolicitud
/ Implentacion FPerez
/ Revision: 280807
/ Descripcion: Valida los campos del formulario de solicitud de informacion
'***************************************************************/
function validarSolicitud(idioma){
//Funcion para la validar los datos enviados desde el formulario de contacto
	var texto,texto_en,texto_fr,texto_val;
	texto = "";
	texto_en = "";
	texto_fr = "";
	texto_val = "";
	texto_de = "";

	var cadenaEnvio;
	cadenaEnvio = "";
	
	//Aqui validamos que los campos obligatorios tengan valor y se añaden a la cadena de envio
	
	if ( document.getElementById("formularioSolicitud").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre.<br>";
		texto_en+=" * You must enter your name.<br>";
		texto_fr+=" * Vous devez indiquer votre nom.<br>";
		texto_val+=" * Deu indicar el seu nom.<br>";
		texto_de+=" * Ihren Namen bitte.\n";
	}else{
			if (!validarTexto(document.getElementById("formularioSolicitud").nombre.value)){
				texto+=" * El nombre tiene carácteres no permitidos.<br>";
			} else {
				cadenaEnvio="nombre=" + document.getElementById("formularioSolicitud").nombre.value;
			}
	}
	
	if ( document.getElementById("formularioSolicitud").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.<br>";
		texto_en+=" * You must enter your e-mail.<br>";
		texto_fr+=" * Vous devez indiquer votre email.<br>";
		texto_val+=" * Deu indicar el seu e-mail.<br>";
		texto_de+=" * Ihre E-Mail Adresse bitte.\n";
	}
	
	if(document.getElementById("formularioSolicitud").email.value!=""){
		if(!validarEmail(document.getElementById("formularioSolicitud").email.value)){
				texto+=" * Formato de E-mail incorrecto.<br>";
				texto_en+=" * The E-mail format is wrong.<br>";
				texto_fr+=" * Format d'email incorrect.<br>";
				texto_val+=" * Format de E-mail incorrecte.<br>";
				texto_de+=" * E-Mail Format ist nicht richtig.\n";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formularioSolicitud").email.value;
		}
	}


	if ( document.getElementById("formularioSolicitud").telefono.value == "" ) {
		texto+=" * Debe indicar su teléfono.<br>";
		texto_en+=" * You must enter your telephone.<br>";
		texto_fr+=" * Vous devez indiquer votre telephone.<br>";
		texto_val+=" * Deu indicar el seu e-mail.<br>";
		texto_de+=" * Ihre E-Mail Adresse bitte.\n";
	}else{
			if (!validarTexto(document.getElementById("formularioSolicitud").telefono.value)){
				texto+=" * El campo telefono tiene carácteres no permitidos.<br>";
			} else {
				cadenaEnvio+="&telefono=" + document.getElementById("formularioSolicitud").telefono.value;
			}
	}	

	if ( document.getElementById("formularioSolicitud").donde.value == "" ) {
		texto+=" * Debe seleccionar donde nos conocio.<br>";
		texto_en+=" * You must enter your telephone.<br>";
		texto_fr+=" * Vous devez indiquer votre telephone.<br>";
		texto_val+=" * Deu indicar el seu e-mail.<br>";
		texto_de+=" * Ihre E-Mail Adresse bitte.\n";
	}else{
		cadenaEnvio+="&donde=" + document.getElementById("formularioSolicitud").donde.value;
		if ( document.getElementById("formularioSolicitud").donde.value == "OT" ) {

			if ( document.getElementById("formularioSolicitud").otros.value == "" ) {
				texto+=" * Al selecionar otros debe introducir donde nos encontró.<br>";
				texto_en+=" * You must enter your telephone.<br>";
				texto_fr+=" * Vous devez indiquer votre telephone.<br>";
				texto_val+=" * Deu indicar el seu e-mail.<br>";
				texto_de+=" * Ihre E-Mail Adresse bitte.\n";
			}else{					
				cadenaEnvio+="&otros=" + document.getElementById("formularioSolicitud").otros.value;
			}	
		}
	}	

	if ( document.getElementById("formularioSolicitud").comentarios.value == "" ){
		texto+=" * Debe incluir el motivo de su consulta.<br>";
		texto_en+=" * You must enter your comments.<br>";
		texto_fr+=" * Vous devez indiquer l'objet de votre demande.<br>";
		texto_val+=" * Deu incloure el motiu de la seua consulta.<br>";
	}else{
			if (!validarTexto(document.getElementById("formularioSolicitud").comentarios.value)){
				texto+=" * El campo comentarios tiene carácteres no permitidos.<br>";
			} else {
				cadenaEnvio+="&comentarios=" + document.getElementById("formularioSolicitud").comentarios.value;
			}
	}	
	
	if ( document.getElementById("formularioSolicitud").departamento.value != "" ){
		cadenaEnvio+="&departamento=" + document.getElementById("formularioSolicitud").departamento.value;
	}
	
	if ( document.getElementById("formularioSolicitud").ref.value != "" ){
		cadenaEnvio+="&ref=" + document.getElementById("formularioSolicitud").ref.value;
	}
	//Si falta algun campo obligatorio o el email no tiene un formato correcto
	//mostramos un mensaje de avios
	
	if ( texto != "" ){
			switch (idioma) { 
				case 'en': 
					document.getElementById("mensajeError").innerHTML=texto_en;
				   break 
				case 'fr': 
					document.getElementById("mensajeError").innerHTML=texto_fr;
				   break 
				case 'val': 
					document.getElementById("mensajeError").innerHTML=texto_val;
				   break 
				case 'de': 
					document.getElementById("mensajeError").innerHTML=texto_de;
				   break 
				default: 
					document.getElementById("mensajeError").innerHTML=texto;
			} 
		document.getElementById("capaError").style.display='block';
		
	}else{
//	alert(cadenaEnvio);
//		document.getElementById("mensaje-respuesta").innerHTML="";
		document.getElementById("mensajeError").innerHTML="";
		document.getElementById("capaError").style.display='none';
		http.open("GET", "actualizer/formcorreosMultiple/envioSinBD-solicitud-info.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseSolicitud;
		http.send(null);
	}
	
}

function mostrarTexto()
{
	if(document.getElementById("donde").value=="OT") {
		document.getElementById("divOtros").style.display="block";
		document.getElementById("otros").focus();
	} else {
		document.getElementById("divOtros").style.display="none";
	}
}

function handleHttpResponseSolicitud() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
//			alert(http.responseText);
		document.getElementById("mensaje-respuesta").innerHTML = "";	
		document.getElementById("mensaje-respuesta2").innerHTML = http.responseText;	
		document.getElementById("respuesta").style.display = "block";	
		document.getElementById("formularioSolicitud").reset();
	}    
}


/****************************************************************
/ Nombre: ajustaImagen
/ Implentacion FPerez
/ Revision: 120907
/ Descripcion: Ajusta el ancho maximo de una imagen al 'ancho'
'***********************************************F****************/

function ajustaImagen(ancho,id,img){
	
//	alert(img);
	
	var anchoImagen,altoImagen,anchoPantalla,altoPantalla;
	img1 = new Image(); 
	img1.src = img;
	anchoImagen = img1.width;
	altoImagen = img1.height;
//	alert(anchoImagen + ' | ' + ancho);
	if (anchoImagen > ancho ){
			document.getElementById('image'+id).width = ancho;
			document.getElementById('image'+id).height = altoImagen * ancho / anchoImagen;

	}
}
/***************************************************************/

/****************************************************************
/ Nombre: imprimirCV
/ Implentacion 
/ Revision: 120907
/ Descripcion: imprimir el cv
'***************************************************************/
function imprimirCV(id){
    var base=document.getElementById("base").innerHTML;
    var estilo=document.getElementById("estilosPrincipal").href
    document.getElementById("estilosPrincipal").href="css/imprimir.css";
    var v=document.getElementById("capaImprimir").innerHTML;
    document.getElementById("base").innerHTML=v;
    document.getElementById("capaOcultar").style.display='none';
    window.print();
    document.getElementById("estilosPrincipal").href=estilo;
    document.getElementById("base").innerHTML=base;
}

/****************************************************************
/ Nombre: FUNCIONES PARA VALIDAR EL CIF
/ Implentacion FPEREZ
/ Revision: 281207
/ Descripcion:valida el CIF
'***************************************************************/
function validarCIF(texto){ 
         
        var pares = 0; 
        var impares = 0; 
        var suma; 
        var ultima; 
        var unumero; 
        var uletra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I"); 
        var xxx; 
         
        texto = texto.toUpperCase(); 
         
        var regular = new RegExp(/^[ABCDEFGHKLMNPQS]\d\d\d\d\d\d\d[0-9,A-J]$/g); 
         if (!regular.exec(texto)) return false; 
              
         ultima = texto.substr(8,1); 

         for (var cont = 1 ; cont < 7 ; cont ++){ 
             xxx = (2 * parseInt(texto.substr(cont++,1))).toString() + "0"; 
             impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1)); 
             pares += parseInt(texto.substr(cont,1)); 
         } 
         xxx = (2 * parseInt(texto.substr(cont,1))).toString() + "0"; 
         impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1)); 
          
         suma = (pares + impares).toString(); 
         unumero = parseInt(suma.substr(suma.length - 1, 1)); 
         unumero = (10 - unumero).toString(); 
         if(unumero == 10) unumero = 0; 
          
         if ((ultima == unumero) || (ultima == uletra[unumero])) 
             return true; 
         else 
             return false; 

    } 
	
function validarNIF(dni) {
  numero = dni.substr(0,dni.length-1);
  let = dni.substr(dni.length-1,1).toUpperCase();
  numero = numero % 23;
  letra='TRWAGMYFPDXBNJZSQVHLCKET';
  letra=letra.substring(numero,numero+1);
  if (letra!=let) {
//    alert('Dni erroneo');
	return false;
  }else{
//    alert('Dni correcto');
	return true;
  }
}

function trabajasActu(resp){
	if (resp == "si")
	{
		document.getElementById('porqueCambiar').disabled='';
		document.getElementById('porqueCambiar').style.background='#FFFFFF';
		document.getElementById('porqueCambiarQuest').style.color='#000000';
		
		
	}
	
	if (resp == "no")
	{
		document.getElementById('porqueCambiar').disabled='true';
		document.getElementById('porqueCambiar').value='';
		document.getElementById('porqueCambiar').style.background='#EEEEEE';
		document.getElementById('porqueCambiarQuest').style.color='#999999';
	}
	
}


function changeDepart() {
	departamento = document.getElementById("departamento").value;
	switch (departamento){
		case "NULL": 
			document.getElementById("descripcionDepartamento").value = "";
			break;
		case "Reservas aéras y renfe": 
			document.getElementById("descripcionDepartamento").value = "Domino AMADEUS, inglés, experiencia en agencias o mayoristas de viajes.\nSe valorará otros idiomas, RENFE, conocimiento de ORBIS.";
			break;
		case "Programas turísticos": 
			document.getElementById("descripcionDepartamento").value = "Dominio AMADEUS, inglés, experiencia en puesto similar.\nSe valorará otros idiomas, RENFE, conocimientos de ORBIS.";
			break;
		case "Comercial": 
			document.getElementById("descripcionDepartamento").value = "Inglés, experiencia en turismo (agencias o mayoristas de viajes).\nSe valorará otros idiomas, experiencia en puesto similar.";
			break;
		case "Incoming": 
			document.getElementById("descripcionDepartamento").value = "Dominio de al menos dos idiomas (uno de ellos inglés) en lengua extranjera.\nExperiencia en turismo.\nSe valorarán otros idiomas, experiencia como guía turístico.";
			break;
		case "Administración": 
			document.getElementById("descripcionDepartamento").value = "Experiencia en puesto similiar, conocimientos de AMADEUS y control de billetaje.\nConocimientos de inglés, conocimientos de CONTAPLUS, dominio de EXCEL.\nSe valorará conocimientos de ORBIS.";
			break;
			
		
	}
}





function validarTRabConNos(idioma){
//Funcion para la validar los datos enviados desde el formulario de contacto
	var texto,texto_en,texto_fr,texto_val;
	texto = "";
	texto_en = "";
	texto_fr = "";
	texto_val = "";
	texto_de = "";

	var cadenaEnvio;
	cadenaEnvio = "";
	
	//Aqui validamos que los campos obligatorios tengan valor y se añaden a la cadena de envio
	//if (!document.getElementById('acepto').checked){
		//texto+="- Debe aceptar los términos.<br>";
	//}


	if ( document.getElementById("formularioContacto").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre y apellidos.<br>";
		texto_en+=" * You must enter your name.<br>";
		texto_fr+=" * Vous devez indiquer votre nom.<br>";
		texto_val+=" * Deu indicar el seu nom.<br>";
		texto_de+=" * Ihren Namen bitte.\n";
	}else{
		cadenaEnvio="nombre=" + document.getElementById("formularioContacto").nombre.value;
	}
	
	if ( document.getElementById("formularioContacto").fechaNacimiento.value == "" ) {
		texto+=" * Debe indicar su fecha de nacimiento.<br>";
	}
	else{
		cadenaEnvio+="&fechaNacimiento=" + document.getElementById("formularioContacto").fechaNacimiento.value;
	}
	
	
	if ( document.getElementById("formularioContacto").lugarNacimiento.value == "" ) {
		texto+=" * Debe indicar su lugar de nacimiento.<br>";
	}
	else{
		cadenaEnvio+="&lugarNacimiento=" + document.getElementById("formularioContacto").lugarNacimiento.value;
	}
	
	
	if ( document.getElementById("formularioContacto").dni.value == "" ) {
		texto+=" * Debe indicar su DNI/NIE.<br>";
	}
	else{
		cadenaEnvio+="&dni=" + document.getElementById("formularioContacto").dni.value;
	}	
	
	if ( document.getElementById("formularioContacto").direccion.value == "" ){
		texto+=" * Debes indicar tu dirección.<br>";
	}
	else{
		cadenaEnvio+="&direccion=" + document.getElementById("formularioContacto").direccion.value;
	}
	
	if ( document.getElementById("formularioContacto").poblacion.value == "" ){
		texto+=" * Debes indicar tu población.<br>";
	}
	else{
		cadenaEnvio+="&poblacion=" + document.getElementById("formularioContacto").poblacion.value;
	}
	
	if ( document.getElementById("formularioContacto").provincia.value == "" ){
		texto+=" * Debes indicar tu provincia.<br>";
	}
	else{
		cadenaEnvio+="&provincia=" + document.getElementById("formularioContacto").provincia.value;
	}
	
	
	if ( document.getElementById("formularioContacto").telefono.value == "" ){
		texto+=" * Debes indicar tu teléfono.<br>";
	}
	else{
		cadenaEnvio+="&telefono=" + document.getElementById("formularioContacto").telefono.value;
	}
	
	if ( document.getElementById("formularioContacto").movil.value == "" ){
		texto+=" * Debes indicar tu móvil.<br>";
	}
	else{
		cadenaEnvio+="&movil=" + document.getElementById("formularioContacto").movil.value;
	}
	
	if ( document.getElementById("formularioContacto").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.<br>";
		texto_en+=" * You must enter your e-mail.<br>";
		texto_fr+=" * Vous devez indiquer votre email.<br>";
		texto_val+=" * Deu indicar el seu e-mail.<br>";
		texto_de+=" * Ihre E-Mail Adresse bitte.\n";
	}
	
	if(document.getElementById("formularioContacto").email.value!=""){
		if(!validarEmail(document.getElementById("formularioContacto").email.value)){
				texto+=" * Formato de E-mail incorrecto.<br>";
				texto_en+=" * The E-mail format is wrong.<br>";
				texto_fr+=" * Format d'email incorrect.<br>";
				texto_val+=" * Format de E-mail incorrecte.<br>";
				texto_de+=" * E-Mail Format ist nicht richtig.\n";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formularioContacto").email.value;
		}
	}




	if (document.getElementById("trabajasActualmenteSi").checked==true)
	{
		if ( document.getElementById("formularioContacto").porqueCambiar.value == "" )
		{
			//alert("si1");
			texto+=" * Debe indicar porqué quieres cambiar de trabajar.<br>";
		}
		else
		{
			//alert("si2");
			cadenaEnvio+="&porqueCambiar=" + document.getElementById("formularioContacto").porqueCambiar.value;
		}
	}
	else{
		//alert("no");
		cadenaEnvio+="&porqueCambiar=";	
	}
	
	if ( document.getElementById("formularioContacto").departamento.value == "NULL" ){
		texto+=" * Debes indicar en qué departamento te gustaría trabajar.<br>";
	}else{
		cadenaEnvio+="&departamento=" + document.getElementById("formularioContacto").departamento.value;
	}
	
	if ( document.getElementById("formularioContacto").porqueEsteDepartamento.value == "" ){
		texto+=" * Debes indicar por qué te gustaría trabajar en este departamento.<br>";
	}else{
		cadenaEnvio+="&porqueEsteDepartamento=" + document.getElementById("formularioContacto").porqueEsteDepartamento.value;
	}
	
	if ( document.getElementById("formularioContacto").trabajarEquipo.value == "" ){
		texto+=" * Debes indicar si te gustaría trabajar en equipo.<br>";
	}else{
		cadenaEnvio+="&trabajarEquipo=" + document.getElementById("formularioContacto").trabajarEquipo.value;
	}
	
	
	if(document.getElementById("nivelPuestoC").checked==true)
	{
		cadenaEnvio+="&nivelPuesto=Cualificado";
		//alert("C");
	}
	if(document.getElementById("nivelPuestoM").checked==true)
	{
		cadenaEnvio+="&nivelPuesto=Medio";
		//alert("M");
	}
	if(document.getElementById("nivelPuestoA").checked==true)
	{
		cadenaEnvio+="&nivelPuesto=Alto";
		//alert("A");
	}
	
	
	if ( document.getElementById("formularioContacto").teVesEnEquipo.value == "" ){
		texto+=" * Debes indicar como te ves en equipo de trabajo.<br>";
	}else{
		cadenaEnvio+="&teVesEnEquipo=" + document.getElementById("formularioContacto").teVesEnEquipo.value;
	}
	
	if ( document.getElementById("formularioContacto").cualidadesPro.value == "" ){
		texto+=" * Debes indicar tus cualidades profesionales .<br>";
	}else{
		cadenaEnvio+="&cualidadesPro=" + document.getElementById("formularioContacto").cualidadesPro.value;
	}
	
	
	
	if ( document.getElementById("formularioContacto").formacion.value == "" ){
		texto+=" * Debe incluir su formación académica.<br>";
	}else{
		cadenaEnvio+="&formacion=" + document.getElementById("formularioContacto").formacion.value;
	}
	
	if ( document.getElementById("formularioContacto").experiencia.value == "" ){
		texto+=" * Debe incluir su experiencia laboral.<br>";
	}else{
		cadenaEnvio+="&experiencia=" + document.getElementById("formularioContacto").experiencia.value;
	}
	
	if ( document.getElementById("formularioContacto").idiomas.value == "" ){
		texto+=" * Debe incluir sus idiomas.<br>";
	}else{
		cadenaEnvio+="&idiomas=" + document.getElementById("formularioContacto").idiomas.value;
	}
	
	if ( document.getElementById("formularioContacto").conoInfo.value == "" ){
		texto+=" * Debe incluir sus conocimientos informáticos.<br>";
	}else{
		cadenaEnvio+="&conoInfo=" + document.getElementById("formularioContacto").conoInfo.value;
	}
	
	//Aqui vamos añadiendo los demas campos sino estan vacion
	
	
	
	//Si falta algun campo obligatorio o el email no tiene un formato correcto
	//mostramos un mensaje de avios
	if ( texto != "" ){
		document.getElementById("mensajeError").innerHTML=texto;
		document.getElementById("capaError").style.display='block';
	}else{
		//alert(cadenaEnvio);
			document.getElementById("mensaje-respuesta").innerHTML="";
			document.getElementById("mensajeError").innerHTML="";
			document.getElementById("capaError").style.display='none';
			document.getElementById("formularioContacto").submit();
/*		http.open("GET", "actualizer/formcorreosMultiple/envioSinBD2.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseTrabConNos;
		http.send(null);*/
	}
/*	if ( texto != "" ){
			switch (idioma) { 
				case 'en': 
					document.getElementById("mensajeError").innerHTML=texto_en;
				   break 
				case 'fr': 
					document.getElementById("mensajeError").innerHTML=texto_fr;
				   break 
				case 'val': 
					document.getElementById("mensajeError").innerHTML=texto_val;
				   break 
				case 'de': 
					document.getElementById("mensajeError").innerHTML=texto_de;
				   break 
				default: 
					document.getElementById("mensajeError").innerHTML=texto;
			} 
		document.getElementById("capaError").style.display='block';
		
	}else{
		//alert(cadenaEnvio);
		document.getElementById("mensaje-respuesta").innerHTML="";
		document.getElementById("mensajeError").innerHTML="";
		document.getElementById("capaError").style.display='none';
		http.open("GET", "actualizer/formcorreosMultiple/envioSinBd.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseContacto;
		http.send(null);
	}*/
	
}

function cerrarAvisoMenResp(){
	document.getElementById("mensajeResp").innerHTML="";
	document.getElementById("mensaje-respuesta").style.display='none';
}

function handleHttpResponseTrabConNos() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
//			alert(http.responseText);
//		alert("ok");
//		alert(http.responseText);
		document.getElementById("mensajeResp").innerHTML = http.responseText;
		document.getElementById("mensaje-respuesta").style.display='block';
		
		//document.getElementById("formularioContacto").reset();
	}  
}

function getNoticias(){
	
	var c;
	
	c=document.getElementById("provincias").value;
//	window.location.href="index.asp?pagina=buscar-agencias&c=" + c;
	var valor = document.getElementById("provincias").options[document.getElementById("provincias").selectedIndex].text;
	
	window.location.href="aquatravel_buscar-agencias_"+c+"_"+valor.toLowerCase()+".html";
}

function validarTexto(eltexto){

	var cval="abcçdefghijklmnñopqrstuvwxyzABCÇDEFGHIJKLMNÑOPQRSTUVWXYZ0123456789 _ÁÀÄÂÉÈËÊÍÌÏÎÓÒÖÔÚÙÜÛáàäâéèëêíìïîóòöôúùüû@,.";
	var aux,n=0;	
	aux=eltexto;
	
	if(aux!=""){
		for(i=0;i<aux.length;i++){	
			for(j=0;j<cval.length;j++){				
				if(cval.charAt(j)==aux.charAt(i)){
					n++;
				}				
			}		 
		}
	}

	if(n==aux.length){
		return true;
	}else{
		return false;
	}
}



/****************************************************************
/ Nombre: muestraMenu
/ Implentacion:
/ Revision:
/ Descripcion: Muestra los menus
'***************************************************************/
function muestraMenu(id,numero) {
	for (i=1;i<=numero;i++){
		if (id != i){
			if (document.getElementById("capaMenu"+ i).style.display == "block"){
				document.getElementById("capaMenu"+ i).style.display = "none";
			}
		}
	}
	if (document.getElementById("capaMenu"+ id).style.display == "block") { 
		document.getElementById("capaMenu"+ id).style.display = "none"; }
	else { 
		document.getElementById("capaMenu"+ id).style.display = "block";
		}
}

function cambiaImagenAmpliada(imagen){
		document.getElementById('imagenAmpliada').src = "includes/ajustarImg2.asp?img=../actualizer/catalogocompleto/fotos/"+imagen;
}




/****************************************************************************************
/ Nombre: SendComment(), handleHttpResponseSendComment()
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Comentarios de la pelicula
'***************************************************************************************/
function SendComment(producto, url){
		CorreoSendComment="";
		TextoSendComment="";
		var elementMessage = document.getElementById("elementMessage");
		var textBoxTitle = document.getElementById("titulo");
		var textBoxEmail = document.getElementById("email");
		CorreoSendComment=textBoxEmail.value;
		var textBoxComment = document.getElementById("comentario");
		var sec_code = document.getElementById("sec_code");


		TextoSendComment="Se ha introducido un comentario en el viaje : <a href='" + url + "'>" + url + "</a>";
	
		if (textBoxTitle.value != '' && textBoxEmail.value != '' && textBoxComment.value != '') {
			url = "AjaxResponse/comentariosPelicula.asp?Title=" + textBoxTitle.value+ "&Comment=" + textBoxComment.value + "&Email="+ textBoxEmail.value +"&producto=" + producto + "&sec_code=" + sec_code.value;
			
			http.open("GET", url , true);
			http.onreadystatechange = handleHttpResponseSendComment;
			http.send(null);
			textBoxTitle.value = '';
			textBoxEmail.value = '';
			textBoxComment.value = '';
		}else{
			elementMessage.innerHTML = '* El t&iacute;tulo y el comentario deben cumplimentarse';
			elementMessage.style.color = 'Red';
		}
}


function handleHttpResponseSendComment() {
	if (http.readyState == 4) {
		if(http.responseText != 'Error'){
			var elementMessage = document.getElementById("comentarios");
			elementMessage.innerHTML = http.responseText;
			enviarEmailComentario(CorreoSendComment, TextoSendComment);						
		}else{
			var elementMessage = document.getElementById("elementMessage");
			alert(http.responseText)
			elementMessage.innerHTML = "No se ha podido insertar el comentario";
		}
	}    
}


function enviarEmailComentario(email, texto){
		cadenaEnvio = 'email='+email;
		laUrl="actualizer/formcorreosMultiple/envioComentario.asp?" + cadenaEnvio + "&texto=" + texto; 
		http.open("GET", laUrl, true);
		http.onreadystatechange = handleHttpResponseEmailComentario;
		http.send(null);
}
function handleHttpResponseEmailComentario() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		if(http.responseText!="") {
			//alert(http.responseText);	
		}
		CorreoSendComment="";
		TextoSendComment="";
	}    
}




/****************************************************************************************
/ Nombre: MarkStar, unMarkStar, VoteFilm, handleHttpResponseVoteFilm
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Manejo de la votacion de la pelicula
'***************************************************************************************/

function MarkStar(starNumber){
		for (i=1; i<=starNumber; i++){
			star = 	document.getElementById("star" + i);
			star.src = "images/voto.png";
		}
}

function unMarkStar(starNumber){	
		for (i=1; i<=starNumber; i++){
			star = 	document.getElementById("star" + i);
			star.src = "images/voto-void.png";
		}
}

function VoteFilm(vote, id){
	url = "AjaxResponse/voteFilm.asp?Id=" + id+ "&Vote=" + vote;
	http.open("GET", url , true);
	http.onreadystatechange = handleHttpResponseVoteFilm;
	http.send(null);
}



function handleHttpResponseVoteFilm() {
	if (http.readyState == 4) {
			var elementMessage = document.getElementById("stars");
			if(http.responseText != 'Error'){
					//var valoracion = document.getElementById("valoracion");
					
					//valor = http.responseText
					//if (valor.length > 3){
					//	valor = valor.substr(0, 3);
					//}
					//valoracion.innerHTML = valor;
				
				elementMessage.innerHTML = "Gracias por votar";
			}else{
				elementMessage.innerHTML = "No se ha podido insertar su voto";
			}
	}    
}


function mostrarComunidadReceptivo(comunidad)
{
		fields = "comunidad=" + comunidad;
		url ="includes/getTemaIdReceptivo.asp";
		
        http.open("POST", url , true);
		
        http.onreadystatechange = function() {
        if (http.readyState==1) {
                          
						  //element.innerHTML="Cargando.......";
						  
        }else if (http.readyState==4){
                   if(http.status==200)
                   {
					   url = "index.asp?pagina=receptivo&subpagina=" + http.responseText;
					   //alert(url);
					   window.location.href=url;
						
                   }
                   else if(http.status==404){
							
                   		}else{
                            
                        }
                   }
         }
         http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         http.send(fields);
         return;
}

