
/****************************************************************
/ 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));
	
}

/****************************************************************
/ 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{
		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").provincia.value == "" ) {
		texto+=" * Debe indicar su provincia.<br>";
		texto_en+=" * You must enter your province.<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+="&provincia=" + document.getElementById("formularioContacto").provincia.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{
		cadenaEnvio+="&comentarios=" + document.getElementById("formularioContacto").comentarios.value;
	}	
	
	//Aqui vamos añadiendo los demas campos sino estan vacion
	//alert(texto);

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").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
	//}
	
	  //  cadenaEnvio+="&ref=" + document.getElementById("formularioContacto").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(texto);
		//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();
	}    
}



function ValidarFecha(Cadena){
	var Fecha= new String(Cadena)	// Crea un string
	var RealFecha= new Date()	// Para sacar la fecha de hoy
	// Cadena Año
	var Ano= new String(Fecha.substring(Fecha.lastIndexOf("/")+1,Fecha.length))
	// Cadena Mes
	var Mes= new String(Fecha.substring(Fecha.indexOf("/")+1,Fecha.lastIndexOf("/")))
	// Cadena Día
	var Dia= new String(Fecha.substring(0,Fecha.indexOf("/")))

	// Valido el año
	if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900){
        	//alert('Año inválido')
		return false
	}
	// Valido el Mes
	if (isNaN(Mes) || Mes.length<2 || parseFloat(Mes)<1 || parseFloat(Mes)>12){
	//alert(parseInt(Mes));
		//alert('Mes inválido')
		return false
	}
	// Valido el Dia
	if (isNaN(Dia) || Dia.length<2 || parseFloat(Dia)<1 || parseFloat(Dia)>31){
		//alert(parseInt(Dia));
		//alert('Día inválido')
		return false
	}
	if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) {
		if (Mes==2 && Dia > 28 || Dia>30) {
			//alert('Día inválido')
			return false
		}
	}
	
  //para que envie los datos, quitar las  2 lineas siguientes
  //alert("Fecha correcta.")
  return true	
}





/****************************************************************
/ 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
	
	var formRegistro = document.getElementById("formRegistro");
	
	
	if ( formRegistro.user.value == "" ) {
		texto+=" * Debe indicar su usuario\n";
	}
	if ( formRegistro.user.value.length < 3  ) {
		texto+=" * Debe indicar 3 letras mínimo de usuario\n";
	}
	
	if ( formRegistro.pass1.value =="" ) {
		texto+=" * Debe indicar contraseña\n";
	}
	
	if ( formRegistro.pass1.value != formRegistro.pass_confirm.value ) {
		texto+=" * Debe indicar la misma contraseña\n";
	}
	
	if (formRegistro.pass1.value.length < 5 ) {
		texto+=" * Debe indicar un mínimo de 5 carácteres en el password\n";
	}
	
	
	if (formRegistro.nombre.value.length < 3 ) {
		texto+=" * Debe indicar un mínimo de 3 letras para su nombre\n";
	}
	
	if (formRegistro.nombre.value == "" ) {
		texto+=" * Debe indicar su nombre\n";
	}
	
	if (formRegistro.primer_apellido.value.length < 3 ) {
		texto+=" * Debe indicar un mínimo de 3 letras para su primer apellido\n";
	}
	
	if (formRegistro.primer_apellido.value == "" ) {
		texto+=" * Debe indicar su primer apellido\n";
	}
	
	if (formRegistro.segundo_apellido.value == "" ) {
		texto+=" * Debe indicar su segundo apellido\n";
	}
	
	if (formRegistro.segundo_apellido.value.length < 3 ) {
		texto+=" * Debe indicar un mínimo de 3 letras para su segundo apellido\n";
	}
	
	if (formRegistro.email.value == "" ) {
		texto+=" * Debe indicar su e-mail.\n";
	}
	
	if(formRegistro.email.value!=""){
		if(!validarEmail(formRegistro.email.value)){
				texto+=" * Formato de E-mail incorrecto.\n";
		}
	}
	
	if(formRegistro.fnacimiento.value!=""){
	//para controlar que las fechas sean correctas
		
	if (!ValidarFecha(formRegistro.fnacimiento.value)){
		texto+=" * La fecha introducida es incorrecta.\n";
	}}
	
	if (formRegistro.condiciones.checked == false ) {
		texto+=" * Debe aceptar las condiciones legales.\n";
	}
	
	var email = formRegistro.email.value;
	var nick = formRegistro.user.value;
	
		if ( texto != "" ){
				alert(texto);
		}else{
			//http.open("GET", "registro/compruebaEmail.asp?email=" + email +"&nick=" + nick, true);
			//document.getElementById("mensaje-exito").innerHTML="";
		   // document.getElementById("mensajeError").innerHTML="";
		   // document.getElementById("capaError").style.display='none';
		    http.open("GET", "registro/compruebaEmail.asp?email=" + email +"&nick=" + nick, true);
			http.onreadystatechange = handleHttpResponseComprobar;
			http.send(null);
			
		}
	
	
}


function validarDatosUser(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").user.value == "" ) {
		texto+=" * Debe indicar su usuario\n";
	}
	
	if ( document.getElementById("formRegistro").pass1.value =="" ) {
		texto+=" * Debe indicar contraseña\n";
	}
	
	if ( document.getElementById("formRegistro").pass1.value != document.getElementById("formRegistro").pass_confirm.value ) {
		texto+=" * Debe indicar la misma contraseña\n";
	}
	
	/*if ( document.getElementById("formRegistro").pregunta.value == "pregunta" ) {
		texto+=" * Debe elegir una pregunta\n";
	}
	
	if ( document.getElementById("formRegistro").respuesta.value == "" ) {
		texto+=" * Debe indicar una respuesta\n";
	}*/
	
	if ( document.getElementById("formRegistro").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre\n";
	}
	
	if ( document.getElementById("formRegistro").primer_apellido.value == "" ) {
		texto+=" * Debe indicar su primer apellido\n";
	}
	
	if ( document.getElementById("formRegistro").segundo_apellido.value == "" ) {
		texto+=" * Debe indicar su segundo apellido\n";
	}
	
	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";
		}
	}
	
	if(document.getElementById("formRegistro").fnacimiento.value!=""){
	//para controlar que las fechas sean correctas
		
	if (!ValidarFecha(document.getElementById("formRegistro").fnacimiento.value)){
		texto+=" * La fecha introducida es incorrecta.\n";
	}}
	
	if ( document.getElementById("formRegistro").condiciones.checked == false ) {
		texto+=" * Debe aceptar las condiciones legales.\n";
	}
	
	var email = document.getElementById("formRegistro").email.value;
	var nick = document.getElementById("formRegistro").user.value;
	
		if ( texto != "" ){
				alert(texto);
		}else{
			//http.open("GET", "registro/compruebaEmail.asp?email=" + email +"&nick=" + nick, true);
			//document.getElementById("mensaje-exito").innerHTML="";
		   // document.getElementById("mensajeError").innerHTML="";
		   // document.getElementById("capaError").style.display='none';
		    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
		
				//alert(http.responseText);
				//document.getElementById("formRegistro").op.value = 0;
				//document.formRegistro.submit();
				
		        document.formRegistro.submit();
				//document.getElementById("formRegistro").reset();
		
	}    
}


/****************************************************************
/ 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;
		//alert(idReferencia = document.getElementById("pk_info"+id).value);
		//alert(document.getElementById("enlace_"+id).href);
		var aux=document.getElementById("enlace_"+id).href;
		var pos=aux.lastIndexOf("&ref");
		if (pos!=-1){
		    var pos2=aux.substring(0,pos);
		    var cadena=pos2 + "&ref=" + idReferencia
		}else{
		    var cadena=aux + "&ref=" + idReferencia
		}
		document.getElementById("enlace_"+id).href = cadena;
		//alert(document.getElementById("enlace_"+id).href);
		var aux=document.getElementById("enlace_imagen_"+id).href;
		var pos=aux.lastIndexOf("&ref");
		if (pos!=-1){
		    var pos2=aux.substring(0,pos);
		    var cadena=pos2 + "&ref=" + idReferencia
		}else{
		    var cadena=aux + "&ref=" + idReferencia
		}
		document.getElementById("enlace_imagen_"+id).href = cadena;
		var aux=document.getElementById("enlace_titulo_"+id).href;
		var pos=aux.lastIndexOf("&ref");
		if (pos!=-1){
		    var pos2=aux.substring(0,pos);
		    var cadena=pos2 + "&ref=" + idReferencia
		}else{
		    var cadena=aux + "&ref=" + idReferencia
		}
		document.getElementById("enlace_titulo_"+id).href = cadena
		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] != ""){
		   // alert(contenido[0]);
			document.getElementById("imagen_"+id).src ="includes/ajustarImg.asp?img=../actualizer/catalogoCompleto/fotos/" + contenido[0];	
		}
		//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";
		}
}

function muestraTemaWiki(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 = "wiki-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 = "wiki-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 autentifica3(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.formLogin3[campo].value;
			if (   (valor == '') || (valor == mensajes[i])  ) {
				document.formLogin3[campo].value = mensajes[i];
				valid = false;
			}else{
				strEnvio += "" + campos[i] + "=" + document.formLogin3[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 e = http.responseText;
		if (e=='si'){
			//window.location.href = 'extranet.asp?pagina=ex';
			window.location.href = 'index.asp';
			//window.location.href = 'index.asp?pagina=login';
		} else {
			if (e=='fuera'){
				window.location.href = 'index.asp';
				}else{
		document.getElementById("respuesta").innerHTML = http.responseText ;	
		document.getElementById("respuesta").style.display = "block";	
			}
		}
	}    
}



/*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 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 == " Buscar en el sitio") || (document.getElementById("textobusqueda").value == "")){
		alert("Introduzca el texto de búsqueda");
	}
	else{
		document.getElementById("busqueda").cadenaBusqueda.value=document.getElementById("textobusqueda").value
		document.getElementById("busqueda").submit()
	}				
}


function searchOnWebbusqueda(){			
    
	if (document.getElementById("palabra").value == ""){
		alert("Introduzca el texto de búsqueda");
	}
	else{
		document.getElementById("busqueda1").cadenaBusqueda.value=document.getElementById("palabra").value;
		document.getElementById("busqueda1").cadenaBusquedaa.value=document.getElementById("buscar_por").value;
		
		document.getElementById("busqueda1").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 == "") || (document.getElementById("formularioSuscripcion").nombre.value == "Nombre") ) {
		texto+=" * Debe indicar su nombre.<br>";
		texto_en+=" * You must enter your first 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").apellido.value == "") || (document.getElementById("formularioSuscripcion").apellido.value == "Apellido") ) {
		texto+=" * Debe indicar su apellido.<br>";
		texto_en+=" * You must enter your last 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+="&apellidos=" + document.getElementById("formularioSuscripcion").apellido.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;
		}
	}

	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("contenidoSuscripcion").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("contenidoSuscripcion").style.display = "block";	
		document.getElementById("formularioSuscripcion").reset();
	}    
}
function cerrarAvisoSuscripcion() {
	  document.getElementById("contenidoSuscripcion").style.display="none";
}

function blancoNombre(lang){
		document.getElementById("contenidoSuscripcion").style.display="none";
	switch (lang) 
	{ 
		case 'es': 
			if (document.getElementById('nombre').value == 'Nombre'){document.getElementById('nombre').value = '';}
	
			if (document.getElementById('apellido').value == ''){document.getElementById('apellido').value = 'Apellido';}
			if (document.getElementById('email').value == ''){document.getElementById('email').value = 'E-mail';}
		case 'en':
			if (document.getElementById('nombre').value == ' First name'){document.getElementById('nombre').value = '';}
	
			if (document.getElementById('apellido').value == ''){document.getElementById('apellido').value = ' Last name';}
			if (document.getElementById('email').value == ''){document.getElementById('email').value = ' E-mail';}
	}
}
function blancoApellido(lang){
	switch (lang) 
	{ 
		case 'es':
			if (document.getElementById('apellido').value == 'Apellido'){document.getElementById('apellido').value = '';}
			
			if (document.getElementById('nombre').value == ''){document.getElementById('nombre').value = 'Nombre';}
			if (document.getElementById('email').value == ''){document.getElementById('email').value = 'E-mail';}
		case 'en':
			if (document.getElementById('apellido').value == ' Last name'){document.getElementById('apellido').value = '';}
	
			if (document.getElementById('nombre').value == ''){document.getElementById('nombre').value = ' First name';}
			if (document.getElementById('email').value == ''){document.getElementById('email').value = ' E-mail';}
	}
}
function blancoEmail(lang){
	switch (lang) 
	{ 
		case 'es':
			if (document.getElementById('email').value == 'E-mail'){document.getElementById('email').value = '';}
			
			if (document.getElementById('nombre').value == ''){document.getElementById('nombre').value = 'Nombre';}
			if (document.getElementById('apellido').value == ''){document.getElementById('apellido').value = 'Apellido';}
		case 'en':
			if (document.getElementById('email').value == ' E-mail'){document.getElementById('email').value = '';}
	
			if (document.getElementById('nombre').value == ''){document.getElementById('nombre').value = ' First name';}
			if (document.getElementById('apellido').value == ''){document.getElementById('apellido').value = ' Last name';}
	}
}

function blancoBuscador(){
	if (document.getElementById('textobusqueda').value == ' Buscar en el sitio' || document.getElementById('textobusqueda').value == ' Search on the web') {
		document.getElementById('textobusqueda').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{
		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{
		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: 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;

	}
}
/***************************************************************/


function showSiteMap(){
	document.getElementById("mapaweb").style.display = "block";
	document.getElementById("EnlaceMapa").style.background = "#CCCCCC";
}

function showSiteMapOver(){
    capa_visible=true;
	document.getElementById("mapaweb").style.display = "block";
}

function hideAll(){
	capa_visible = false;
	setTimeout('hideSiteMap();',1500);
}

function hideAllOver(){
	if (capa_visible == true){
	    capa_visible =false;
	}else{
	    capa_visible=false;
	}
	setTimeout('hideSiteMap();',1500);
}

function hideSiteMap(){
    if (!capa_visible){
	    document.getElementById("mapaweb").style.display = "none";
	document.getElementById("EnlaceMapa").style.background = "#FFFFFF";
	}    
}


function cambiarProducto(){
    var id=document.getElementById("prodserie").value;
    //producto=document.getElementById("productosSerie" + id).producto.value;
    //galeria=document.getElementById("productosSerie" + id).galeria.value;
    //numPagina=document.getElementById("productosSerie" + id).numPagina.value;
    //ref=document.getElementById("productosSerie" + id).ref.value;
    //subpagina=document.getElementById("productosSerie" + id).subpagina.value;
    //document.location.href="index.asp"
    document.getElementById("productosSerie" + id).submit();
    
}


function changeDistribuidores(){
	var element = document.getElementById('distribuidoresList');
	var valor = element.options[document.getElementById('distribuidoresList').selectedIndex].value;
	
	valores = valor.split("|");
	
	if(valores.length != 0){
		var url = "?pagina=contactos&amp;pais=" + valores[1] + "&amp;tipo=20&amp;b=1&amp;";
		document.location= url;
	}
	return false;
}

function validar2(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{
		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").provincia.value == "Seleccione Provincia" ) && ( document.getElementById("prov").style.display == "block" )){
		texto+=" * Debe indicar su provincia.<br>";
		texto_en+=" * Debe indicar su provincia.<br>";
		texto_fr+=" * Vous devez indiquer l'objet de votre demande.<br>";
		texto_val+=" * Deu incloure el motiu de la seua consulta.<br>";
	}
	
	cadenaEnvio+="&provincia=" + document.getElementById("formularioContacto").provincia.options[document.getElementById("formularioContacto").provincia.selectedIndex].text

	if (( document.getElementById("formularioContacto").pais.value == "Seleccione Pais" ) && ( document.getElementById("pai").style.display == "block" )){
		texto+=" * Debe indicar su país.<br>";
		texto_en+=" * You must enter your country.<br>";
		texto_fr+=" * Vous devez indiquer l'objet de votre demande.<br>";
		texto_val+=" * Deu incloure el motiu de la seua consulta.<br>";
	}
	
	cadenaEnvio+="&pais=" + document.getElementById("formularioContacto").pais.options[document.getElementById("formularioContacto").pais.selectedIndex].text
		

	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{
		cadenaEnvio+="&comentarios=" + document.getElementById("formularioContacto").comentarios.value;
	}	
	
	//Aqui vamos añadiendo los demas campos sino estan vacion
	
	if ( document.getElementById("formularioContacto").telefono.value != "" ){
		cadenaEnvio+="&telefono=" + document.getElementById("formularioContacto").telefono.value;
	}
	
//	cadenaEnvio+="&pais=" + document.getElementById("formularioContacto").pais.options[document.getElementById("formularioContacto").pais.selectedIndex].text
	
//	cadenaEnvio+="&provincia=" + document.getElementById("formularioContacto").provincia.options[document.getElementById("formularioContacto").provincia.selectedIndex].text
	
	cadenaEnvio+="&actividad=" + document.getElementById("formularioContacto").actividad.options[document.getElementById("formularioContacto").actividad.selectedIndex].text
	
	cadenaEnvio+="&ref=" + document.getElementById("formularioContacto").ref.value;
	
	cadenaEnvio+="&submodo=" + document.getElementById("formularioContacto").submodo.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/envioSinBd2.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseContacto;
		http.send(null);
	}
	
}


function validar3(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{
		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{
		cadenaEnvio+="&comentarios=" + document.getElementById("formularioContacto").comentarios.value;
	}	
	
	//Aqui vamos añadiendo los demas campos sino estan vacion
	
	if ( document.getElementById("formularioContacto").telefono.value != "" ){
		cadenaEnvio+="&telefono=" + document.getElementById("formularioContacto").telefono.value;
	}
	
	cadenaEnvio+="&provincia=" + document.getElementById("formularioContacto").provincia.options[document.getElementById("formularioContacto").provincia.selectedIndex].text
	
	cadenaEnvio+="&pais=" + document.getElementById("formularioContacto").pais.options[document.getElementById("formularioContacto").pais.selectedIndex].text
	
	cadenaEnvio+="&asunto=" + document.getElementById("formularioContacto").asunto.options[document.getElementById("formularioContacto").asunto.selectedIndex].text
	
	cadenaEnvio+="&ref=" + document.getElementById("formularioContacto").ref.value;
	
	cadenaEnvio+="&submodo=" + document.getElementById("formularioContacto").submodo.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/envioSinBd3.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseContacto;
		http.send(null);
	}
	
}


/****************************************************************************************
/ Nombre: changePicture
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Cambia una imagen
'***************************************************************************************/
function changePictureTooltip(id, picture, tooltip){
		
		document.getElementById(id).src = picture;
		document.getElementById(id).alt= tooltip;
}


function buscarContactos(){
    document.getElementById("formularioContactosBusc").submit();
}

var idGlobal="";

function soporteBusc1(){
  
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getModelos.asp?id=" + document.getElementById("soporteBuscador1").series.value, true);
	    http.onreadystatechange = handleHttpResponseSoporteBusc1;
	    http.send(null);
	//}
}

function soporteBusc1Prod(){
  
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getProductos.asp?id=" + document.getElementById("soporteBuscador1").modelo.value, true);
	    http.onreadystatechange = handleHttpResponseSoporteBusc1Prod;
	    http.send(null);
	//}
}

function soporteBusc1Doc(){
  
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getDocumentos.asp?id=" + document.getElementById("soporteBuscador1").producto.value, true);
	    http.onreadystatechange = handleHttpResponseSoporteBusc1Doc;
	    http.send(null);
	//}
}

function soporteBusc2(){
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getModelos2.asp?id=" + document.getElementById("soporteBuscador1").series.value, true);
	    http.onreadystatechange = handleHttpResponseSoporteBusc2;
	    http.send(null);
	//}
}

function soporteBusc3(){
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getModelos3.asp?id=" + document.getElementById("soporteBuscador1").series.value, true);
	    http.onreadystatechange = handleHttpResponseSoporteBusc3;
	    http.send(null);
	//}
}

function soporteBusc2Rec(id){
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getModelos2Rec.asp?id=" + id, true);
	    http.onreadystatechange = handleHttpResponseSoporteBusc2;
	    http.send(null);
	//}
}

function soporteBusc3Rec(id){
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getModelos3Rec.asp?id=" + id, true);
	    http.onreadystatechange = handleHttpResponseSoporteBusc3;
	    http.send(null);
	//}
}

function soporteBusc2Prod(){
  
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getProductos2.asp?id=" + document.getElementById("soporteBuscador1").modelo.value, true);
	    http.onreadystatechange = handleHttpResponseSoporteBusc2Prod;
	    http.send(null);
	//}
}

function soporteBusc3Prod(){
  
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getProductos3.asp?id=" + document.getElementById("soporteBuscador1").modelo.value, true);
	    http.onreadystatechange = handleHttpResponseSoporteBusc3Prod;
	    http.send(null);
	//}
}

function soporteBusc2Rec2(){
  
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getProductos2Rec.asp?id=" + document.getElementById("soporteBuscador1").modelo.value, true);
	    http.onreadystatechange = handleHttpResponseSoporteBusc2Prod;
	    http.send(null);
	//}
}

function soporteBusc3Rec3(){
  
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getProductos3Rec.asp?id=" + document.getElementById("soporteBuscador1").modelo.value, true);
	    http.onreadystatechange = handleHttpResponseSoporteBusc3Prod;
	    http.send(null);
	//}
}

function cambiaRecambios(){
   // if (document.getElementById("soporteBuscador1").series.value!=0){
   idGlobal=document.getElementById("soporteBuscador1").encuentre.value;
   if (idGlobal==1){
    document.getElementById("capaVisibleModelo").style.display='block';
  }
   if (idGlobal==2){
    document.getElementById("capaVisibleModelo").style.display='none';
   }
   
        http.open("GET", "includes/getRecambios.asp?id=" + document.getElementById("soporteBuscador1").encuentre.value, true);
	    http.onreadystatechange = handleHttpResponseCambiaRecambios;
	    http.send(null);
	//}
}

function cambiaAccesorios(){
   // if (document.getElementById("soporteBuscador1").series.value!=0){
    idGlobal=document.getElementById("soporteBuscador1").encuentre.value;
    if (idGlobal==1){
    document.getElementById("capaVisibleModelo").style.display='block';
  }
   if (idGlobal==3){
    document.getElementById("capaVisibleModelo").style.display='none';
   }
        http.open("GET", "includes/getAccesorios.asp?id=" + document.getElementById("soporteBuscador1").encuentre.value, true);
	    http.onreadystatechange = handleHttpResponseCambiaAccesorios;
	    http.send(null);
	//}
}

function handleHttpResponseSoporteBusc1() {
	if (http.readyState == 4) {    	
		document.getElementById("capaSelectModelo").innerHTML=http.responseText;	
	}    
}

function handleHttpResponseSoporteBusc1Prod() {
	if (http.readyState == 4) {    	
		document.getElementById("capaSelectProducto").innerHTML=http.responseText;	
	}    
}

function handleHttpResponseSoporteBusc1Doc() {
	if (http.readyState == 4) {    	
		document.getElementById("capaSelectDocumento").innerHTML=http.responseText;	
	}    
}

function handleHttpResponseSoporteBusc2() {
	if (http.readyState == 4) {    
		document.getElementById("capaSelectModelo").innerHTML=http.responseText;	
	}    
}

function handleHttpResponseSoporteBusc2Prod() {
	if (http.readyState == 4) {    	
		document.getElementById("capaSelectProducto").innerHTML=http.responseText;	
	}    
}

function handleHttpResponseSoporteBusc3Prod() {
	if (http.readyState == 4) {    	
		document.getElementById("capaSelectProducto").innerHTML=http.responseText;	
	}    
}

function handleHttpResponseSoporteBusc3() {
	if (http.readyState == 4) {    
		document.getElementById("capaSelectModelo").innerHTML=http.responseText;	
	}    
}

function handleHttpResponseCambiaRecambios() {
	if (http.readyState == 4) {    	
		document.getElementById("capaSelectSeries").innerHTML=http.responseText;
	
		if (idGlobal==2){
		    soporteBusc2Rec(idGlobal);
		}	
	}    
}

function handleHttpResponseCambiaAccesorios() {
	if (http.readyState == 4) {    	
		document.getElementById("capaSelectSeries").innerHTML=http.responseText;
	
		if (idGlobal==3){
		    soporteBusc3Rec(idGlobal);
		}	
	}    
}

function buscador1(){
    document.getElementById("soporteBuscador1").submit();
}


function changeNoticiasTipos(){
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getNoticiasTemas.asp?seccion=" + document.getElementById("tipo").value, true);
	    http.onreadystatechange = handleHttpResponseTipos;
	    http.send(null);
	//}
}

function handleHttpResponseTipos() {
	if (http.readyState == 4) {    	
		document.getElementById("noticiasTemas").innerHTML=http.responseText;	
	}    
}

function changeSeries(){
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getSeries.asp?id=" + document.getElementById("serie").value, true);
	    http.onreadystatechange = handleHttpResponseSeries;
	    http.send(null);
	//}
}

function handleHttpResponseSeries() {
	if (http.readyState == 4) {    	
		document.getElementById("capaProductos").innerHTML=http.responseText;	
	}    
}




function BuscarNoticias() {
	document.getElementById("formularioNoticias").submit()    
}



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 - 128 +'px' ;
	document.getElementById('calendario_'+tipo).style.display = "block";
	

//	window.open("calendario.aspx?tipo="+tipo,"Calendario","width=240 height=240 titlebar=0");

}

function reiniciaCapas(){
	window.parent.document.getElementById('calendario_inicio').style.display = 'none';
	window.parent.document.getElementById('frameInicio').src = 'calendario.aspx?tipo=inicio';
}

function muestraAviso(id){
    document.getElementById("capaAviso" + id).style.display="block";
}

function quitarAviso(id){
    document.getElementById("capaAviso" + id).style.display="none";
}

function muestraAviso2(id){
    document.getElementById("capaAvisoFicha" + id).style.display="block";
}

function quitarAviso2(id){
    document.getElementById("capaAvisoFicha" + id).style.display="none";
}


function help(mesage){
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getMessages.asp?message=" + mesage, true);
	    http.onreadystatechange = handleHttpResponseHelp;
	    http.send(null);
	//}
}

function handleHttpResponseHelp() {
	if (http.readyState == 4) {    	
		document.getElementById("help").innerHTML=http.responseText;	
		document.getElementById("help").style.display= "block";	
	}    
}

function cierraCapa(capa){
		document.getElementById(capa).style.display= "none";	
}
//**********************************
//Para crera el  PDF de las noticias
//**********************************
function CreaPdf(num){

	if(num!="")
	{
		var strUrl="pdf/creaPdf.asp?id="+num+"&tabla=TAP4NBS"
		http.open("GET", strUrl, false);    
		http.onreadystatechange = handleHttpResponsePdf;
		http.send(null);  
	}		
}

//Crear el PDF
function handleHttpResponsePdf() {
	if (http.readyState == 4) {    	
		strResul=http.responseText;
		strResul=strResul.substring(0,3)		
		if(strResul=="pdf")
		{		
			window.open(http.responseText, "Pdf", "");
		}
		else
		{
			alert(http.responseText)
		}
	}    
}

//**********************************

/****************************************************************
/ Nombre: imprimirCV
/ Implentacion 
/ Revision: 120907
/ Descripcion: imprimir el cv
'***************************************************************/
function imprimirNoticia(id){
    var base=document.getElementById("base").innerHTML;
    var estilo=document.getElementById("estilosPrincipal").href
    document.getElementById("estilosPrincipal").href="css/imprimir.css";
    var v=document.getElementById("contenidos").innerHTML;
    document.getElementById("base").innerHTML=v;
    document.getElementById("capaOcultar").style.display='none';
    document.getElementById("capaOcultar2").style.display='none';
    document.getElementById("capaOcultar3").style.display='none';
    window.print();
    document.getElementById("estilosPrincipal").href=estilo;
    document.getElementById("base").innerHTML=base;
}


function imprimirProducto(id){
    var base=document.getElementById("base").innerHTML;
    var estilo=document.getElementById("estilosPrincipal").href
    document.getElementById("estilosPrincipal").href="css/imprimir.css";
    var v=document.getElementById("contenidos").innerHTML;
    document.getElementById("base").innerHTML="<div   align='center'><div style='border:1px solid #CFCFCF; width:800px; '>" + v + "</div></div>";
    document.getElementById("cabeceraImprimir").style.display='block'; //fperez 17/01/08
    document.getElementById("documentacion").style.display='none';
    document.getElementById("referencias").style.display='none';
    document.getElementById("catalogoNavegacion").style.display='none';
    document.getElementById("capaOcultar3").style.display='none';
    window.print();
    document.getElementById("estilosPrincipal").href=estilo;
    document.getElementById("cabeceraImprimir").style.display='none'; //fperez 17/01/08
    document.getElementById("base").innerHTML=base;
}

/****************************************************************
/ Nombre: FUNCIONES PARA ENVIAR EL CURRICULUM POR EMAIL
/ Implentacion 
/ Revision: 120907
/ Descripcion: imprimir el cv
'***************************************************************/

function enviarEmail2(){
    document.getElementById("capaEnviarEmail").style.display="block";
}

function enviarNoticia(numero){
    var texto="";
    if (document.getElementById("cajaEnvioEmail2").value==""){
        texto+=" * Debe insertar su nombre.<br/>"
    }
    if (document.getElementById("cajaEnvioEmail").value==""){
        texto+=" * Debe insertar un email.<br/>"
    }
    
    if(document.getElementById("cajaEnvioEmail").value!=""){
		if(!validarEmail(document.getElementById("cajaEnvioEmail").value)){
				texto+=" * Formato de E-mail incorrecto.<br/>";
		}
	}
	
	if (texto!=""){
	    document.getElementById("mensajeError").innerHTML=texto;
	}else{
	    
	    http.open("GET", "includes/enviarEmail.asp?id=" + numero + "&email=" + document.getElementById("cajaEnvioEmail").value + "&nombre=" + document.getElementById("cajaEnvioEmail2").value, true);
        http.onreadystatechange = handleHttpResponseEnviarEmail;
        http.send(null);
	}			
}

function handleHttpResponseEnviarEmail() {
	if (http.readyState == 4) {    
        document.getElementById("mensajeError").innerHTML=http.ResponseText;
        document.getElementById("cajaEnvioEmail").value="";
        // window.print() 
        //document.location="index.asp?pagina=candidatos&subpagina=vista-previa"
    }    
}

function cerrarAvisoEmail(){
    document.getElementById("capaEnviarEmail").style.display="none";
}

function cerrarAvisoRegistro(){
    document.getElementById("mensaje-exito").style.display="none";
}

function cerrarAvisoYaRegistro(){
    document.getElementById("mensaje-ya-registro").style.display="none";
}

function cambiaClaseGal(id){
    document.getElementById("galeria"+id).className="galeriaHover";
}

function quitaClaseGal(id){
        document.getElementById("galeria"+id).className="galeria";
		
		
}

function cargaGaleria(tema,galeria,lang,d){
    document.location="index.asp?pagina=productos&lang=" + lang + "&subpagina=" + tema + "&galeria=" + galeria + "&d=" + d
}


/* FUNCIONES PARA AMPLIAR LAS IMAGENES DE LOS PRODUCTOS*/
/* FPEREZ 18/01/08*/

var im, alto2, ancho2, img_y, img_x;
function ampliaProd(imagen){


//				var imagen = "SUBA110.jpg";
				im = imagen;
				document.getElementById('imagenCapaImagen').src = "actualizer/catalogoCompleto/fotos/" + im;
//				img1 = new Image(); 
//			    img1.src = "actualizer/catalogoCompleto/fotos/"+imagen; 
//				alert(img1.src);
				ancho2 = img1.width ;
				alto2 = img1.height + 40;
				document.getElementById('capaImagen').style.width = ancho2+"px";
				document.getElementById('capaImagen').style.height = alto2	+"px";


	var obj = document.getElementById('actualizable');
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}

//	var altoPantalla = window.screen.height;
//	alert(altoPantalla);
	img_y = curtop + 120;
	img_x = curleft + 499 - (ancho2/2);
	img2_y = curtop + 126;
	img2_x = curleft + 505 - (ancho2/2);
	
	
//	alert(imagen);
//				alert(ancho);
//				alert(alto);
//				window.resizeTo(ancho+10,alto+10);
//				document.getElementById('imagenCapaImagen').src = "actualizer/catalogoCompleto/fotos/" + im;
				document.getElementById('capaImagen').style.top = img_y+"px";
				document.getElementById('capaImagen').style.left = img_x+"px";
				document.getElementById('capaCerrar').style.top = img2_y+"px";
				document.getElementById('capaCerrar').style.left = img2_x+"px";
				setTimeout('ampliaProd2()',1000);
}

function ampliaProd2(){
		document.getElementById('capaImagen').style.display = "block";
		document.getElementById('capaCerrar').style.display = "block";
}

function muestraArticulos(){
    document.getElementById("buscador1").className="desmarcado"
    document.getElementById("buscador2").className="desmarcado"
    document.getElementById("buscador3").className="desmarcado"
    document.getElementById("buscador5").className="desmarcado"
    if (document.getElementById("filaContenidoTema1").style.display=="block"){
        document.getElementById("filaContenidoTema1").style.display="none";
    }else{
        document.getElementById("filaContenidoTema1").style.display="block"
        document.getElementById("enlaceTema1").className="marcado"
    }
}







function contactosBusc1(){
  
   // if (document.getElementById("soporteBuscador1").series.value!=0){
        http.open("GET", "includes/getPaisContactoBuscador.asp?id=" + document.getElementById("formularioContactosBusc").tipo.value, true);
	    http.onreadystatechange = handleHttpResponseContactosBusc1;
	    http.send(null);
	//}
}

function handleHttpResponseContactosBusc1() {
	if (http.readyState == 4) {    	
		document.getElementById("capaSelectPais").innerHTML=http.responseText;	
	}    
}

/****************************************************************
/ 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: ShowFilmFrame, ShowFilmFrameOver
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Amplia una imagen de la cartelera
//Al pasar el mouse por encima si esta visible la capa cambia de imagen
'***************************************************************************************/
function ShowFilmFrame(picture){
		
		var url = picture;
		var element = document.getElementById('bigPicture');
          
        if (picture != ''){
                index = url.indexOf('.jpg');
                url = url.substring(0, index + 4);
                url += "&Width=450&Height=250";
                document.getElementById("bigPictureImage").src = '';
                document.getElementById("bigPictureImage").src = url;
                element.style.display = 'block';
                document.getElementById('CloseBigPicture').style.display = 'block';
        }else{
            element.style.display = 'none';
            document.getElementById('CloseBigPicture').style.display = 'none';
        }
}


function ShowFilmFrameOver(picture){

    var element = document.getElementById('bigPicture');
    
    if(element.style.display != 'none'){
        ShowFilmFrame(picture);
    }

}



/****************************************************************************************
/ Nombre: SendToFriend
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Envia un contenido a un amigo
'***************************************************************************************/
function SendToFriend(){
	
		var element = document.getElementById("friendEmail");

		var elementMessage = document.getElementById("message");
		elementMessage.innerHTML = '';
		if(element.value !=''){
			if(validarEmail(element.value)){
	   	         url = "AjaxResponse/SendToFriend.ashx?Email=" + element.value;
				 element.value = '';			 
				 http.open("GET", url , true);
				 http.onreadystatechange = handleHttpResponseSendToFriend;
				 http.send(null);
	
			}else{
				elementMessage.innerHTML = "* Formato de e-mail incorrecto";
				elementMessage.style.color = "#666666";
			}
		}else{
				elementMessage.innerHTML = "* Introduzca un email";
				elementMessage.style.color = "#666666";	
		}
		

}


function handleHttpResponseSendToFriend() {
	if (http.readyState == 4) {
		var elementMessage = document.getElementById("message");
		elementMessage.innerHTML = http.responseText;
		elementMessage.style.color = "#666666";
	}    
}


/****************************************************************************************
/ Nombre: ShowConfirm(), RentingFilm(), handleHttpResponseRentingFilm
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Proceso de alquiler de una pelicula
'***************************************************************************************/

function ShowConfirm(){
	
	var element = document.getElementById("ConfirmMessage");
	
	
	if(element.style.display == 'block'){
		element.style.display = 'none';	
	}else{
		element.style.display = 'block';
	}
	
}

function RentingFilm(id, user){
		var element = document.getElementById("ConfirmMessage");
		var elementMessage = document.getElementById("message");
		
		if (user != null) {
	
			element.style.display = 'none';	
			elementMessage.innerHTML = '';
	
			url = "AjaxResponse/rentFilm.asp?Id=" + id;
			
			http.open("GET", url , true);
			http.onreadystatechange = handleHttpResponseRentingFilm;
			http.send(null);
					  
		}else{
			elementMessage.innerHTML = 'No esta autentificado como usuario';
			elementMessage.style.color = 'Red';
		}
}


function handleHttpResponseRentingFilm() {
	if (http.readyState == 4) {
		var elementMessage = document.getElementById("message");
		elementMessage.innerHTML = http.responseText;
		elementMessage.style.color = "#666666";
		
		url = "index.asp?pagina=login";
		setTimeout("ChangeLocation('" + url + "')", 2000);
		
	}    
}


/****************************************************************************************
/ Nombre: SendComment(), handleHttpResponseSendComment()
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Comentarios de la pelicula
'***************************************************************************************/

function SendComment(producto){
		var elementMessage = document.getElementById("elementMessage");
		var textBoxTitle = document.getElementById("titulo");
		var textBoxComment = document.getElementById("comentario");
		var sec_code = document.getElementById("sec_code");
	
		if (textBoxTitle.value != '' && textBoxComment.value != '') {
			url = "AjaxResponse/comentariosPelicula.asp?Title=" + textBoxTitle.value+ "&Comment=" + textBoxComment.value + "&producto=" + producto + "&sec_code=" + sec_code.value;
			
			http.open("GET", url , true);
			http.onreadystatechange = handleHttpResponseSendComment;
			http.send(null);
			textBoxTitle.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;
		}else{
			var elementMessage = document.getElementById("elementMessage");
			elementMessage.innerHTML = "No se ha podido insertar el comentario";
		}
	}    
}


/****************************************************************************************
/ 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";
			}
	}    
}



/****************************************************************************************
/ Nombre: FilmView
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Visualizacion y descarga de la pelicula
'***************************************************************************************/
function FilmView(id){
	window.open("FilmView.asp?Id=" + id);
}

function FilmDownload(id){
	window.open("FilmDownload.asp?Id=" + id);
}

/****************************************************************************************
/ Nombre: ChangeLocation
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: CAmbia de página por la pasada
'***************************************************************************************/
function ChangeLocation(url){
	document.location = url;
}



/****************************************************************************************
/ Nombre: Paypal, Bancaja
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Pagos online
'***************************************************************************************/
/*PAYPAL*/
function Paypal(){
	document._xclick.submit();
}

/*BANCAJA*/
function Bancaja(){
	document.bancaja.submit();
}


/****************************************************************************************
/ Nombre: CopyCode
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Copia el codigo de visualizacion
'***************************************************************************************/
function CopyCode(id){
	
	var element = document.getElementById(id);
	//window.clipboardData.setData("Text", element.value); 
	
	
	if (window.clipboardData) 
    { 

    // IE
     window.clipboardData.setData("Text", element.value); 
  
   } 
   else  
   {
	
   }
}


/****************************************************************************************
/ Nombre: getProvincia
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: recoje el id de la provincia y muestra el contenido
'***************************************************************************************/
function getProvincia(provincia){//alert(provincia);
	http.open("GET", "includes/getProvincias.asp?provincia=" + provincia , true);
	http.onreadystatechange = handleHttpResponseMapaProvincia;
	http.send(null);
}

function handleHttpResponseMapaProvincia() {
		if (http.readyState == 4) {
			
			document.location = "index.asp?pagina=conoce-espanya&subpagina=" + http.responseText;
		}
}


function getContinente(provincia){	
	http.open("GET", "includes/getProvincias.asp?provincia=" + provincia , true);
	http.onreadystatechange = handleHttpResponseContinente;
	http.send(null);
}

function handleHttpResponseContinente() {
	if (http.readyState == 4) {
		document.location = "index.asp?pagina=conoce-el-mundo&subpagina=" + http.responseText;
	}
}



//*******************************************************************************
//******** PARA LAS OFERTAS DE TRABAJO ******************************************
function inscribirse(referencia,idioma){
	//window.open('inscribir.asp?ref=' + referencia + '&idioma=' + idioma,'','width=500 height=360')
	window.open('inscribir.asp?ref=' + referencia + '&idioma=' + idioma,'','width=500 height=360')
}	

function validarInscripcion(opcion){
	var texto;
	texto="";
	if(document.getElementById("formularioOfertas").nombre.value==""){
		if (opcion==1){
			texto+=" - Debe insertar su nombre.<br>"
		}else{
			texto+=" - Insert your name.<br>"
		}	
	}
	if(document.getElementById("formularioOfertas").apellidos.value==""){
		if (opcion==1){
			texto+=" - Debe insertar sus apellidos.<br>"
		}else{
			texto+=" - Insert your surnames.<br>"	
		}	
	}
	if(document.getElementById("formularioOfertas").email.value==""){
		if (opcion==1){
			texto+=" - Debe insertar su email.<br>"
		}else{
			texto+=" - Insert your email.<br>"	
		}	
	}
	if(document.getElementById("formularioOfertas").telefono.value==""){
		if (opcion==1){
			texto+=" - Debe insertar su telefono.<br>"
		}else{
			texto+=" - Insert your telephone.<br>"	
		}	
	}
//	if(document.getElementById("formularioOfertas").curriculum.value==""){
//		if (opcion==1){
//			texto+=" - Debe adjuntar su curriculum.<br>"
//		}else{
//			texto+=" - Insert your curriculum.<br>"	
//		}	
//	}
	
	var textoCerrar="";
	
	if (opcion==1){
		textoCerrar="Cerrar";
	}else{
		textoCerrar="Close";
	}
	
	if (texto!=""){
		document.getElementById("capa-mensaje-empleo").innerHTML=texto + "<br><center><a href='javascript:cerrarCapaEmpleo();'>[" + textoCerrar + "]</a></center>";
		document.getElementById("capa-mensaje-empleo").style.display="block";
	}else{
		document.getElementById("formularioOfertas").submit();
	}
}

function cerrarCapaEmpleo(){
	document.getElementById("capa-mensaje-empleo").innerHTML="";
	document.getElementById("capa-mensaje-empleo").style.display='none';
}



