var _domain = "http://www.trustelcomunicaciones.com/";

/****************************************************************
/ 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));
	
}


String.prototype.trim= function() {//Agrega la función trim al objeto String
   return this.replace(/(^\s*)|(\s*$)/g,""); //elimina espacios a izquierda y derecha
   }

/****************************************************************
/ Nombre: validar
/ Implentacion
/ Revision: 301106
/ Descripcion: Valida los campos del formulario
'***************************************************************/
function validar(){
//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('acepto').checked){
		texto+="* Debe aceptar los términos.<br>";
	}

	var nombre = escape(document.getElementById("formularioContacto").nombre.value.trim());

	if ((nombre == "") || (nombre == "%26nbsp%3B")) {
		texto+=" * Debe indicar el producto sobre el que desea información.<br>";
	}else{
		cadenaEnvio="nombre=" + nombre;
	}
	
	if ( document.getElementById("formularioContacto").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.<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;
		}
	}
	
	var comentarios = escape(document.getElementById("formularioContacto").comentarios.value.trim()); 
	
	if ((comentarios == "") || (comentarios == "%26nbsp%3B")) {
		texto+=" * Debe incluir el motivo de su consulta.<br>";
	}else{
		cadenaEnvio+="&comentarios=" + comentarios;
	}	
		
	if ( escape(document.getElementById("formularioContacto").telefono.value != "" )){
		cadenaEnvio+="&telefono=" + escape(document.getElementById("formularioContacto").telefono.value);
	}
	
	if ( escape(document.getElementById("formularioContacto").personaContacto.value != "" )){
		cadenaEnvio+="&personaContacto=" + escape(document.getElementById("formularioContacto").personaContacto.value);
	}

	if ( escape(document.getElementById("formularioContacto").fax.value != "" )){
		cadenaEnvio+="&fax=" + escape(document.getElementById("formularioContacto").fax.value);
	}
	
	if ( escape(document.getElementById("formularioContacto").tipoInformacion.value != "" )){
		cadenaEnvio+="&tipoInformacion=" + escape(document.getElementById("formularioContacto").tipoInformacion.value);
	}
	if ( texto != "" ){
		document.getElementById("mensajeError").innerHTML=texto;
		document.getElementById("capaError").style.display='block';
	} 
	else{
		document.getElementById("mensaje-respuesta").innerHTML="";
		document.getElementById("mensajeError").innerHTML="";
		document.getElementById("capaError").style.display='none';
		http.open("GET", _domain + "actualizer/formcorreosMultiple/envioSinBd.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseContacto;
		http.send(null);
	}
	
}


function replace(texto,s1,s2){
 return texto.split(s1).join(s2);
}

function validarFormCanjePuntos(){
//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 ( escape(document.getElementById("formCanjePuntos").nombre.value.trim()) == "" ) {
		texto+=" * Debe indicar su nombre o denominación social.<br>";
	}else{
		cadenaEnvio="nombre=" + escape(document.getElementById("formCanjePuntos").nombre.value);
	}

	if ( escape(document.getElementById("formCanjePuntos").cif.value.trim()) == "" ) {
		texto+=" * Debe indicar su NIF o CIF.<br>";
	}else{
		cadenaEnvio+="&cif=" + escape(document.getElementById("formCanjePuntos").cif.value);
	}

	if ( escape(document.getElementById("formCanjePuntos").personaAutorizada.value.trim()) == "" ) {
		texto+=" * Debe indicar el teléfono móvil de una persona autorizada.<br>";
	}else{
		cadenaEnvio+="&personaAutorizada=" + escape(document.getElementById("formCanjePuntos").personaAutorizada.value);
	}

	if ( document.getElementById("formCanjePuntos").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.<br>";
	}
	
	if(document.getElementById("formCanjePuntos").email.value!=""){
		if(!validarEmail(document.getElementById("formCanjePuntos").email.value)){
				texto+=" * Formato de E-mail incorrecto.<br>";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formCanjePuntos").email.value;
		}
	}
	
	if ( escape(document.getElementById("formCanjePuntos").telefonoContacto.value.trim()) == "" ) {
		texto+=" * Debe indicar un teléfono de contacto.<br>";
	}else{
		cadenaEnvio+="&telefonoContacto=" + escape(document.getElementById("formCanjePuntos").telefonoContacto.value);
	}
	
	if ( escape(document.getElementById("formCanjePuntos").codigo.value.trim()) == "" ) {
		texto+=" * Debe indicar el código.<br>";
	}else{
		cadenaEnvio+="&codigo=" + escape(document.getElementById("formCanjePuntos").codigo.value);
	}

	if ( escape(document.getElementById("formCanjePuntos").movilSolicitado.value.trim()) == "" ) {
		texto+=" * Debe indicar el teléfono móvil que desea.<br>";
	}else{
		cadenaEnvio+="&movilSolicitado=" + escape(document.getElementById("formCanjePuntos").movilSolicitado.value);
	}

	if ( escape(document.getElementById("formCanjePuntos").puntos.value.trim()) == "" ) {
		texto+=" * Debe indicar los puntos utilizados.<br>";
	}else{
		cadenaEnvio+="&puntos=" + escape(document.getElementById("formCanjePuntos").puntos.value);
	}

	if ( escape(document.getElementById("formCanjePuntos").totalImporte.value.trim()) == "" ) {
		texto+=" * Debe indicar el importe total.<br>";
	}else{
		cadenaEnvio+="&totalImporte=" + escape(document.getElementById("formCanjePuntos").totalImporte.value);
	}



	if ( document.getElementById("formCanjePuntos").costeCero.checked == false ) {
		cadenaEnvio+="&costeCero=no";
	}
	else {
		cadenaEnvio+="&costeCero=si";
	}


	
	if ( document.getElementById("formCanjePuntos").zonaAzul[0].checked == true ) {
		cadenaEnvio+="&zonaAzul=si";
	}
	else {
		cadenaEnvio+="&zonaAzul=no";
	}

if ( escape(document.getElementById("formCanjePuntos").direccion.value.trim()) == "" ) {
		texto+=" * Debe indicar una dirección de envío.<br>";
	}else{
		cadenaEnvio+="&direccion=" + escape(document.getElementById("formCanjePuntos").direccion.value);
	}


if ( texto != "" ){
		document.getElementById("mensajeError3").innerHTML=texto;
		document.getElementById("capaError3").style.display='block';
	} 
	else{
		document.getElementById("mensaje-respuesta3").innerHTML="";
		document.getElementById("mensajeError3").innerHTML="";
		document.getElementById("capaError3").style.display='none';
		http.open("GET", _domain + "actualizer/formcorreosMultiple/envioSinBdCanjePuntos.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseCanjePuntos;
		http.send(null);
	}
	
}

function handleHttpResponseCanjePuntos() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
//			alert(http.responseText);
		document.getElementById("mensaje-respuesta3").innerHTML = http.responseText;	
		document.getElementById("mensaje-respuesta3").style.display = 'block';	
		document.getElementById("formCanjePuntos").reset();
	}    
}



function validarFormSolicitudOnline(){
//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("formSolicitudOnline").titular.value.trim() == "" ) {
		texto+=" * Debe indicar el titular.<br>";
	}else{
		if (!validarTexto(document.getElementById("formSolicitudOnline").titular.value)){
			texto="* El titular tiene carácteres no permitidos.<br>";
		} else {
			cadenaEnvio="titular=" + document.getElementById("formSolicitudOnline").titular.value;
		}
	}

	if ( document.getElementById("formSolicitudOnline").cif.value.trim() == "" ) {
		texto+=" * Debe indicar su CIF/NIF.<br>";
	}else{
		if (!validarTexto(document.getElementById("formSolicitudOnline").cif.value)){
			texto+="* El CIF/NIF tiene carácteres no permitidos.<br>";
		} else {
			cadenaEnvio+="&cif=" + document.getElementById("formSolicitudOnline").cif.value;
		}
	}

	if ( document.getElementById("formSolicitudOnline").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.<br>";
	}
	
	if(document.getElementById("formSolicitudOnline").email.value!=""){
		if(!validarEmail(document.getElementById("formSolicitudOnline").email.value)){
				texto+=" * Formato de E-mail incorrecto.<br>";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formSolicitudOnline").email.value;
		}
	}
	
	if (!validarTexto(document.getElementById("formSolicitudOnline").domicilioFiscal.value)){
		texto+="* El domicilio fiscal tiene carácteres no permitidos.<br>";
	} else {
		cadenaEnvio+="&domicilioFiscal=" + document.getElementById("formSolicitudOnline").domicilioFiscal.value;
	}
	
	if ( document.getElementById("formSolicitudOnline").telefono.value.trim() == "" ) {
		texto+=" * Debe indicar un teléfono de contacto.<br>";
	}else{
		cadenaEnvio+="&telefono=" + document.getElementById("formSolicitudOnline").telefono.value;
	}

	if (!validarTexto(document.getElementById("formSolicitudOnline").actividad.value)){
		texto+="* La actividad tiene carácteres no permitidos.<br>";
	} else {
		cadenaEnvio+="&actividad=" + document.getElementById("formSolicitudOnline").actividad.value;
	}

	if (!validarTexto(document.getElementById("formSolicitudOnline").localidad.value)){
		texto+="* La localidad tiene carácteres no permitidos.<br>";
	} else {
		cadenaEnvio+="&localidad=" + document.getElementById("formSolicitudOnline").localidad.value;
	}

	if (!validarTexto(document.getElementById("formSolicitudOnline").provincia2.value)){
		texto+="* La provincia tiene carácteres no permitidos.<br>";
	} else {
		cadenaEnvio+="&provincia=" + document.getElementById("formSolicitudOnline").provincia.value;
	}

	if (!validarTexto(document.getElementById("formSolicitudOnline").cpostal.value)){
		texto+="* El código postal tiene carácteres no permitidos.<br>";
	} else {
		cadenaEnvio+="&cpostal=" + document.getElementById("formSolicitudOnline").cpostal.value;
	}

	if ( document.getElementById("formSolicitudOnline").domicilioInstalacion.value.trim() == "" ) {
		texto+=" * Debe indicar el domicilio de la instalación.<br>";
	}else{
		if (!validarTexto(document.getElementById("formSolicitudOnline").domicilioInstalacion.value)){
			texto+="* El domicilio de instalación tiene carácteres no permitidos.<br>";
		} else {
			cadenaEnvio+="&domicilioInstalacion=" + document.getElementById("formSolicitudOnline").domicilioInstalacion.value;
		}
	}

	if ( document.getElementById("formSolicitudOnline").movil.value.trim() == "" ) {
		texto+=" * Debe indicar su teléfono móvil.<br>";
	}else{
		cadenaEnvio+="&movil=" + document.getElementById("formSolicitudOnline").movil.value;
	}


	if ( document.getElementById("formSolicitudOnline").localidad2.value == "" ) {
		texto+=" * Debe indicar la localidad de la instalación.<br>";
	}else{
		if (!validarTexto(document.getElementById("formSolicitudOnline").localidad2.value)){
			texto+="* La localidad de la instalación tiene carácteres no permitidos.<br>";
		} else {
			cadenaEnvio+="&localidad2=" + document.getElementById("formSolicitudOnline").localidad2.value;
		}
	}

	if ( document.getElementById("formSolicitudOnline").provincia2.value.trim() == "" ) {
		texto+=" * Debe indicar la provincia de la instalación.<br>";
	}else{
		if (!validarTexto(document.getElementById("formSolicitudOnline").provincia2.value)){
			texto+="* La provincia de la instalación tiene carácteres no permitidos.<br>";
		} else {
			cadenaEnvio+="&provincia2=" + document.getElementById("formSolicitudOnline").provincia2.value;
		}
	}

	if ( document.getElementById("formSolicitudOnline").cpostal2.value.trim() == "" ) {
		texto+=" * Debe indicar el código postal de la instalación.<br>";
	}else{
		if (!validarTexto(document.getElementById("formSolicitudOnline").cpostal2.value)){
			texto+="* El código postal de la instalación tiene carácteres no permitidos.<br>";
		} else {
			cadenaEnvio+="&cpostal2=" + document.getElementById("formSolicitudOnline").cpostal2.value;
		}
	}


	if ( document.getElementById("formSolicitudOnline").personaContacto.value.trim() == "" ) {
		texto+=" * Debe indicar una persona de contacto.<br>";
	}else{
		if (!validarTexto(document.getElementById("formSolicitudOnline").personaContacto.value)){
			texto+="* La persona de contacto tiene carácteres no permitidos.<br>";
		} else {
			cadenaEnvio+="&personaContacto=" + document.getElementById("formSolicitudOnline").personaContacto.value;
		}
	}

	if ( document.getElementById("formSolicitudOnline").telefonoServicio.value.trim() == "" ) {
		texto+=" * Debe indicar el número de teléfono del servicio o la instalación.<br>";
	}else{
		cadenaEnvio+="&telefonoServicio=" + document.getElementById("formSolicitudOnline").telefonoServicio.value;
	}

	if ( document.getElementById("formSolicitudOnline").entidad.value.trim() == "" ) {
		texto+=" * Debe indicar la entidad.<br>";
	}else{
		cadenaEnvio+="&entidad=" + document.getElementById("formSolicitudOnline").entidad.value;
	}

	if ( document.getElementById("formSolicitudOnline").sucursal.value.trim() == "" ) {
		texto+=" * Debe indicar la sucursal.<br>";
	}else{
		cadenaEnvio+="&sucursal=" + document.getElementById("formSolicitudOnline").sucursal.value;
	}

	if ( document.getElementById("formSolicitudOnline").DC.value.trim() == "" ) {
		texto+=" * Debe indicar el DC.<br>";
	}else{
		cadenaEnvio+="&DC=" + document.getElementById("formSolicitudOnline").DC.value;
	}

	if ( document.getElementById("formSolicitudOnline").cuenta.value.trim() == "" ) {
		texto+=" * Debe indicar su número de cuenta.<br>";
	}else{
		cadenaEnvio+="&cuenta=" + document.getElementById("formSolicitudOnline").cuenta.value;
	}

	if ( document.getElementById("formSolicitudOnline").productos.value.trim() == "" ) {
		texto+=" * Debe indicar los productos o servicios solicitados.<br>";
	}else{
		if (!validarTexto(document.getElementById("formSolicitudOnline").productos.value)){
			texto+="* Los productos o servicios solicitados tienen carácteres no permitidos.<br>";
		} else {
			cadenaEnvio+="&productos=" + document.getElementById("formSolicitudOnline").productos.value;
		}
	}

	cadenaEnvio+="&archivoCIF=" + document.getElementById("formSolicitudOnline").archivoCIF.value;

	cadenaEnvio+="&archivoRecibo=" + document.getElementById("formSolicitudOnline").archivoRecibo.value;

	if ( texto != "" ){
		document.getElementById("mensajeError").innerHTML=texto;
		document.getElementById("capaError").style.display='block';
	} 
	else{
/*		document.getElementById("mensaje-respuesta").innerHTML="";
		document.getElementById("mensajeError").innerHTML="";
		document.getElementById("capaError").style.display='none';
		http.open("GET", "actualizer/formcorreosMultiple/envioSinBdCanjePuntos.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseCanjePuntos;
		http.send(null);
		
*/		document.getElementById("formSolicitudOnline").submit();
	}
	
}

function handleHttpResponseSolicitudOnline() {
	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("mensaje-respuesta").style.display = 'block';	
		document.getElementById("formSolicitudOnline").reset();
	}    
}



function cerrarAviso3(){
	document.getElementById("mensajeError3").innerHTML="";
	document.getElementById("capaError3").style.display='none';
}




/****************************************************************
/ 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();
		var response = http.responseText;
		if(response.indexOf("icono_correcto.gif") > -1){
			//url = window.location.href;
			//url = replace(url, "&send=true","")
			//window.location.href = url + "&send=true";
			
			window.location.href = "contatoconfirm.html"
		}else{
			
		}
	}    
}


function Init() {
	
		uniqueId = "map_location1";
		width = 516;
		height = 180;
		iconUrl = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
		address = "Avenida de la industria, 18 28947 Fuenlabrada, MADRID";
		loadMap(uniqueId);
		GoogleCodeAddress(address, true);
		
		uniqueId = "map_location2";
		width = 516;
		height = 180;
		iconUrl = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
		address = "Avenida de la Peseta, 92 28054 MADRID";
		loadMap2(uniqueId);
		GoogleCodeAddress2(address, true);
		
		
		//var map2 =new google.maps.Map(document.getElementById("gmap2"));
		//map2.setCenter(new google.maps.LatLng(37.76, -122.45));
	}
	
	
//***************************************************************************
//***************************************************************************

//* GOOGLE MAPS *//

	var uniqueId = "map_location1";
	var width = 516;
	var height = 180;
	var iconUrl = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
	var address = "Madrid";
	//var googlePoint = "37.4419, -122.1419";
	googlePoint = "37.4419, -122.1419";
	

var _geocoder, _geocoder2;
var map, map2;

function loadMap(id)
{
    _geocoder = new google.maps.Geocoder();
   
    //if ($("#" + id).css("display") == "none") {
        //$("#" + id).html("");
       // var map = new google.maps.Map2(document.getElementById(id));
        //map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13);
        //$("#" + id).show();
    /*} else {
        $("#" + id).hide();
    }*/
    latlng=new google.maps.LatLng(37.4419, -122.1419);
    
    var googleMapOptions = {
      zoom: 13,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById(id), googleMapOptions);
    
}

function loadMap2(id)
{
    _geocoder2 = new google.maps.Geocoder();
   
    //if ($("#" + id).css("display") == "none") {
        //$("#" + id).html("");
       // var map = new google.maps.Map2(document.getElementById(id));
        //map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13);
        //$("#" + id).show();
    /*} else {
        $("#" + id).hide();
    }*/
    latlng=new google.maps.LatLng(37.4419, -122.1419);
    
    var googleMapOptions = {
      zoom: 13,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map2 = new google.maps.Map(document.getElementById(id), googleMapOptions);
    
}

function GoogleCodeAddress(address, firstLoad) {
    if (_geocoder) {
        _geocoder.geocode({ 'address': address }, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location
                });
            } else {
                if (!firstLoad) {
                    MessageFadeOutTime($("#incorrectAddress").val());
                }
            }
        });
    }
}

function GoogleCodeAddress2(address, firstLoad) {
    if (_geocoder2) {
        _geocoder2.geocode({ 'address': address }, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map2.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                    map: map2,
                    position: results[0].geometry.location
                });
            } else {
                if (!firstLoad) {
                    MessageFadeOutTime($("#incorrectAddress").val());
                }
            }
        });
    }
}



/****************************************************************
/ Nombre: validar
/ Implentacion
/ Revision: 301106
/ Descripcion: Valida los campos del formulario
'***************************************************************/
function validarIns(tipo){
//Funcion para la validar los datos enviados desde el formulario de contacto
	var texto;
	texto = "";

	var cadenaEnvio;
	cadenaEnvio = "";
	
	//Aqui validamos que los campos obligatorios tengan valor y se añaden a la cadena de envio
	
/*	if ( document.getElementById("formRegistro").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre.\n";
	}else{
		cadenaEnvio="nombre=" + document.getElementById("formRegistro").nombre.value;
	}*/
	
	if ( document.getElementById("formRegistro").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.\n";
	}
	
	if(document.getElementById("formRegistro").email.value!=""){
		if(!validarEmail(document.getElementById("formRegistro").email.value)){
				texto+=" * Formato de E-mail incorrecto.\n";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formRegistro").email.value;
		}
	}
	if (( document.getElementById("formRegistro").telefono.value != "" ) && ( isNaN(document.getElementById("formRegistro").telefono.value)) ){
		document.getElementById("formRegistro").telefono.value = ""
		document.getElementById("formRegistro").telefono.focus();
		texto+=" * El número de teléfono debe ser numérico.\n";
	}
	if (( document.getElementById("formRegistro").movil.value != "" ) && ( isNaN(document.getElementById("formRegistro").movil.value)) ){
		document.getElementById("formRegistro").movil.value = ""
		document.getElementById("formRegistro").movil.focus();
		texto+=" * El número de móvil debe ser numérico.\n";
	}
	if ( isNaN(document.getElementById("formRegistro").cpostal.value) ){
		document.getElementById("formRegistro").cpostal.value = ""
		document.getElementById("formRegistro").cpostal.focus();
		texto+=" * El código postal debe ser numérico.\n";
	}

	if ( document.getElementById("formRegistro").nick.value == "" ) {
		texto+=" * Debe indicar su nick.\n";
	}else if ( document.getElementById("formRegistro").nick.value.length < 4 ) {
				texto+=" * El nick debe ser de al menos 4 carácteres.\n";
	}
	if ( document.getElementById("formRegistro").dia.value == "0" ) {
		texto+=" * Debe seleccionar el día de su fecha de nacimiento.\n";
	}
	if ( document.getElementById("formRegistro").mes.value == "0" ) {
		texto+=" * Debe seleccionar el mes de su fecha de nacimiento.\n";
	}
	if ( document.getElementById("formRegistro").anyo.value == "0" ) {
		texto+=" * Debe seleccionar el año de su fecha de nacimiento.\n";
	}
	
	//para controlar que las fechas sean correctas
	var dia, mes, anyo;
	
	dia = document.getElementById('formRegistro').dia.value;
	mes = document.getElementById('formRegistro').mes.value;
	anyo = document.getElementById('formRegistro').anyo.value;
	
	if (!compruebaFecha(dia, mes, anyo)){
		texto+=" * La fecha intorducida es incorrecta.\n";
	}

		cadenaEnvio+="&=" + document.getElementById("formRegistro").preferencias.value;

	if ( document.getElementById("formRegistro").condiciones.checked == false ) {
		texto+=" * Debe aceptar las condiciones legales para registrarse.\n";
	}
	
	var email = document.getElementById("formRegistro").email.value;
	var nick = document.getElementById("formRegistro").nick.value;
	
		if ( texto != "" ){
				alert(texto);
		}else{
			http.open("GET", _domain + "registro/compruebaEmail.asp?email=" + email +"&nick=" + nick, true);
			http.onreadystatechange = handleHttpResponseComprobar;
			http.send(null);
		}
	
	
}

function handleHttpResponseComprobar() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
			var t =  http.responseText;	
		if ( t != "" ){
				alert(t);
		}else{
				document.getElementById("formRegistro").op.value = 0;
				document.formRegistro.submit();
		}
	}    
}


/****************************************************************
/ Nombre: compruebaFecha()
/ Implentacion: Fperez

/ Revision:
/ Descripcion: Comprueba que las fechas sean correctas
'***************************************************************/
function compruebaFecha(dia, mes, anyo){
	var error;
	if ((dia > 30) && ((mes == 2) || (mes == 4) || (mes == 6) || (mes == 9) || (mes == 11))){
		return false;
	}
	if ((dia > 29) && (mes == 2)){
		return false;
	}
	var resto = parseInt(anyo)%4;
	if (resto != 0){
		if ((dia > 28) && (mes == 2)){
			return false;
		}
	}
	
	return true;
}




/*********************************************************************************
/ Nombre: mostrarReferencia
/ Implentacion: FPEREZ
/ Revision: 05-10-07
/ Descripcion: Cambia el precio y los datos de cada referencia
*********************************************************************************/
function mostrarReferencia(id){
		if (document.getElementById("pk_info"+id).value == ""){
			document.getElementById("referencia").innerHTML = "";
			document.getElementById("referencia").style.display = "block";	
			return false;
		}
		var idReferencia = document.getElementById("pk_info"+id).value;
		document.getElementById("enlace_"+id).href = document.getElementById("enlace_"+id).href + "&ref=" + idReferencia
		document.getElementById("enlace_imagen_"+id).href = document.getElementById("enlace_imagen_"+id).href + "&ref=" + idReferencia
		document.getElementById("enlace_titulo_"+id).href = document.getElementById("enlace_titulo_"+id).href + "&ref=" + idReferencia
		http.open("GET", _domain + "includes/getReferencia.asp?id=" + idReferencia, true);
		http.onreadystatechange = handleHttpResponseReferencia;
		http.send(null);
	
}

function handleHttpResponseReferencia() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		var contenido = http.responseText.split("|");
		var id = contenido[1];
		
		if (contenido[0] != ""){
			document.getElementById("precio_referencia"+id).innerHTML = "POR&nbsp;<big><big><b>" +  contenido[0] + "</b></big></big>&nbsp;&euro;";	
		}
		document.getElementById("precio_referencia"+id).style.display = "block";	
	}    
}

/****************************************************************
/ Nombre: openWindow
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Abre un popup
'***************************************************************/
	function openWindow(theURL,winName,features){
 		window.open(theURL,winName,features);
		return
	}


/****************************************************************
/ Nombre: muestraTema
/ Implentacion:
/ Revision:
/ Descripcion: Muestra los temas
'***************************************************************/
function muestraTema(id,numero) {
	for (i=1;i<=numero;i++){
		if (id != i){
			if (document.getElementById("filaContenidoTema"+ i).style.display == "block"){
				document.getElementById("filaContenidoTema"+ i).style.display = "none";
			}
				document.getElementById("enlaceTema"+ i).className = "desmarcado";
		}
	}
	if (document.getElementById("filaContenidoTema"+ id).style.display == "block") { 
		document.getElementById("filaContenidoTema"+ id).style.display = "none"; }
	else { 
		document.getElementById("filaContenidoTema"+ id).style.display = "block";
		document.getElementById("enlaceTema"+ id).className = "marcado";
		}
}


/****************************************************************
/ Nombre: capaPosition
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Posiciona una capa en el centro de la pantalla +- los pixeles deseados
'***************************************************************/
function capaPosition(layer, position){
		element = document.getElementById(layer);
		screenCenterX = document.body.clientWidth / 2;
		element.style.left = screenCenterX + position;
		element.style.display = 'inline';
	}


/****************************************************************************************
/ Nombre: ampliaImagen
/ Implentacion: PACO
/ Revision:
/ Descripcion: Muestra el PopUp de ampliacion de las imagenes y lo redimensiona
'***************************************************************************************/
function ampliaImagen(url){
	document.getElementById('imagenAmpliada').src = "images/" + url;
	}

function redimensionarImagen(img){
	var anchoImagen,altoImagen,anchoPantalla,altoPantalla;
	img1 = new Image(); 
	img1.src = img.src;
	anchoImagen = img1.width;
	altoImagen = img1.height;
//	anchoPantalla = window.screen.width;
	anchoPantalla = 930
	altoPantalla = window.screen.height - 240;
	posicionx = (anchoPantalla/2) - (anchoImagen/2);
	posiciony = (altoPantalla/2) - (altoImagen/2);
	
	// coloca la capa de la imagen y la redimensiona
	document.getElementById('capaImagenAmpliada').style.top = posiciony + 'px';
	document.getElementById('capaImagenAmpliada').style.left = posicionx + 'px';
	document.getElementById('capaImagenAmpliada').style.width = anchoImagen + 'px';
	document.getElementById('capaImagenAmpliada').style.height = altoImagen + 'px';
	// coloca un poco más arriba la capa del enlace para cerrar
	posicionCerrar = posiciony - 19;
	document.getElementById('cerrarImagenAmpliada').style.top = posicionCerrar + 'px';
	document.getElementById('cerrarImagenAmpliada').style.left = posicionx + 'px';

	document.getElementById('capaImagenAmpliada').style.display = 'block';
	document.getElementById('cerrarImagenAmpliada').style.display = 'block';
	// en caso del formulario de contacto, ocultamos el combo
	document.getElementById('pais').style.visibility = 'hidden';
}

function cerrarImagenAmpliada(){
	document.getElementById('imagenAmpliada').src = "";
	document.getElementById('capaImagenAmpliada').style.display = 'none';
	document.getElementById('cerrarImagenAmpliada').style.display = 'none';
	document.getElementById('pais').style.visibility = 'visible';
}
//***************************************************************************
//***************************************************************************



/****************************************************************************************
/ Nombre: autentifica
/ Implentacion: JBERNALTE
/Parametros: [Type] (off) desautentifica (otra cosa) autentifica
/ Revision:
/ Descripcion: Login de usuario en la zona privada
'***************************************************************************************/
function autentifica(type){
	var strEnvio = '';
	
	if(type != 'off'){
		
		var campos = new Array();
		var mensajes = new Array();
		
		
		/* DENINE CAMPO A VALIDAR MENSAJE*/
		campos[0] = 'user'; mensajes[0] = 'Indique su usuario';
		campos[1] = 'password'; mensajes[1] = 'Indique su contraseña';
	
		
		valid = false; 
		i=0;
		
		for(campo in campos){
			valor = document.formLogin[campo].value;
			if (   (valor == '') || (valor == mensajes[i])  ) {
				document.formLogin[campo].value = mensajes[i];
				valid = false;
			}else{
				strEnvio += "" + campos[i] + "=" + document.formLogin[campo].value + "&";
				valid = true;
			}
			i++;
		}
		strEnvio += "login=on"
	}else{
		valid=true;
		strEnvio += "login=off"
		
	}
	
	if(valid){
//		window.location.href = "includes/loginEngine.asp?" + strEnvio;
		url = _domain + "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 = _domain + "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 = _domain + "includes/loginEngine.asp?login=off";
		http.open("GET", url , true);
		http.onreadystatechange = handleHttpResponseReloadFlash;
		http.send(null);
	}else{
		url = _domain + "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 = _domain + "includes/loginEngine.asp?" + strEnvio;
		http.open("GET", url , true);
		http.onreadystatechange = handleHttpResponseReload;
		http.send(null);		
}


/****************************************************************************************
/ Nombre: edit, handleHttpResponseReload
/ Implentacion: JBERNALTE
/ Revision:13/06/2007
/ Descripcion: Recarga la pagina despues de ejecutar AJAX
'***************************************************************************************/
function handleHttpResponseReload() {
	if (http.readyState == 4) {
		//window.location.reload();
		var respuesta=http.responseText;
		if (respuesta=="no"){
			document.getElementById("mensaje-alerta").style.display='block';
		}
		if (respuesta=="si"){
			var pagina=document.getElementById("login").pagina.value;
			var subpagina=document.getElementById("login").subpagina.value;
			var c=document.getElementById("login").c.value;
			document.location="index.asp?pagina=" + pagina + "&subpagina=" + subpagina + "&c=" + c;
		}
	}    
}

function 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 = _domain + "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= _domain + "ES/pagina=ficha-de-usuario.html";
	}    
}



/****************************************************************************************
/ 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 = _domain + "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", _domain + "actualizer/formcorreosMultiple/envioEmail.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseEmail;
		http.send(null);
}
function handleHttpResponseEmail() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		document.getElementById("recordarPassword").style.display = 'none';	
		document.getElementById("respuestaRecuerdo").style.display = 'block';	
		document.getElementById("respuestaRecuerdo").innerHTML = http.responseText;	
		document.getElementById("formrecuerdo").reset();
	}    
}



/****************************************************************************************
/ Nombre: submenuPosition
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Central el menu a partir del centro de la resolucion de pantalla
'***************************************************************************************/

	function submenuPosition(layer, position){
		subMenuHide();
		
		element = document.getElementById(layer);
		screenCenterX = document.body.clientWidth / 2;
		element.style.left = screenCenterX + position;
		element.style.display = 'inline';
		
		
	}
	

/****************************************************************************************
/ Nombre: subMenuHide
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Oculta el submenu, necesitamos definir cuantos existen
'***************************************************************************************/
	function subMenuHide(){
		
		cuantos = 4;
		
		//OCULTAMOS TODOS
		for(i=1; i<=cuantos; i++){
			document.getElementById('submenu' + i).style.display = "none";
		}

	}
	
	
/****************************************************************************************
/ Nombre: buscadorWeb
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Envia el formulario de busqueda
'***************************************************************************************/
function searchOnWeb(){			
	if (document.getElementById("textobusqueda").value.length<1){
		alert("Introduzca el texto de búsqueda");
	}
	else{
		document.getElementById("busqueda").cadenaBusqueda.value=document.getElementById("textobusqueda").value
		document.getElementById("busqueda").submit()
	}				
}




/****************************************************************************************
/ Nombre: validarSuscripcion
/ Implentacion: JDolz
/ Revision:
/ Descripcion: Valida y envia el formulario de suscripcion a las news
'***************************************************************************************/
/*function validarSuscripcion(){

	var texto="";

	if ( document.getElementById("formularioSuscripcion").nombre.value == "" ) {
		texto+=" - Debe indicar su nombre.<br>";
	}else{
		cadenaEnvio="nombre=" + document.getElementById("formularioSuscripcion").nombre.value;
	}
	
	if ( document.getElementById("formularioSuscripcion").email.value == "" ) {
		texto+=" - Debe indicar su email.<br>";
	}
	
	if(document.getElementById("formularioSuscripcion").email.value!=""){
		if(!validarEmail(document.getElementById("formularioSuscripcion").email.value)){
				texto+=" - Formato de E-mail incorrecto.<br>";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formularioSuscripcion").email.value;
		}
	}

	if (texto!=""){
		document.getElementById("respuesta-suscripcion").innerHTML="";
		document.getElementById("respuesta-suscripcion").innerHTML=texto;
		document.getElementById("respuesta-suscripcion").style.display="block";
	}else{
		http.open("GET", "actualizer/ap3nbs/suscripcion/suscripcion.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseSuscripcion;
		http.send(null);
	}	
}
function handleHttpResponseSuscripcion() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		document.getElementById("respuesta-suscripcion").innerHTML=http.responseText;
		document.getElementById("respuesta-suscripcion").style.display = 'block';	
		document.getElementById("formularioSuscripcion").reset();
	}    
}*/

/****************************************************************
/ Nombre: validarvalidarSuscripcion
/ Implentacion: Fperez
/ Revision: 11-07-07
/ Descripcion: Valida los campos del formulario de suscripcion
'***************************************************************/
function validarSuscripcion(idioma){


	var texto,texto_en,texto_fr,texto_val,texto_de;
	texto = "";
	texto_en = "";
	texto_fr = "";
	texto_val = "";
	texto_de = "";

	if ( document.getElementById("formularioSuscripcion").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre.<br>";
		texto_en+=" * You must enter your name.<br>";
		texto_fr+=" * Vous devez indiquer votre nom.<br>";
		texto_val+=" * Deu indicar el seu nom.<br>";
		texto_de+=" * Ihren Namen bitte.<br>";
	}else{
		cadenaEnvio="nombre=" + document.getElementById("formularioSuscripcion").nombre.value;
	}
	
	if ( document.getElementById("formularioSuscripcion").email.value == "" ) {
		texto+="- Debe indicar su email.<br>";
		texto_en+=" * You must enter your e-mail.<br>";
		texto_fr+=" * Vous devez indiquer votre email.<br>";
		texto_val+=" * Deu indicar el seu e-mail.<br>";
		texto_de+=" * Ihre E-Mail Adresse bitte.<br>";
	}
	
	if(document.getElementById("formularioSuscripcion").email.value!=""){
		if(!validarEmail(document.getElementById("formularioSuscripcion").email.value)){
				texto+=" * Formato de E-mail incorrecto.<br>";
				texto_en+=" * The E-mail format is wrong.<br>";
				texto_fr+=" * Format d'email incorrect.<br>";
				texto_val+=" * Format de E-mail incorrecte.<br>";
				texto_de+=" * E-Mail Format ist nicht richtig.<br>";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formularioSuscripcion").email.value;
		}
	}

	if (texto!=""){
		document.getElementById("textoSuscripcion").innerHTML="";

			switch (idioma) { 
				case 'en': 
					document.getElementById("textoSuscripcion").innerHTML=texto_en;
				   break 
				case 'fr': 
					document.getElementById("textoSuscripcion").innerHTML=texto_fr;
				   break 
				case 'val': 
					document.getElementById("textoSuscripcion").innerHTML=texto_val;
				   break 
				case 'de': 
					document.getElementById("textoSuscripcion").innerHTML=texto_de;
				   break 
				default: 
					document.getElementById("textoSuscripcion").innerHTML=texto;
			} 
		document.getElementById("textoSuscripcion").style.display="block";
	}else{
		http.open("GET", _domain + "actualizer/suscripcion/suscripcion.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseSuscripcion;
		http.send(null);
	}	
}
function handleHttpResponseSuscripcion() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
			alert(http.responseText);
		document.getElementById("textoSuscripcion").innerHTML = http.responseText;	
		document.getElementById("formularioSuscripcion").reset();
	}    
}
function blanco(){
	if (document.getElementById('nombre').value == ' nombre') {
		document.getElementById('nombre').value = '';
	}
	if (document.getElementById('email').value == ' e-mail') {
		document.getElementById('email').value = '';
	}
}



/****************************************************************************************
/ Nombre: getProvincia
/ Implentacion: JDolz
/ Revision:
/ Descripcion: recoje el id de la provincia y muestra el contenido
'***************************************************************************************/
function getProvincia(provincia){
	
	http.open("GET", _domain + "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", _domain + "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(_domain + "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", _domain + "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;

	}
}
/***************************************************************/

/****************************************************************
/ Nombre: imprimirCV
/ Implentacion 
/ Revision: 120907
/ Descripcion: imprimir el cv
'***************************************************************/
function imprimirCV(id){
    var base=document.getElementById("base").innerHTML;
    var estilo=document.getElementById("estilosPrincipal").href
    document.getElementById("estilosPrincipal").href="css/imprimir.css";
    var v=document.getElementById("capaImprimir").innerHTML;
    document.getElementById("base").innerHTML=v;
    document.getElementById("capaOcultar").style.display='none';
    window.print();
    document.getElementById("estilosPrincipal").href=estilo;
    document.getElementById("base").innerHTML=base;
}

/****************************************************************
/ Nombre: FUNCIONES PARA VALIDAR EL CIF
/ Implentacion FPEREZ
/ Revision: 281207
/ Descripcion:valida el CIF
'***************************************************************/
function validarCIF(texto){ 
         
        var pares = 0; 
        var impares = 0; 
        var suma; 
        var ultima; 
        var unumero; 
        var uletra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I"); 
        var xxx; 
         
        texto = texto.toUpperCase(); 
         
        var regular = new RegExp(/^[ABCDEFGHKLMNPQS]\d\d\d\d\d\d\d[0-9,A-J]$/g); 
         if (!regular.exec(texto)) return false; 
              
         ultima = texto.substr(8,1); 

         for (var cont = 1 ; cont < 7 ; cont ++){ 
             xxx = (2 * parseInt(texto.substr(cont++,1))).toString() + "0"; 
             impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1)); 
             pares += parseInt(texto.substr(cont,1)); 
         } 
         xxx = (2 * parseInt(texto.substr(cont,1))).toString() + "0"; 
         impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1)); 
          
         suma = (pares + impares).toString(); 
         unumero = parseInt(suma.substr(suma.length - 1, 1)); 
         unumero = (10 - unumero).toString(); 
         if(unumero == 10) unumero = 0; 
          
         if ((ultima == unumero) || (ultima == uletra[unumero])) 
             return true; 
         else 
             return false; 

    } 
	
function validarNIF(dni) {
  numero = dni.substr(0,dni.length-1);
  let = dni.substr(dni.length-1,1).toUpperCase();
  numero = numero % 23;
  letra='TRWAGMYFPDXBNJZSQVHLCKET';
  letra=letra.substring(numero,numero+1);
  if (letra!=let) {
//    alert('Dni erroneo');
	return false;
  }else{
//    alert('Dni correcto');
	return true;
  }
}



/****************************************************************************************
/ 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 = _domain + "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) {
	
			
		if (localizacion.match("SPAIN")=="SPAIN")
        {
	 		element.style.display = 'none';	
			elementMessage.innerHTML = '';
	
			url = _domain + "AjaxResponse/rentFilm.asp?Id=" + id;
			
			http.open("GET", url , true);
			http.onreadystatechange = handleHttpResponseRentingFilm;
			http.send(null);
    	}
        else
	    {
  	      document.getElementById("plataforma").style.display='block';
     	}
			
						  
		}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";
		if (http.responseText=="<br/>Portal sólo para España.")
		{url = _domain; }
		else
		{url = _domain + "ES/login.html";}
		setTimeout("ChangeLocation('" + url + "')", 500);
	}    
}


/****************************************************************************************
/ 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");
	
		if (textBoxTitle.value != '' && textBoxComment.value != '') {
			url = _domain + "AjaxResponse/comentariosPelicula.asp?Title=" + textBoxTitle.value+ "&Comment=" + textBoxComment.value + "&producto=" + producto;
			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 = _domain + "AjaxResponse/voteFilm.asp?Id=" + id+ "&Vote=" + vote;
	http.open("GET", url , true);
	http.onreadystatechange = handleHttpResponseVoteFilm;
	http.send(null);
}




function validar_compra(id){
  if (localizacion.match("SPAIN")=="SPAIN")
    {
	  window.location.href = 'index.asp?pagina=login&subpagina=compra&id='+id;
	}
 else
	{
  	 document.getElementById("plataforma").style.display='block';
	}	
}



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";
				//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){
	
	if (localizacion.match("SPAIN")=="SPAIN")
        {
	 		window.open("FilmView.asp?Id=" + id);
    	}
        else
	    {
  	      document.getElementById("plataforma").style.display='block';
     	}
	
}

function FilmDownload(id){
	if (localizacion.match("SPAIN")=="SPAIN")
        {
	window.open("FilmDownload.asp?Id=" + id);
	}
        else
	    {
  	      document.getElementById("plataforma").style.display='block';
     	}
}

/****************************************************************************************
/ 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: Mp3RemoteControl
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Control de WM desde Flash
'***************************************************************************************/
playerOperation = "stop";

//Control del Flash
function Mp3RemoteControl(instruction, id){
	
	playerOperation = instruction;
	var flash = document.getElementById("mp3");

	if(id!=""){
		flash.SetVariable("_root.music", id);
	}
	
	switch (playerOperation) {
		
		case "stop":
			flash.SetVariable("_root.remote", "stop");
			break;
		case "play":
			flash.SetVariable("_root.remote", "play");
			break;
	}

}


//Control del Windows media
function Mp3RemoteControlAudio(instruction, id){
	
	playerOperation = instruction;
	
	getAudioPlayer('wmLayer', id);
	
	var wmplayer = document.getElementById("wm");
	
	switch (playerOperation) {
		
		case "stop":
			try{
				wmplayer.controls.stop();
			}catch(e){}
			break;
		case "play":
			try{
				wmplayer.controls.play()
			}catch(e){}
			break;
	}
}

//PINTA EL REPRODUCTOR WM
function getAudioPlayer(div, urlStreaming){
	player =""; 	
		player +='<embed type="application/x-mplayer2" id="wm" name="wm" src="' + urlStreaming + '" autostart="true" volume="10" showStatusBar="true" showControls="false" kioskmode="false" height="20" width="105" scale="ASPECT"></embed>'; 
	 document.getElementById(div).innerHTML= player;
	 
}



/****************************************************************************************
/ Nombre: DinamicFlashText
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Permite que un flash adquiera el texto de una capa
'***************************************************************************************/
function DinamicFlashText(div){
		
	var element = document.getElementById(div);
	var texto = element.innerHTML;
	texto = texto.replace("&amp;", "##ampersand##");
	texto = texto.replace("&", "##ampersand##");
	var pelicula = new FlashObject("swf/dinamic-title.swf?texto=" + texto, div + "Text", "500", "40", "8", "");
	pelicula.addParam("wmode", "transparent");
	pelicula.addParam("quality", "high");
	pelicula.write(div);

}



/****************************************************************************************
/ Nombre: checkwhere
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Cordenadas del mouse
'***************************************************************************************/
var xCoord = 0;
var yCoord = 0;

function checkwhere(e) {
        if (document.layers){
        xCoord = e.x;
        yCoord = e.y;
}
        else if (document.all){
        xCoord = event.clientX;
        yCoord = event.clientY;
}
        else if (document.getElementById){
        xCoord = e.clientX;
        yCoord = e.clientY;
}
        //self.status = "X= "+ xCoord + "  Y= " + yCoord; 
        }


document.onmousemove = checkwhere;
if(document.captureEvents) {document.captureEvents(Event.MOUSEMOVE);}


function validarFormulario(){
//Funcion para la validar los datos enviados desde el formulario de solicitud de presupuesto de centralita
	var texto;
	texto = "";

	var cadenaEnvio;
	cadenaEnvio = "";
	
	if ( document.getElementById("formPresupuesto").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre.<br>";
	}else{
		cadenaEnvio="nombre=" + document.getElementById("formPresupuesto").nombre.value;
	}
	
	if ( document.getElementById("formPresupuesto").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.<br>";
	}
	
	if(document.getElementById("formPresupuesto").email.value!=""){
		if(!validarEmail(document.getElementById("formPresupuesto").email.value)){
				texto+=" * Formato de E-mail incorrecto.<br>";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formPresupuesto").email.value;
		}
	}
	if ( document.getElementById("formPresupuesto").comentarios.value != "" ){
		cadenaEnvio+="&comentarios=" + document.getElementById("formPresupuesto").comentarios.value;
	}	
		
	if ( document.getElementById("formPresupuesto").telefono.value != "" ){
		cadenaEnvio+="&telefono=" + document.getElementById("formPresupuesto").telefono.value;
	}
	
	if ( document.getElementById("formPresupuesto").personaContacto.value != "" ){
		cadenaEnvio+="&personaContacto=" + document.getElementById("formPresupuesto").personaContacto.value;
	}
	if ( document.getElementById("formPresupuesto").empresa.value != "" ){
		cadenaEnvio+="&empresa=" + document.getElementById("formPresupuesto").empresa.value;
	}

	if ( document.getElementById("formPresupuesto").fax.value != "" ){
		cadenaEnvio+="&fax=" + document.getElementById("formPresupuesto").fax.value;
	}
	
	if ( document.getElementById("formPresupuesto").marca.value != "" ){
		cadenaEnvio+="&marca=" + document.getElementById("formPresupuesto").marca.value;
	}
	if ( document.getElementById("formPresupuesto").modelo.value != "" ){
		cadenaEnvio+="&modelo=" + document.getElementById("formPresupuesto").modelo.value;
	}
	if ( document.getElementById("formPresupuesto").analogicas.value != "" ){
		cadenaEnvio+="&analogicas=" + document.getElementById("formPresupuesto").analogicas.value;
	}
	if ( document.getElementById("formPresupuesto").digitales.value != "" ){
		cadenaEnvio+="&digitales=" + document.getElementById("formPresupuesto").digitales.value;
	}
	if ( document.getElementById("formPresupuesto").moviles.value != "" ){
		cadenaEnvio+="&moviles=" + document.getElementById("formPresupuesto").moviles.value;
	}
	if ( document.getElementById("formPresupuesto").extensiones_analogicas.value != "" ){
		cadenaEnvio+="&extensiones_analogicas=" + document.getElementById("formPresupuesto").extensiones_analogicas.value;
	}
	if ( document.getElementById("formPresupuesto").extensiones_digitales.value != "" ){
		cadenaEnvio+="&extensiones_digitales=" + document.getElementById("formPresupuesto").extensiones_digitales.value;
	}

	if ( document.getElementById("formPresupuesto").analogicas2.value == "" ) {
		texto+=" * Debe indicar el nº de líneas <br>analógicas para presupuestar.<br>";
	}else{
		cadenaEnvio+="&analogicas2=" + document.getElementById("formPresupuesto").analogicas2.value;
	}

	if ( document.getElementById("formPresupuesto").digitales2.value == "" ) {
		texto+=" * Debe indicar el nº de líneas <br>digitales para presupuestar.<br>";
	}else{
		cadenaEnvio+="&digitales2=" + document.getElementById("formPresupuesto").digitales2.value;
	}
	if ( document.getElementById("formPresupuesto").moviles2.value == "" ) {
		texto+=" * Debe indicar el nº de líneas <br>móviles para presupuestar.<br>";
	}else{
		cadenaEnvio+="&moviles2=" + document.getElementById("formPresupuesto").moviles2.value;
	}
	if ( document.getElementById("formPresupuesto").extensiones_analogicas2.value == "" ) {
		texto+=" * Debe indicar el nº de extensiones<br>analogicas para presupuestar.<br>";
	}else{
		cadenaEnvio+="&extensiones_analogicas2=" + document.getElementById("formPresupuesto").extensiones_analogicas2.value;
	}
	if ( document.getElementById("formPresupuesto").extensiones_digitales2.value == "" ) {
		texto+=" * Debe indicar el nº de extensiones<br>digitales para presupuestar.<br>";
	}else{
		cadenaEnvio+="&extensiones_digitales2=" + document.getElementById("formPresupuesto").extensiones_digitales2.value;
	}

if ( texto != "" ){
		document.getElementById("mensajeError2").innerHTML=texto;
		document.getElementById("capaError2").style.display='block';
	} 
	else{
		document.getElementById("mensaje-respuesta2").innerHTML="";
		document.getElementById("mensajeError2").innerHTML="";
		document.getElementById("capaError2").style.display='none';
		http.open("GET", _domain + "actualizer/formcorreosMultiple/envioSinBd2.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseFormPresupuesto;
		http.send(null);
	}
	
}
/****************************************************************
/ Nombre: cerrarAviso
/ Implentacion: 
/ Revision:
/ Descripcion: Cierra la capa del aviso del formulario
'***************************************************************/
function cerrarAviso2(){
	document.getElementById("mensajeError2").innerHTML="";
	document.getElementById("capaError2").style.display='none';
}

function handleHttpResponseFormPresupuesto() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
//			alert(http.responseText);
		document.getElementById("mensaje-respuesta2").innerHTML = http.responseText;	
		document.getElementById("formPresupuesto").reset();
	}    
}

function validarTexto(eltexto){

	var cval="abcçdefghijklmnñopqrstuvwxyzABCÇDEFGHIJKLMNÑOPQRSTUVWXYZ0123456789 _ÁÀÄÂÉÈËÊÍÌÏÎÓÒÖÔÚÙÜÛáàäâéèëêíìïîóòöôúùüû@,./-";
	var aux,n=0;	
	aux=eltexto;
	
	if(aux!=""){
		for(i=0;i<aux.length;i++){	
			for(j=0;j<cval.length;j++){				
				if(cval.charAt(j)==aux.charAt(i)){
					n++;
				}				
			}		 
		}
	}

	if(n==aux.length){
		return true;
	}else{
		return false;
	}
}

/****************************************************************
/ Nombre: cerrarAviso
/ Implentacion: 
/ Revision:
/ Descripcion: Load del documento jQuery
'***************************************************************/
$(document).ready(function(){
	$(".btn-slide").click(function(){
		$("#panel").slideToggle("slow");
		$(this).toggleClass("active");
		return false;
	});
	
	$('.ticker').vTicker({
		speed: 500,
		pause: 5000,
		showItems: 1,
		animation: 'fade',
		mousePause: true
	});

});

$(function() {
	$(".newsticker-jcarousellite").jCarouselLite({
		vertical: true,
		hoverPause:true,
		visible: 3,
		auto:500,
		speed:3000
	});
});



function calculaFinanciacion() {

    var meses, importe, url, params;

	try {
		/*meses = document.getElementById("meses").options[document.getElementById("meses").selectedIndex].text;
		importe = document.getElementById("importe").value;*/
		meses = $("#meses").val();
		importe = $("#importe").val();
	}
	catch(err) {}
	
    if (importe == "") {
        alert("Debe indicar el importe");
    }
    else {
        if (importe < 1200) {
            alert("El importe debe ser superior a 1200€ más IVA")
        }
        else {
			var pathname = window.location.href;
			
			if (pathname.indexOf("http://www.trustelcomunicaciones.com") > -1) {
            	url = "http://www.trustelcomunicaciones.com/includes/calculaFinanciacion.asp";
			}
			else {
				url = "http://trustelcomunicaciones.com/includes/calculaFinanciacion.asp";
			}
			//alert(url);
            params = "meses=" + meses + "&importe=" + importe;

            http.open("POST", url, true);
            http.onreadystatechange = function() {
                if (http.readyState == 4) {
                    element = document.getElementById("capaRespuesta");
                    element.style.display = "block";
                    if (http.status == 200) {
                        element.innerHTML = http.responseText;
                    }
                    else if (http.status == 404) {
                        element.innerHTML = "Error: 404";
                    } else {
                        element.innerHTML = "Error: " + http.status;
                    }
                }
            }
            http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            http.send(params);
            return;
            /*$.ajax({
				type: 'POST',
				data: params,
				url: url,
				success: function(data) {
					alert(data);
					$("#capaRespuesta").css("display", "block");
					$("#capaRespuesta").html(data);
				}
            });*/
        }
    }
}

    var nav4 = window.Event ? true : false;
    function acceptNum(evt) {
        // NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	
        var key = nav4 ? evt.which : evt.keyCode;
        return ((key >= 48 || key == 46) && key <= 57);
    }
