/****************************************************************
/ 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/body-background-quienes-somos.jpg)";
				break;
			case 2: 
				fondo= "url(images/body-background-vacaciones.jpg)";
				break;
			case 3: 
				fondo= "url(images/body-background-especiales.jpg)";
				break;
			case 4: 
				fondo= "url(images/body-background-empresas.jpg)";
				break;
			case 5: 
				fondo= "url(images/body-background-a-medida.jpg)";
				break;
			case 6: 
				fondo= "url(images/body-background-cruceros.jpg)";
				break;
			case 7: 
				fondo= "url(images/body-background-tienda.jpg)";
				break;
			case 8: 
				fondo= "url(images/body-background-buscador.jpg)";
				break;
			case 9: 
				fondo= "url(images/body-background-glosario.jpg)";
				break;
			case 10: 
				fondo= "url(images/body-background-faqs.jpg)";
				break;
			case 11: 
				fondo= "url(images/body-background-aviso-legal.jpg)";
				break;
			case 12: 
				fondo= "url(images/body-background-mapa-web.jpg)";
				break;
			case 13: 
				fondo= "url(images/body-background-zaraclub.jpg)";
				break;
			case 14: 
				fondo= "url(images/body-background-novios.jpg)";
				break;
			case 15: 
				fondo= "url(images/body-background-tienda.jpg)";
				break;
			case 16: 
				fondo= "url(images/body-background-zaraclub.jpg)";
				break;
			default:
				fondo= "url(images/body-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));
	
}

/****************************************************************
/ 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("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 permitidos.<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 permitidos.<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 permitidos.<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 permitidos.<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 permitidos.<br>";
		} else {

		cadenaEnvio+="&provincia=" + document.getElementById("formularioContacto").provincia.value;
		}
	}
	
	if ( document.getElementById("formularioContacto").telefono.value == "" ){
		texto+=" * Debe indicar su teléfono.<br>";
		texto_en+=" * You must enter your telephone number.<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";
	} else {
		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 != "" ){
		if (!validarTexto(document.getElementById("formularioContacto").cpostal.value)){
			texto+="* El código postal tiene carácteres no permitidos.<br>";
		} else {
			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 != "" ){
			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);
	}
	
}
/****************************************************************
/ 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();
	}    
}

/****************************************************************
/ 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").password.value == "" ) 
		{
		texto+="Debe indicar su contraseña.\n";
		}
	else{
		if (!validarTexto(document.getElementById("formRegistro").password.value))
			{
			texto+="El password tiene carácteres no permitidos.\n";
			} else  {
				cadenaEnvio+="&password=" + document.getElementById("formRegistro").password.value;
					}
		}

	if ( document.getElementById("formRegistro").password2.value == "" ) {
		texto+="Debe repetir su contraseña.\n";
	}else{
		if (!validarTexto(document.getElementById("formRegistro").password2.value)){
			texto+="El password repetido tiene carácteres no permitidos.\n";
		}
	}
	
	if ( document.getElementById("formRegistro").password2.value != document.getElementById("formRegistro").password.value ) {
		texto+="El valor de la contraseña no coincide.\n";
	}

	if (!validarTexto(document.getElementById("formRegistro").nombre.value)){
		texto+="El nombre tiene carácteres no permitidos.\n";
	} else {
		cadenaEnvio+="&nombre=" + document.getElementById("formRegistro").nombre.value;
	}

	if (!validarTexto(document.getElementById("formRegistro").observaciones.value)){
		texto+="Las observaciones tienen carácteres no permitidos.\n";
	} else {
		cadenaEnvio+="&observaciones=" + document.getElementById("formRegistro").observaciones.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 nombre = document.getElementById("formRegistro").nombre.value;
	
		if ( texto != "" ){
				alert(texto);
		}else{
			http.open("GET", "registro/compruebaEmail.asp?email=" + email +"&nombre=" + nombre, 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 != "" ){
				document.getElementById("mensaje-alerta").style.display='block';
				document.getElementById("mensaje-alerta").innerHTML= 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
		//document.getElementById("hayQueCambiar"+id).href = "javascript:pedir("+id+", "+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: 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 (   (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 autentifica2(type){
	var strEnvio = '';

	if (!validarTexto(document.getElementById("formLogin2").user.value)){
		alert("El user tiene carácteres no permitidos.");
	}
	
	if (!validarTexto(document.getElementById("formLogin2").password.value)){
		alert("El pass tiene carácteres no permitidos.");
	} else {


		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 (   (valor == '') || (valor == mensajes[i])  ) {
					document.getElementById("mensaje-alerta").style.display='block';
					document.getElementById("mensaje-alerta").innerHTML='.: Usuario o contraseña incorrectos :.';
					//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 + "&reg=1";
			http.open("GET", url , false);
			//alert(url);
			//alert(http.readyState)
			if (navegador == "Microsoft Internet Explorer"){   
				http.Onreadystatechange = handleHttpResponseReload;
			}else{
				http.Onreadystatechange = handleHttpResponseReloadMoz();	
			}
			http.send(null);
			//window.open ("templates/refresh_login.html");
			
		}else{
			document.getElementById("mensaje-alerta").style.display='block';
			document.getElementById("mensaje-alerta").innerHTML='.: Usuario o contraseña incorectos :.'	
		}	
	}
	
	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;
		}
	}    
}*/

function handleHttpResponseReload() 
{
	if (http.readyState == 4) 
	{
		var respuesta=http.responseText;
		if (respuesta=="no")
		{document.getElementById("mensaje-alerta").style.display='block';
		document.getElementById("mensaje-alerta").innerHTML='.: Usuario o contraseña incorectos :.';}
		if (respuesta=="si")
		{
			document.location="index.asp?pagina=zaraclub";
			//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;
		}
	}    
}

var cont2=0;
function handleHttpResponseReloadMoz() 
{
	if (http.readyState == 4) 
	{
		var respuesta=http.responseText;
		if (respuesta=="no")
		{document.getElementById("mensaje-alerta").style.display='block';
		document.getElementById("mensaje-alerta").innerHTML='.: Usuario o contraseña incorectos :.';}
		if (respuesta=="si")
		{
			document.location="index.asp?pagina=zaraclub";
			//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(cont2==1)
	{
		cont2=0
		clearTimeout();
	}
	else
	{
		cont2=1;
		setTimeout("handleHttpResponseReloadMoz();",100);
	}
}


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"){
//			alert();
			window.parent.document.location.href="index.asp";
		}
		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 ="viajes.asp";
		}
	}    
}

/****************************************************************************************
/ 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 rememberPassword(){
	document.getElementById('recordarPassword').style.display = 'block';
}

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();
		setTimeout('document.getElementById("recordarPassword").style.display = "none";',3000);
		setTimeout('document.getElementById("respuestaRecuerdo").innerHTML = "";',3500);		
	}    
}



/****************************************************************************************
/ 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{
		if (!validarTexto(document.getElementById("textobusqueda").value)){
			alert("El texto de búsqueda tiene carácteres no permitidos.");
			document.getElementById("textobusqueda").value="";
		} else {
			document.getElementById("busqueda").cadenaBusqueda.value=document.getElementById("textobusqueda").value
			document.getElementById("busqueda").submit();
		}
	}
}




/****************************************************************************************
/ Nombre: validarSuscripcion
/ Implentacion: JDolz
/ Revision:
/ Descripcion: Valida y envia el formulario de suscripcion a las news
'***************************************************************************************/
/*function validarSuscripcion(){

	var texto="";

	if ( document.getElementById("formularioSuscripcion").nombre.value == "" ) {
		texto+=" - Debe indicar su nombre.<br>";
	}else{
		cadenaEnvio="nombre=" + document.getElementById("formularioSuscripcion").nombre.value;
	}
	
	if ( document.getElementById("formularioSuscripcion").email.value == "" ) {
		texto+=" - Debe indicar su email.<br>";
	}
	
	if(document.getElementById("formularioSuscripcion").email.value!=""){
		if(!validarEmail(document.getElementById("formularioSuscripcion").email.value)){
				texto+=" - Formato de E-mail incorrecto.<br>";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formularioSuscripcion").email.value;
		}
	}

	if (texto!=""){
		document.getElementById("respuesta-suscripcion").innerHTML="";
		document.getElementById("respuesta-suscripcion").innerHTML=texto;
		document.getElementById("respuesta-suscripcion").style.display="block";
	}else{
		http.open("GET", "actualizer/ap3nbs/suscripcion/suscripcion.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseSuscripcion;
		http.send(null);
	}	
}
function handleHttpResponseSuscripcion() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		document.getElementById("respuesta-suscripcion").innerHTML=http.responseText;
		document.getElementById("respuesta-suscripcion").style.display = 'block';	
		document.getElementById("formularioSuscripcion").reset();
	}    
}*/

/****************************************************************
/ Nombre: validarvalidarSuscripcion
/ Implentacion: Fperez
/ Revision: 11-07-07
/ Descripcion: Valida los campos del formulario de suscripcion
'***************************************************************/
function validarSuscripcion(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="nombre=" + document.getElementById("formularioSuscripcion").email.value;
			cadenaEnvio+="&email=" + document.getElementById("formularioSuscripcion").email.value;
		}
	}

	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 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("formularioSuscripcion").reset();
	}    
}
function blanco(){
/*	if (document.getElementById('nombre').value == ' nombre') {
		document.getElementById('nombre').value = '';
	}*/
	if (document.getElementById('email').value == '  Suscribase al newsletter') {
		document.getElementById('email').value = '';
	}
}


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("formularioSuscripcion2").email2.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("formularioSuscripcion2").email2.value!=""){
		if(!validarEmail(document.getElementById("formularioSuscripcion2").email2.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="nombre=" + document.getElementById("formularioSuscripcion2").email2.value;
			cadenaEnvio+="&email=" + document.getElementById("formularioSuscripcion2").email2.value;
		}
	}

	if (texto!=""){
		document.getElementById("textoSuscripcion2").innerHTML="";

			switch (idioma) { 
				case 'en': 
					document.getElementById("textoSuscripcion2").innerHTML=texto_en;
				   break 
				case 'fr': 
					document.getElementById("textoSuscripcion2").innerHTML=texto_fr;
				   break 
				case 'val': 
					document.getElementById("textoSuscripcion2").innerHTML=texto_val;
				   break 
				case 'de': 
					document.getElementById("textoSuscripcion2").innerHTML=texto_de;
				   break 
				default: 
					document.getElementById("textoSuscripcion2").innerHTML=texto;
			} 
		document.getElementById("textoSuscripcion2").style.display="block";
	}else{
		http.open("GET", "actualizer/suscripcion/suscripcion.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseSuscripcion2;
		http.send(null);
	}	
}
function handleHttpResponseSuscripcion2() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
//			alert(http.responseText);
		document.getElementById("textoSuscripcion2").innerHTML = http.responseText;	
		document.getElementById("formularioSuscripcion2").reset();
	}    
}
function blanco2(){
/*	if (document.getElementById('nombre').value == ' nombre') {
		document.getElementById('nombre').value = '';
	}*/
	if (document.getElementById('email2').value == '  Suscribase al newsletter') {
		document.getElementById('email2').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=380 ");

}

/****************************************************************
/ 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").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+="* Los comentarios tienen carácteres no permitidos.<br>";
		} else {
			cadenaEnvio+="&comentarios=" + document.getElementById("formularioSolicitud").comentarios.value;
		}
	}	
	
	
	if ( document.getElementById("formularioSolicitud").telefono.value != "" ){
		cadenaEnvio+="&telefono=" + document.getElementById("formularioSolicitud").telefono.value;
	}
	
	if ( document.getElementById("formularioSolicitud").departamento.value != "" ){
		cadenaEnvio+="&departamento=" + document.getElementById("formularioSolicitud").departamento.value;
	}
	
	if ( document.getElementById("formularioSolicitud").referencia.value != "" ){
		cadenaEnvio+="&referencia=" + document.getElementById("formularioSolicitud").referencia.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 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: autentifica
/ Implentacion: FPEREZ
/ Revision:
/ Descripcion: Login de usuario en la zona privada
'***************************************************************************************/
function autentifica3(type){
	var strEnvio = '';
	
		
		var campos = new Array();
		var mensajes = new Array();
		
		
		/* DENINE CAMPO A VALIDAR MENSAJE*/
		campos[0] = 'user'; mensajes[0] = 'Indique usuario';
		campos[1] = 'password'; mensajes[1] = 'Indique contraseña';
	
		
		valid = false; 
		i=0;
		
		for(campo in campos){
			valor = document.formLogin2[campo].value;
			if (   (valor == '') || (valor == mensajes[i])  ) {
				document.formLogin2[campo].value = mensajes[i];
				valid = false;
			}else{
				strEnvio += "" + campos[i] + "=" + document.formLogin2[campo].value + "&";
				valid = true;
			}
			i++;
		}
	
	if(valid){
//		window.location.href = "includes/loginEngine.asp?" + strEnvio;
		url = "includes/login2.asp?" + strEnvio;
//		alert(url);
		http.open("GET", url , true);
		http.onreadystatechange = handleHttpResponseReload;
		http.send(null);		
	}else{
		return false;	
	}	
}






/****************************************************************
/ 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;

	}
}
/***************************************************************/





//*******************************************************************************
//******** PARA EL BUSCADOR DE VIAJES ******************************************
/****************************************************************
/ Implentacion FPerez
/ Revision: 240907
/ Descripcion: Cambia los dias, mese y años del formulario
'***************************************************************/
var navegador=navigator.appName;
var objeto_y;
var objeto_x;
function abreCalendario(tipo){
	var obj = document.getElementById('image_'+tipo);
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	objeto_y = curtop;
//	alert(curtop);
	objeto_x = curleft;
//	alert(curleft);
//	return [curleft,curtop];

	document.getElementById('calendario_'+tipo).style.top = curtop + 20 +'px' ;
	document.getElementById('calendario_'+tipo).style.left = curleft - 197 +'px' ;
	document.getElementById('calendario_'+tipo).style.display = "block";
	

//	window.open("calendario.aspx?tipo="+tipo,"Calendario","width=240 height=240 titlebar=0");

}

function calendario(tipo,dia,mes,anyo,pag){
	indice_mes = mes -1;
	
		//Seleccion el mes correspondiente
		if (pag == 'op'){
			if (tipo == 'ambos'){
				window.parent.document.getElementById('mes_inicio').options[indice_mes].selected=true;
				window.parent.document.getElementById('mes_fin').options[indice_mes].selected=true;
			} else {
				window.parent.document.getElementById('mes_'+tipo).options[indice_mes].selected=true;
			}
		}else{
			if (tipo == 'ambos'){
				document.getElementById('mes_inicio').options[indice_mes].selected=true;
				document.getElementById('mes_fin').options[indice_mes].selected=true;
			} else {
				document.getElementById('mes_'+tipo).options[indice_mes].selected=true;
			}
		}


		//Seleccion el anyo correspondiente
		if (pag == 'op'){
			if (tipo == 'ambos'){
					for (i=0;i<2;i++){
							if(window.parent.document.getElementById('anyo_inicio').options[i].value==anyo){
									window.parent.document.getElementById('anyo_inicio').options[i].selected=true;
								}
							if(window.parent.document.getElementById('anyo_fin').options[i].value==anyo){
									window.parent.document.getElementById('anyo_fin').options[i].selected=true;
								}
					}
			} else {
					for (i=0;i<2;i++){
							if(window.parent.document.getElementById('anyo_'+tipo).options[i].value==anyo){
									window.parent.document.getElementById('anyo_'+tipo).options[i].selected=true;
								}
					}
			}
		}else{
			if (tipo == 'ambos'){
					for (i=0;i<2;i++){
							if(document.getElementById('anyo_inicio').options[i].value==anyo){
									document.getElementById('anyo_inicio').options[i].selected=true;
								}
							if(document.getElementById('anyo_fin').options[i].value==anyo){
									document.getElementById('anyo_fin').options[i].selected=true;
								}
					}
			} else {
					for (i=0;i<2;i++){
							if(document.getElementById('anyo_'+tipo).options[i].value==anyo){
									document.getElementById('anyo_'+tipo).options[i].selected=true;
								}
					}
			}
		}
		
		
//	alert('1');
		http.open("GET", "pintaDias.asp?tipo=" + tipo+"&dia=" + dia+"&mes=" + mes+"&anyo=" + anyo+"&pag=" + pag, true);
		http.onreadystatechange = handleHttpResponseCalendario;
		http.send(null);
//	alert('2');
}

function handleHttpResponseCalendario() {//alert(http.readyState);
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido

//		alert(http.responseText);
		var contenido = http.responseText;	
		cont = contenido.split("|");
//			alert(cont[0]);
		
		if (cont[0] == 'op'){
					if (cont[1] == 'ambos'){
							window.parent.document.getElementById('cont_dia_inicio').innerHTML = cont[2];
							window.parent.document.getElementById('cont_dia_fin').innerHTML = cont[3];
					}
					if (cont[1] == 'inicio'){
							window.parent.document.getElementById('cont_dia_inicio').innerHTML = cont[2];
					}
					if (cont[1] == 'fin'){
							window.parent.document.getElementById('cont_dia_fin').innerHTML = cont[2];
					}

		} else {
					if (cont[1] == 'ambos'){
							document.getElementById('cont_dia_inicio').innerHTML = cont[2];
							document.getElementById('cont_dia_fin').innerHTML = cont[3];
					}
					if (cont[1] == 'inicio'){
							document.getElementById('cont_dia_inicio').innerHTML = cont[2];
					}
					if (cont[1] == 'fin'){
							document.getElementById('cont_dia_fin').innerHTML = cont[2];
					}
			
		}
//		document.getElementById("respuesta").style.display = "block";	
//		document.getElementById("formularioSolicitud").reset();
	}    
}


function validarVuelos(){
	
	
	/***** DEBE INSERTAR ORIGEN Y DESTINO *****/
	if (document.getElementById('B_LOCATION_1').value == ""){
			alert('Ha de haber una ciudad o aeropuerto de origen.');
			return;
	}

	if (document.getElementById('E_LOCATION_1').value == ""){
			alert('Ha de haber una ciudad o aeropuerto de destino.');
			return;
	}

	/***** DEBE INSERTAR ORIGEN Y DESTINO *****/



	/***** CREA LOS CAMPOS PARA LOS VIAJEROS ******/
	
	var num_adultos, num_ninyos, num_bebes;
	var	campos = "";
	
	// Capturamos el numero de adultos, niños y bebes seleccionados
	num_adultos = parseInt(document.getElementById('adultos').options[document.getElementById('adultos').selectedIndex].value);
	num_ninyos = parseInt(document.getElementById('ninyos').options[document.getElementById('ninyos').selectedIndex].value);
	num_bebes = parseInt(document.getElementById('bebes').options[document.getElementById('bebes').selectedIndex].value);
	
	var total_viajeros = num_adultos + num_ninyos;
	
	
	
	//No se pueden seleccionar mas de 9 pasajeros
	if (total_viajeros > 9){
		alert('No se pueden seleccionar más de 9 pasajeros.');
		return;
	} else {
		
		if (num_bebes > num_adultos){
				alert('No puede haber más de un bebé por adulto.');
				return;
		} 

		//pintamos los campos de los adultos
		for (i=0;i<num_adultos;i++){
			a = i + 1
			document.getElementById('TRAVELLER_TYPE_'+a).value = "ADT";
		}
		
		//pintamos los campos de los adultos
		for (j=0;j<num_ninyos;j++){
			b = j + 1
			document.getElementById('TRAVELLER_TYPE_'+(b+a)).value = "CHD";
		}

		//pintamos los campos de los adultos
		for (k=0;k<num_bebes;k++){
			c = k + 1
			document.getElementById('HAS_INFANT_'+c).value = "TRUE";
//			campos += '<input type="hidden" name="HAS_INFANT_'+c+'" value="TRUE"><BR>';
		}
//		document.getElementById('campos').innerHTML = campos;
//		alert(document.getElementById('campos').innerHTML);
	}

	/***** CREA LOS CAMPOS PARA LOS VIAJEROS ******/
	
	/***** INSERTO LAS FECHAS DE SALIDA Y LLEGADA *****/
	var fecha = new Date();
	var mes_actual = fecha.getMonth() + 1;
	var anyo_actual = fecha.getFullYear();
	var dia_actual = fecha.getDate();


	var dia_salida, mes_salida, anyo_salida, hora_salida;
	var dia_llegada, mes_llegada, anyo_llegada, hora_llegada;
	
	var fecha_salida = "";
	var fecha_llegada = "";

	//recojo los datos de la salida y formo el formato de la fecha
	dia_salida = document.getElementById('dia_inicio').options[document.getElementById('dia_inicio').selectedIndex].value;
	mes_salida = document.getElementById('mes_inicio').options[document.getElementById('mes_inicio').selectedIndex].value;
	anyo_salida = document.getElementById('anyo_inicio').options[document.getElementById('anyo_inicio').selectedIndex].value;
	fecha_salida = anyo_salida + mes_salida + dia_salida + '0000';

	//Comprueba que la fecha de salida es correcta
	if (anyo_actual == anyo_salida){
			if(mes_salida < mes_actual){
					alert('La fecha de salida no puede ser anterior a la fecha actual.');
					return;
			} 
			if ((mes_salida == mes_actual) && (dia_salida < dia_actual)){
					alert('La fecha de salida no puede ser anterior a la fecha actual.');
					return;
			}
	}
	
if ( document.formVuelos.TRIP_TYPE[0].checked == true){
	/*** ESTO SE DEBE CONTROLAR  **/
	//recojo los datos de la llegada y formo el formato de la fecha
	dia_llegada = document.getElementById('dia_fin').options[document.getElementById('dia_fin').selectedIndex].value;
	mes_llegada = document.getElementById('mes_fin').options[document.getElementById('mes_fin').selectedIndex].value;
	anyo_llegada = document.getElementById('anyo_fin').options[document.getElementById('anyo_fin').selectedIndex].value;
	fecha_llegada = anyo_llegada + mes_llegada + dia_llegada + '0000';

	//Comprueba que la fecha de llegada es correcta
	if (anyo_actual == anyo_llegada){
			if(mes_llegada < mes_actual){
					alert('La fecha de vuelta no puede ser anterior a la fecha actual.');
					return;
			}
			if ((mes_llegada == mes_actual) && (dia_llegada < dia_actual)){
					alert('La fecha de vuelta no puede ser anterior a la fecha actual.');
					return;
			}
	}

	//Comprueba que la fecha de llegada no es anterior a la de salida
	if (anyo_salida > anyo_llegada){
			alert('La fecha de vuelta no puede ser anterior a la fecha de salida.');
			return;
	}
	if (anyo_salida == anyo_llegada){
			if(mes_llegada < mes_salida){
					alert('La fecha de vuelta no puede ser anterior a la fecha de salida.');
					return;
			}
			if ((mes_llegada == mes_salida) && (dia_llegada < dia_salida)){
					alert('La fecha de vuelta no puede ser anterior a la fecha de salida.');
					return;
			}
	}

/*** ESTO SE DEBE CONTROLAR  **/
}

	//asigno los valores a los campos del form
	document.getElementById('B_DATE_1').value = fecha_salida;
	document.getElementById('B_DATE_2').value = fecha_llegada;



	/***** INSERTO LAS FECHAS DE SALIDA Y LLEGADA *****/

	document.formVuelos.submit();
	
}




function abreLugar(tipo){
	var obj = document.getElementById(tipo+'_LOCATION_1');
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	objeto_y = curtop;
//	alert(curtop);
	objeto_x = curleft;
//	alert(curleft);
//	return [curleft,curtop];

	document.getElementById('lugar_'+tipo).style.top = curtop +'px' ;
	document.getElementById('lugar_'+tipo).style.left = curleft + 140 +'px' ;
	document.getElementById('lugar_'+tipo).style.display = "block";
	

//	window.open("calendario.aspx?tipo="+tipo,"Calendario","width=240 height=240 titlebar=0");

}


function searchAmadeus(tipo){
	
	document.getElementById('buscadorvuelos').style.display = 'none';
	document.getElementById('buscadorhoteles').style.display = 'none';
	document.getElementById('buscadoralquiler').style.display = 'none';
	
	document.getElementById('buscador' + tipo).style.display = 'block';
	
	
	
	document.getElementById('btnvuelos').src = document.getElementById('btnvuelos').src.replace('-over','');
	document.getElementById('btnhoteles').src = document.getElementById('btnhoteles').src.replace('-over','');
	document.getElementById('btnalquiler').src = document.getElementById('btnalquiler').src .replace('-over','');
	
	var imagen = document.getElementById('btn' + tipo).src;
	var imagenOver = imagen.substring(0, imagen.length - 4) + "-over" +  imagen.substring(imagen.length -  4, imagen.length);
	document.getElementById('btn' + tipo).src = imagenOver;
	
	
}

function reiniciaCapas(){
	window.parent.document.getElementById('calendario_inicio').style.display = 'none';
	window.parent.document.getElementById('calendario_fin').style.display = 'none';
	window.parent.document.getElementById('frameInicio').src = 'calendario.aspx?tipo=inicio';
	window.parent.document.getElementById('frameFin').src = 'calendario.aspx?tipo=fin';
}

function pedir(cual){	
	var p,i;
	i = document.getElementById('pk_info'+cual).value;
	p = document.getElementById('pk_pedidos'+cual).value;
//	i=eval('document.getElementById('pk_info''+cual'.value');
//	p=eval('document.pedidos'+cual+'.pk_pedidos'+cual+'.value');
	window.open('actualizer/pedidos/pedidos_va01.asp?pk_fotos='+cual+'&pk_info='+i+'&pk_pedidos='+p,'pedido','scrollbars=yes,width=620,height=650,top=40,left=30,status=no,toolbar=no,menubar=no,location=no,titlebar=0,resizable=no, fullscreen = no ');
}
/*function pedir(idProd, refProd){	
	var p;
	p=document.getElementById("pk_pedidos"+idProd).value;
	window.open('actualizer/pedidos/pedidos_va01.asp?pk_fotos='+idProd+'&pk_pedidos='+p+'&pk_referencia='+refProd,'pedido','scrollbars=yes,width=640,height=640,top=0,left=0,status=no,toolbar=no,menubar=no,location=no,titlebar=0,resizable=no, fullscreen = no ');
	
}*/
function pedir2(cual){	
	var p;
	p=document.getElementById("pedidos").pk_pedidos.value;
	window.open('actualizer/pedidosTPV/pedidos_va01.asp?pk_fotos='+cual+'&pk_pedidos='+p,'pedido','scrollbars=yes,width=640,height=640,top=0,left=0,status=no,toolbar=no,menubar=no,location=no,titlebar=0,resizable=no, fullscreen = no ');
	
}

/********************************************/


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;
	}
}