var vpCampoObl = "Campo obligatorio";
var vpIntroducirDir = "Debe introducir una dirección";
var vpIntroducirPobl = "Debe introducir una población";
var vpElegirProv = "Debe elegir una provincia";
var vpNoImprimir = "No se puede imprimir";
var vpAceptarCond = "Debe aceptar las condiciones del programa";
var vpFechaInicialInfFinal = "La fecha inicial tiene ser inferior a la final.";
var vpFormatoFecha = "El formato de la fecha debe ser dd/mm/aaaa";
var vpAnyoNoValido = "El año introducido no es válido";
var vpMesNoValido = "El mes introducido no es válido";
var vpDiaNoValido = "El dia introducido no es válido";
var vpFechaIniObl = "Para realizar la búsqueda\n\res obligatoria la fecha inicial.";
var vpElegirTipoAp = "Debes elegir algún tipo de aparato";
var vpElegirFam = "Debes elegir alguna familia";
var vpElegirMod = "Debes elegir algún modelo";
var vpIntroducirNSerie = "Debe introducir un Nº de Serie";
var vpIntroducirFechaPMarcha = "Debe introducir una Fecha P. en Marcha";
var vpIntroducirNom = "Debe introducir un Nombre";
var vpIntroducirApel = "Debe introducir Apellidos";
var vpIntroducirTelef = "Debe introducir un Teléfono";
var vpNSerieNoValido = "El nº de Serie introducido tiene caracteres no válidos";
var vpIntroducirCP = "Debe introducir un Código Postal";
var vpIntroducirCPValido = "Debe introducir un código postal válido";
var vpIntroducirNumTelef = "Debe introducir un número de teléfono";
var vpIntroducirNumTelefValido = "Debe introducir un número de teléfono válido";
var vpIntroducirCorreo = "Debe introducir una dirección de correo";
var vpIntroducirFaxValido = "Debe introducir un número de fax válido";
var vpIntroducirFax = "Debe introducir un número de fax";

function buscarCategoriaRegalo(valor, nombre, jsp){
	document.form1.MENU_CATEGORIA.value=valor;
	document.form1.nombreCategoria.value=nombre;
	document.form1.action=jsp; //"RegalosCategoria.jsp";
	document.form1.submit();
}

function buscarRegalo(jsp){
	document.form1.action=jsp; //"ResultadoRegalos.jsp";
	if(document.form1.Puntos.value!= '' && !esNumeroValido(document.form1.Puntos.value) ){
		document.form1.Puntos.focus();
		return;
	}else{
		if(document.form1.Categoria.value != -1){
			document.form1.nombreCategoria.value=document.form1.Categoria.options[document.form1.Categoria.selectedIndex].text;
		}
		if (document.form1.tipoPuntos[0].checked){
			//sacamos el rango de valores
			var rango = document.form1.RangoPuntos.value;
			if ( rango != -1){
				if (rango.indexOf("-") ==-1){
					if (rango.indexOf("<") !=-1){
						document.form1.rangoInf.value=0
						document.form1.rangoSup.value=rango.substring(rango.indexOf("<")+1,rango.length);
					}else{
						document.form1.rangoInf.value=rango.substring(rango.indexOf(">")+1,rango.length);
						document.form1.rangoSup.value=0
					}
				}else{
					//es un rango normal
					document.form1.rangoInf.value= rango.substring(0,rango.indexOf("-"));
					document.form1.rangoSup.value= rango.substring(rango.indexOf("-")+1,rango.length);
				}
				//puntos
				document.form1.Puntos.value='';
			}
		}else{
			document.form1.RangoPuntos.value='';
			document.form1.rangoInf.value='';
			document.form1.rangoSup.value='';
		}
	}
	document.form1.submit();
}

function activar(valor){
	if (valor==0){
		document.form1.Puntos.value='';
		document.form1.Puntos.disabled=true;
		document.form1.RangoPuntos.disabled=false;
	}else{
		document.form1.RangoPuntos.value='';
		document.form1.rangoInf.value='';
		document.form1.rangoSup.value='';
		document.form1.RangoPuntos.disabled=true;
		document.form1.Puntos.disabled=false;
	}
}

function cargarValoresRegalos( rango, puntos){
	if (rango != ''){
		document.form1.Puntos.disabled=true;
		document.form1.tipoPuntos[0].checked=true;
	}
	if (puntos != ''){
		document.form1.RangoPuntos.value='';
		document.form1.rangoInf.value='';
		document.form1.rangoSup.value='';
		document.form1.RangoPuntos.disabled=true;
		document.form1.tipoPuntos[1].checked=true;
	}
	if (rango =='' && puntos ==''){
		document.form1.tipoPuntos[0].checked=true;
		activar(0);
	}
}

function buscarSiguientesRegalos(jsp){
	document.form1.SIGUIENTE_GRUPO.value='S';
	document.form1.Categoria.value =categoria;
	document.form1.Puntos.value=puntos;
	document.form1.action=jsp; //"ResultadoRegalos.jsp";
	document.form1.submit();
}

function informacion(valor, jsp){
	var ancho = 425;
	var alto = 500;
	if (document.all) var xMax = screen.width, yMax = screen.height;
	else
		if (window.outerWidth){
			var xMax = window.outerWidth, yMax = window.outerHeight;
		}
		else{
			var xMax = 800, yMax=600;
		}
	var xOffset = (xMax - ancho)/2, yOffset = (yMax - alto)/2 - 30;
	var valorUnescape = unescape(valor);
	window.open(jsp+"NOMBRE="+valorUnescape,'Flotante_DETALLE','scrollbars=NO,width='+ancho+',height='+alto+',top='+yOffset+',left='+xOffset);
}

function solicitarRegalo(valor, nombre, puntos, jsp){
	document.form1.ID_REGALO.value = valor;
	document.form1.NOMBRE_REGALO.value = unescape(nombre);
	document.form1.PUNTOS.value=desformatearPuntos(puntos);
	document.form1.FUNCION.value="ANADIR";
	document.form1.action=jsp; //"CestaInstal.jsp";
	document.form1.submit();
}

function enviarConsulta(jsp){
	document.form1.action = jsp; //;"ConsultaRegaloFlotante.jsp";
	document.form1.FUNCION.value="enviarConsulta";
	//variable que existe en la jsp
	document.form1.NOMBRE.value=nombreRegalo;

	if (document.form1.DetalleRegalo.value==''){
		alert(vpCampoObl);
		document.form1.DetalleRegalo.focus();
		return;
	}else{
		if (document.form1.mailConsultaReg.value!=''){
			if(!checkMail(document.form1.mailConsultaReg)){
				return;
			}else{
				document.form1.submit();
			}
		}else{
			if (jsp == 'ConsultaRegaloFlotante.jsp'){
				if (document.form1.AsuntoRegalo.value==''){
					alert(vpCampoObl);
					document.form1.AsuntoRegalo.focus();
					return;
				}else{
					document.form1.submit();
				}
			}else{
				document.form1.submit();
			}
		}
	}
}

function eliminarCesta (jsp){
	document.form1.FUNCION.value="BORRAR";
	document.form1.action=jsp; //"CestaInstal.jsp";
	document.form1.submit();
}

function actualizarCesta(jsp){
	//validar que las cantidades introducidas son de tipo numérico
	if (form1){
		f = document.form1;
		for(var i=0; i<f.elements.length;i++){
			if ( f.elements[i].name.length>8 && f.elements[i].name.substring(0,8)=='UdCesta_'){
				//miramos si la cantidad es de tipo numerico
				if(!esNumeroValido(f.elements[i].value) ){
					f.elements[i].focus();
					return;
				}
			}
		}
	}
	//Desformatear los campos de puntos
	if (form1){
		f= document.form1;
		for(var i=0; i<f.elements.length;i++){
			if ( f.elements[i].name.length>7 && f.elements[i].name.substring(0,7)=='PUNTOS_'){
				f.elements[i].value = desformatearPuntos(f.elements[i].value);
			}
		}
	}
	document.form1.FUNCION.value="ACTUALIZAR";
	document.form1.action=jsp; //"CestaInstal.jsp";
	document.form1.submit();
}

function buscarRegalos(jsp){
	document.form1.action=jsp; //"RegalosOk.jsp";
	document.form1.PRIMERA_VEZ.value="S";
	document.form1.submit();
}

function verCesta(jsp){
	document.form1.action=jsp; //"CestaInstal.jsp";
	document.form1.submit();
}

function enviarPedidoCestaRegalos(jsp){
	document.form1.action=jsp; //"EnvioCestaRegalos.jsp";
	var comprobarCamposDireccion = false;
	if ( document.form1.DirEntregaCesta.length == 3){
		if (document.form1.DirEntregaCesta[2].checked){
			comprobarCamposDireccion = true;
			document.form1.DIRECCION_ENTREGA.value="direccion_ocasional";
		}else{
			if (document.form1.DirEntregaCesta[1].checked){
				document.form1.DIRECCION_ENTREGA.value="direccion_archivo_2";
			}else{
				document.form1.DIRECCION_ENTREGA.value="direccion_archivo_1";
			}
		}
	}else{
		if (document.form1.DirEntregaCesta.length == 2){
			if (document.form1.DirEntregaCesta[1].checked){
				comprobarCamposDireccion = true;
				document.form1.DIRECCION_ENTREGA.value="direccion_ocasional";
			}else{
				document.form1.DIRECCION_ENTREGA.value="direccion_archivo_1";
			}
		}else{
			//solo hay una direccion que es la direccion ocasional
			comprobarCamposDireccion = true;
			document.form1.DIRECCION_ENTREGA.value="direccion_ocasional";
		}
	}

	if (comprobarCamposDireccion == true){
		//mirar que ha introducido todos los campos
		if (document.form1.DirModSocio2.value==''){
			alert(vpIntroducirDir);
			document.form1.DirModSocio2.focus();
			return;
		}
		if (document.form1.PoblModSocio2.value==''){
			alert(vpIntroducirPobl);
			document.form1.PoblModSocio2.focus();
			return;
		}
		if (!codigoPostalValido(document.form1.CPModSocio2)){
			document.form1.CPModSocio2.focus();
			return;
		}
		if (document.form1.ProvPartAltaCombo.value==''){
			alert(vpElegirProv);
			document.form1.ProvPartAltaCombo.focus();
			return;
		}
		if (!telefonoValido(document.form1.TfnoModSocio2)){
			document.form1.TfnoModSocio2.focus();
			return;
		}
		if ( !direccionCorreoValida(document.form1.MailModSocio2)){
			document.form1.MailModSocio2.focus();
			return;
		}
	}

	//Desformatear los campos de puntos
	if (form1){
		f = document.form1;
		for(var i=0; i<f.elements.length;i++){
			if ( f.elements[i].name.length>7 && f.elements[i].name.substring(0,7)=='PUNTOS_' ){
				f.elements[i].value = desformatearPuntos(f.elements[i].value);
			}
		}
	}
	document.form1.ProvPartAlta.value= document.form1.ProvPartAltaCombo.options[document.form1.ProvPartAltaCombo.selectedIndex].text;
	document.form1.submit();
}


function deshabilitarBotonEnvio(valor){
	if (valor=='true'){
		document.form1.EnvCesta.disabled=true;
	}
}

function borrarCesta(jsp){
	var contesta = confirm("¿Quiere borrar la cesta?");
	if ( contesta == true){
		document.form1.FUNCION.value="BORRAR_CESTA";
		document.form1.action=jsp; //"RegalosOk.jsp";
		document.form1.submit();
	}
}

function imprimirVentana(){
	if (window.print){
    		window.print();
  	}else{
	    alert(vpNoImprimir);
	}
}

function imprimir(jsp){
	var ancho = 650;
	var alto = 600;
	if (document.all) var xMax = screen.width, yMax = screen.height;
	else
		if (window.outerWidth){
			var xMax = window.outerWidth, yMax = window.outerHeight;
		}
		else{
			var xMax = 800, yMax=600;
		}
	var xOffset = (xMax - ancho)/2, yOffset = (yMax - alto)/2 - 30;
	window.open(jsp,'Flotante_IMPRIMIR','scrollbars=YES,width='+ancho+',height='+alto+',top='+yOffset+',left='+xOffset);
}

function verImagen(imagen){
	var ancho = 300;
	var alto = 300;
	if (document.all) var xMax = screen.width, yMax = screen.height;
	else
		if (window.outerWidth){
			var xMax = window.outerWidth, yMax = window.outerHeight;
		}
		else{
			var xMax = 800, yMax=600;
		}
	var xOffset = (xMax - ancho)/2, yOffset = (yMax - alto)/2 - 30;
	window.open('imagen.jsp?IMAGEN='+imagen,'Flotante_IMAGEN','scrollbars=NO,width='+ancho+',height='+alto+',top='+yOffset+',left='+xOffset);
}

function damePagina(pagina,jsp){
	document.form1.action=jsp;
	document.form1.pagina.value=pagina;
	document.form1.submit();
}

function borrarFormulario(){
	if (document.form1){
		f = document.form1;
		for(var i=0; i<f.elements.length;i++){
			if ( f.elements[i].type=='text'||f.elements[i].type=='hidden' || f.elements[i].type=='select-one' ){
				f.elements[i].value='';
			}else{
				if (f.elements[i].type=='checkbox'){
					if (f.elements[i].name=='ACEPTO_PRIVACIDAD'){
						f.elements[i].checked=true;
					}else{
						f.elements[i].checked=false;
					}
				}
			}
		}
	}
}

function desformatearPuntos(puntosEntrada){
	var puntos="";
	for(var i=0;i<puntosEntrada.length;i++){
		if (puntosEntrada.charAt(i)!='.'){
			puntos= puntos+puntosEntrada.charAt(i);
		}
	}
	return puntos;
}

function validarFormularioSolicitud(){
	if (!verificarDatosUsuarioArriba()){
		return ;
	}else{
		//si no es socio debe introducir los datos de su empresa
		if ( !verificarDatosUsuarioEmpresa()){
			return;
		}else{
			/*if ( ! verificarDatosParticularesUsuario()){
				return;
			}else{*/
				//COndiciones del programa
				if (document.form1.AceptoCondProg.checked==false){
						alert(vpAceptarCond);
						return;
				}else{
					//hacer el submit
					document.form1.nombre_provincia.value = document.form1.provincia.options[document.form1.provincia.selectedIndex].text;
					if(document.form1.pais){
						document.form1.nombre_pais.value = document.form1.pais.options[form1.pais.selectedIndex].text;
					}
					if(document.form1.actividadInstal){
						document.form1.nombre_profesion.value = document.form1.actividadInstal.options[document.form1.actividadInstal.selectedIndex].text;
					}

					if (document.form1.direccionParticular.checked==true){
						document.form1.nombre_provincia2.value = document.form1.ProvPartAlta.options[document.form1.ProvPartAlta.selectedIndex].text;
						if(document.form1.PaisPartAlta){
							document.form1.nombre_pais2.value = document.form1.PaisPartAlta.options[document.form1.PaisPartAlta.selectedIndex].text;
						}
					}
					document.form1.action = "SolAdmision.jsp";
					document.form1.FUNCION.value = "alta";
					document.form1.submit();
				}
			//}
		}
	}
}

function verificarDatosUsuarioArriba() {
	if (document.form1.empresa.value==''){
		alert(vpCampoObl);
		document.form1.empresa.focus();
		return false;
	}else if (document.form1.nombre.value==''){
                alert(vpCampoObl);
                document.form1.nombre.focus();
                return false;
	}else if (document.form1.apellidos.value==''){
                alert(vpCampoObl);
                document.form1.apellidos.focus();
                return false;
	}else if (document.form1.nif.value=='' && document.form1.dni.value==''){
                alert(vpCampoObl);
                document.form1.nif.focus();
                return false;
        }else{
                return true;
        }
}

function verificarDatosUsuarioEmpresa(){
	if ((document.form1.colegiado && document.form1.colegiado.value=='') || !document.form1.colegiado){
		if (document.form1.direccion.value==''){
			alert(vpCampoObl);
			document.form1.direccion.focus();
			return false;
		}else if (document.form1.poblacion.value==''){
                        alert(vpCampoObl);
                        document.form1.poblacion.focus();
                        return false;
		}else if ( !codigoPostalValido(document.form1.cp)){
                          document.form1.cp.focus();
                          return false;
		}else if (document.form1.provincia.value==''){
                          alert(vpCampoObl);
                          document.form1.provincia.focus();
                          return false;
                }else if (document.form1.pais && document.form1.pais.value==''){
                          alert(vpCampoObl);
                          document.form1.pais.focus();
                          return false;
                }else if ( !telefonoValido(document.form1.tfno)){
                          document.form1.tfno.focus();
                          return false;
                }else if ( !telefonoValidoNoObligatorio(document.form1.movil)){
                          document.form1.movil.focus();
                          return false;
                }else if (!direccionCorreoValida(document.form1.email)){
                          document.form1.email.focus();
                          return false;
            	}else{
                	return true;
            	}
	}else{
		return true;
	}
}

function verificarDatosParticularesUsuario(){
	var datosParticulares = false;
	if (((document.form1.colegiado && document.form1.colegiado.value=='') || !document.form1.colegiado) && document.form1.direccionParticular.checked==true){
		datosParticulares = true;
	}
	if (datosParticulares == true){
		if (document.form1.DirPartiAlta.value==''){
			alert(vpCampoObl);
			document.form1.DirPartiAlta.focus();
			return false;
		}else if (document.form1.PoblPartAlta.value==''){
                        alert(vpCampoObl);
                        document.form1.PoblPartAlta.focus();
                        return false;
		}else if ( !codigoPostalValido(document.form1.CpPartAlta)){
                        document.form1.CpPartAlta.focus();
                        return false;
                }else if (document.form1.ProvPartAlta.value==''){
                        alert(vpCampoObl);
                        document.form1.ProvPartAlta.focus();
                        return false ;
                }else if (document.form1.PaisPartAlta && document.form1.PaisPartAlta.value==''){
                        alert(vpCampoObl);
                        document.form1.PaisPartAlta.focus();
                        return false;
                }else if (!telefonoValido(document.form1.TfnoPartAlta)){
                        document.form1.TfnoPartAlta.focus();
                        return false;
                }else if ( !direccionCorreoValida(document.form1.MailPartAlta)){
                        document.form1.MailPartAlta.focus();
                        return false;
                }else{
                        return true;
                }
	}else{
		return true;
	}
}

function modificarDatos(jsp){
	document.form1.action = jsp;
	if (validarCamposModificar ()){
		if (document.form1.sms.checked==true){
			if (!validarCamposModificarParticulares()){
				return;
			}else{
				document.form1.nombreProvincia.value=document.form1.ProvModSocio[document.form1.ProvModSocio.selectedIndex].text;
				document.form1.nombreProvinciaPar.value=document.form1.ProvPersModSocio[document.form1.ProvPersModSocio.selectedIndex].text;
				document.form1.FUNCION.value="modificar";
				//document.form1.action="SocioInstalOk.jsp";
				document.form1.submit();
			}
		}else{
			document.form1.nombreProvincia.value=document.form1.ProvModSocio[document.form1.ProvModSocio.selectedIndex].text;
			document.form1.FUNCION.value="modificar";
			//document.form1.action="SocioInstalOk.jsp";
			document.form1.submit();
		}
	}else{
		return;
	}
}

function validarCamposModificar(){
	if (document.form1.NomModSocio.value==''){
		alert(vpCampoObl);
		document.form1.NomModSocio.focus();
		return false;
	}else{
		if (document.form1.NombEmpresaModSocio.value==''){
			alert(vpCampoObl);
			document.form1.NombEmpresaModSocio.focus();
			return false;
		}else{
			if (document.form1.DirModSocio.value==''){
				alert(vpCampoObl);
				document.form1.DirModSocio.focus();
				return false;
			}else if (document.form1.PoblModSocio.value==''){
				alert(vpCampoObl);
				document.form1.PoblModSocio.focus();
				return false;
                        }else if ( !codigoPostalValido(document.form1.CPModSocio)){
                                document.form1.CPModSocio.focus();
                                return false;
                        }else if (document.form1.ProvModSocio.value==''){
                                alert(vpCampoObl);
                                document.form1.ProvModSocio.focus();
                                return false;
                        }else if (!telefonoValido(document.form1.TfnoModSocio)){
                                document.form1.TfnoModSocio.focus();
                                return false;
                        }else if ( !telefonoValido(document.form1.MovilModSocio)){
                                document.form1.MovilModSocio.focus();
                                return false;
                        }else if ( !faxValidoNoObligatorio (document.form1.FaxModSocio)){
                                document.form1.FaxModSocio.focus();
                                return false;
                        }else if (!direccionCorreoValida(document.form1.MailModSocio)){
                                document.form1.MailModSocio.focus();
                                return false;
                        }else{
                                return true;
                        }
		}
	}
}

function validarCamposModificarParticulares(){
	if (document.form1.DirPersModSocio.value==''){
		alert(vpCampoObl);
		document.form1.DirPersModSocio.focus();
		return false;
	}else if (document.form1.PoblPersModSocio.value==''){
                alert(vpCampoObl);
                document.form1.PoblPersModSocio.focus();
                return false;
        }else if ( !codigoPostalValido ( document.form1.CPPersModSocio)){
                document.form1.CPPersModSocio.focus();
                return false;
        }else if (document.form1.ProvPersModSocio.value==''){
                alert(vpCampoObl);
                document.form1.ProvPersModSocio.focus();
                return false;
        }else if ( !telefonoValido(document.form1.TfnoPersModSocio)){
                document.form1.TfnoPersModSocio.focus();
                return false;
        }else if ( !telefonoValido(document.form1.MovilPersModSocio)){
                document.form1.MovilPersModSocio.focus();
                return false;
        }else if ( !faxValido(document.form1.FaxPersModSocio)){
                document.form1.FaxPersModSocio.focus();
                return false;
        }else if ( !direccionCorreoValida ( document.form1.MailPerModSocio)){
                document.form1.MailPerModSocio.focus();
                return false;
        }else{
                return true;
        }
}

function buscarRegalosObtenidos(jsp){
	//"RegalosObtenidosListado.jsp";
	//validamos las fechas
	if (document.form1.FechaHastReg.value=="dd/mm/aaaa" || document.form1.FechaDesReg.value==''){
		document.form1.FECHA_INI.value="";
	}else{
		//if (!validarFechaStringSep(document.form1.FechaDesReg.value)){
		//	document.form1.FechaDesReg.focus();
		//	return;
		//}else{
			document.form1.FECHA_INI.value = document.form1.FechaDesReg.value;
		//}
	}
	if (document.form1.FechaHastReg.value=="dd/mm/aaaa" || document.form1.FechaHastReg.value == ''){
		document.form1.FECHA_FIN.value="";
	}else{
		//if (!validarFechaStringSep(document.form1.FechaHastReg.value)){
		//	document.form1.FechaHastReg.focus();
		//	return;
		//}else{
			document.form1.FECHA_FIN.value = document.form1.FechaHastReg.value;
		//}
	}
	if(document.form1.FECHA_INI.value != "" && document.form1.FECHA_FIN.value!= ""){
		if(dateCompareVP(document.form1.FECHA_INI.value,document.form1.FECHA_FIN.value) == "OK"){
			document.form1.action = jsp;
			document.form1.submit();
		}else{
			alert(vpFechaInicialInfFinal)
		}
	}else{
		document.form1.action = jsp;
		document.form1.submit();
	}
}

function comprobarFechaCorrecta(valor){
	if (valor.length != 10){
		alert(vpFormatoFecha);
		return false;
	}else{
		var arrayValores =  valor.split("/");
		if (arrayValores.length == 3){
			//miramos el dia
			var dia = arrayValores[0];
			if (dia.length != 2){
				alert(vpFormatoFecha);
				return false;
			}else if (!esNumeroValido(dia)){
				return false;
			}else{
				var mes = arrayValores[1];
				if ( mes.length != 2){
					alert(vpFormatoFecha);
					return false;
				}else if (!esNumeroValido(mes)){
					return false;
				}else{
					var anyo = arrayValores[2];
					if ( anyo.length != 4){
						alert(vpFormatoFecha);
						return false;
					}else if (!esNumeroValido(anyo)){
						return false;
					}else{
						//validamos la fecha
						if (! validarFechaInstalClub(dia,mes,anyo)){
							return false;
						}else{
							return true;
						}
					}
				}
			}
		}else{
			alert(vpFormatoFecha);
			return false;
		}
	}
}

function validarFechaInstalClub(dia, mes, anyo){
	//vemos si la fecha es válida
       //Si el año no es valido
       if (anyo<0)
       {
           alert(vpAnyoNoValido);
           return false;
       }
	if(anyoBisiesto(anyo))
           febrero=29;
       else
           febrero=28;
       //Miramo si el mes introducido es erroneo
       if ((mes<1) || (mes>12))
       {
           alert(vpMesNoValido);
           return false;
       }
       //Si el mes es febrero miramos si está bien introducido el dia
       if ((mes==2) && ((dia<1) || (dia>febrero)))
       {
           alert(vpDiaNoValido);
           return false;
       }
       //si es un mes de 31 días
       if (((mes==1) || (mes==3) || (mes==5) || (mes==7) || (mes==8) || (mes==10) || (mes==12)) && ((dia<1) || (dia>31)))
       {
           alert(vpDiaNoValido);
           return false;
       }
       //Si el mes tiene 30 días
       if (((mes==4) || (mes==6) || (mes==9) || (mes==11)) && ((dia<1) || (dia>30)))
       {
           alert(vpDiaNoValido);
           return false;
       }
       return true;
}

function verListadoCompletoRegalosObtenidos( jsp){
	document.form1.action = jsp; //"RegalosObtenidosListado.jsp";
	if(document.form1.FECHA_FIN)
		document.form1.FECHA_FIN.value = "";
	if(document.form1.FECHA_INI)
		document.form1.FECHA_INI.value = "";
	if(document.form1.Categoria)
		document.form1.Categoria.value="";
	if(document.form1.descRegalo)
		document.form1.descRegalo.value="";
	document.form1.submit();
}

function buscarPuntosAparato(jsp){
	document.form1.action = jsp; //"PuntosApartado.jsp";
	document.form1.FUNCION.value="buscar";
	document.form1.submit();
}

function habilitarCampos(){
	if (document.form1.sms.checked==true){
		//habilitamos los campos particulares
		document.form1.DirPersModSocio.disabled=false;
		document.form1.NomModSocio.disabled=false;
		document.form1.PoblPersModSocio.disabled=false;
		document.form1.CPPersModSocio.disabled=false;
		document.form1.ProvPersModSocio.disabled=false;
		document.form1.TfnoPersModSocio.disabled=false;
		document.form1.MovilPersModSocio.disabled=false;
		document.form1.FaxPersModSocio.disabled=false;
		document.form1.MailPerModSocio.disabled=false;
	}else{
		//deshabilitamos los campos particulares
		document.form1.DirPersModSocio.value='';
		document.form1.DirPersModSocio.disabled=true;
		document.form1.NomModSocio.value='';
		document.form1.NomModSocio.disabled=true;
		document.form1.PoblPersModSocio.value='';
		document.form1.PoblPersModSocio.disabled=true;
		document.form1.CPPersModSocio.value='';
		document.form1.CPPersModSocio.disabled=true;
		document.form1.ProvPersModSocio.value='';
		document.form1.ProvPersModSocio.disabled=true;
		document.form1.TfnoPersModSocio.value='';
		document.form1.TfnoPersModSocio.disabled=true;
		document.form1.MovilPersModSocio.value='';
		document.form1.MovilPersModSocio.disabled=true;
		document.form1.FaxPersModSocio.value='';
		document.form1.FaxPersModSocio.disabled=true;
		document.form1.MailPerModSocio.value='';
		document.form1.MailPerModSocio.disabled=true;
	}
}

function verExtracto(jsp){
	if(document.form1.FECHA_FIN){
		if(document.form1.FechaHastInstal && document.form1.FechaHastInstal.value!=""){
			document.form1.FECHA_FIN.value = document.form1.FechaHastInstal.value;
		}else{
			document.form1.FECHA_FIN.value = getActualDateDDMMYYYY();
		}
	}
	document.form1.action = jsp;
	document.form1.target = 'Flotante_DETALLE';
	var ancho = 700;
	var alto = 600;
	if (document.all) var xMax = screen.width, yMax = screen.height;
	else
		if (window.outerWidth){
			var xMax = window.outerWidth, yMax = window.outerHeight;
		}
		else{
			var xMax = 800, yMax=600;
		}
	var xOffset = (xMax - ancho)/2, yOffset = (yMax - alto)/2 - 30;
	window.open(jsp,'Flotante_DETALLE','scrollbars=YES,width='+ancho+',height='+alto+',top='+yOffset+',left='+xOffset);
	document.form1.submit();
	document.form1.target = '_self';
}

function buscarInstalacionesRealizadas(){
	//validamos las fechas
	if (document.form1.FechaDesInstal.value == "dd/mm/aaaa" || document.form1.FechaDesInstal.value == '' ){
		document.form1.FECHA_INI.value = "";
	}else{
		//if (!validarFechaStringSep(document.form1.FechaDesInstal.value)){
		//	document.form1.FechaDesInstal.focus();
		//	return;
		//}else{
			document.form1.FECHA_INI.value = document.form1.FechaDesInstal.value;
		//}
	}
	if (document.form1.FechaHastInstal.value=="dd/mm/aaaa" || document.form1.FechaHastInstal.value==''){
		document.form1.FECHA_FIN.value="";
	}else{
		//if (!validarFechaStringSep(document.form1.FechaHastInstal.value)){
		//	document.form1.FechaHastInstal.focus();
		//	return;
		//}else{
			document.form1.FECHA_FIN.value = document.form1.FechaHastInstal.value;
		//}
	}
	if(document.form1.AnnoInstal && document.form1.AnnoInstal.value!= ''){
		if (!esNumeroValido(document.form1.AnnoInstal.value)){
			document.form1.AnnoInstal.focus();
			return;
		}
	}
	if(document.form1.FECHA_INI.value != "" && document.form1.FECHA_FIN.value!= ""){
		if(dateCompareVP(document.form1.FECHA_INI.value,document.form1.FECHA_FIN.value) == "OK"){
			document.form1.action = "InstalRealizadasListado.jsp";
			document.form1.submit();
		}else{
			alert(vpFechaInicialInfFinal)
		}
	}else{
		document.form1.action = "InstalRealizadasListado.jsp";
		document.form1.submit();
	}
}

function getActualDateDDMMYYYY(){
	var mydate = new Date();
	var year = mydate.getYear();
	var month = mydate.getMonth();
	var day = mydate.getDate();
	if (day < 10)
		day = "0" + day;
	month = month + 1;
	if(month < 10)
		month = '0' + month;
	if(year.toString().length < 4){
		year = year + 1900;
	}
	var now = day.toString() + "-" + month.toString() + "-" + year.toString();
	return now;
}

function buscarPuntosWeb(){
	//validamos las fechas
	if(document.form1.FechaDesInstal.value == ''){
		alert(vpFechaIniObl);
		return;
	}else{
		if (document.form1.FechaDesInstal.value == "dd/mm/aaaa" || document.form1.FechaDesInstal.value == '' ){
			document.form1.FECHA_INI.value = "";
		}else{
			//if (!validarFechaStringSep(form1.FechaDesInstal.value)){
			//	document.form1.FechaDesInstal.focus();
			//	return;
			//}else{
				document.form1.FECHA_INI.value = document.form1.FechaDesInstal.value;
			//}
		}
		if (document.form1.FechaHastInstal.value=="dd/mm/aaaa" || document.form1.FechaHastInstal.value==''){
			document.form1.FECHA_FIN.value = getActualDateDDMMYYYY();
		}else{
			//if (!validarFechaStringSep(document.form1.FechaHastInstal.value)){
			//	document.form1.FechaHastInstal.focus();
			//	return;
			//}else{
				document.form1.FECHA_FIN.value = document.form1.FechaHastInstal.value;
			//}
		}
		if(document.form1.FECHA_INI.value != "" && document.form1.FECHA_FIN.value!= ""){
			if(dateCompareVP(document.form1.FECHA_INI.value,document.form1.FECHA_FIN.value) == "OK"){
				document.form1.action = "puntosWeb.jsp";
				document.form1.submit();
			}else{
				alert(vpFechaInicialInfFinal)
			}
		}else{
			document.form1.action = "puntosWeb.jsp";
			document.form1.submit();
		}
	}
}

function buscarPuntosWebDistal(){
	//validamos las fechas
	if(document.form1.FechaDesInstal.value == ''){
		alert(vpFechaIniObl);
		return;
	}else{
		//validamos las fechas
		if (document.form1.FechaDesInstal.value == "dd/mm/aaaa" || document.form1.FechaDesInstal.value == '' ){
			document.form1.FECHA_INI.value = "";
		}else{
			if (!validarFechaStringSep(form1.FechaDesInstal.value)){
				document.form1.FechaDesInstal.focus();
				return;
			}else{
				document.form1.FECHA_INI.value = document.form1.FechaDesInstal.value;
			}
		}
		if (document.form1.FechaHastInstal.value=="dd/mm/aaaa" || document.form1.FechaHastInstal.value==''){
			document.form1.FECHA_FIN.value = getActualDateDDMMYYYY();
		}else{
			if (!validarFechaStringSep(form1.FechaHastInstal.value)){
				document.form1.FechaHastInstal.focus();
				return;
			}else{
				document.form1.FECHA_FIN.value = form1.FechaHastInstal.value;
			}
		}
		if(document.form1.FECHA_INI.value != "" && document.form1.FECHA_FIN.value!= ""){
			if(dateCompareVP(document.form1.FECHA_INI.value,document.form1.FECHA_FIN.value) == "OK"){
				document.form1.action = "puntosWebDistal.jsp";
				document.form1.submit();
			}else{
				alert(vpFechaInicialInfFinal)
			}
		}else{
			document.form1.action = "puntosWebDistal.jsp";
			document.form1.submit();
		}
	}
}

function verListadoCompletoInstRealizadas(){
	document.form1.action="InstalRealizadasListado.jsp";
	//hay que poner todos a blanco
	if(document.form1.FECHA_INI)
		document.form1.FECHA_INI.value="";
	if(document.form1.FECHA_FIN)
		document.form1.FECHA_FIN.value="";
	if(document.form1.AnnoInstal)
		document.form1.AnnoInstal.value="";
	if(document.form1.TipAptoPuntos)
		document.form1.TipAptoPuntos.value="";
	if(document.form1.ModInstal)
		document.form1.ModInstal.value="";
	if(document.form1.DirInstal)
		document.form1.DirInstal.value="";
	if(document.form1.PoblInstal)
		document.form1.PoblInstal.value="";
	if(document.form1.ProvInstal)
		document.form1.ProvInstal.value="";
	if(document.form1.CPInstal)
		document.form1.CPInstal.value="";
	document.form1.submit();
}

function cargarRadio(valorAnyo){
	if (valorAnyo != ''){
		document.form1.PuntosDisp[1].checked=true;
		//deshabilitar los campos
		document.form1.FechaHastInstal.value="dd/mm/aaaa";
		document.form1.FechaHastInstal.disabled=true;
		document.form1.FechaDesInstal.value="dd/mm/aaaa";
		document.form1.FechaDesInstal.disabled=true;
	}else{
		document.form1.PuntosDisp[0].checked=true;
		document.form1.AnnoInstal.value="";
		document.form1.AnnoInstal.disabled=true;
	}
}

function habilitarCamposInstalaciones(valor){
	if (valor==0){
		//habilitar campo fecha y deshabilitar campo anyo
		//deshabilitar los campos
		document.form1.FechaHastInstal.disabled=false;
		document.form1.FechaDesInstal.disabled=false;
		document.form1.AnnoInstal.value="";
		document.form1.AnnoInstal.disabled=true;
	}else{
		document.form1.FechaHastInstal.value="dd/mm/aaaa";
		document.form1.FechaHastInstal.disabled=true;
		document.form1.FechaDesInstal.value="dd/mm/aaaa";
		document.form1.FechaDesInstal.disabled=true;
		document.form1.AnnoInstal.disabled=false;
	}
}

function verDetalleInstalacion(idInstalacion){
	var ancho = 470;
	var alto = 310;
	if (document.all) var xMax = screen.width, yMax = screen.height;
	else
		if (window.outerWidth){
			var xMax = window.outerWidth, yMax = window.outerHeight;
		}
		else{
			var xMax = 800, yMax=600;
		}
	var xOffset = (xMax - ancho)/2, yOffset = (yMax - alto)/2 - 30;
	window.open('DetalleInstalaciones.jsp?ID_INSTALACION='+idInstalacion,'Flotante_DETALLE','scrollbars=YES,width='+ancho+',height='+alto+',top='+yOffset+',left='+xOffset);
}

function cambiarCombo(){
	document.form1.action="IntroGarantia1.jsp";
	document.form1.submit();
}

function introducirGarantia1(){
	if (document.form1.TipAptoGarant.value ==''){
		alert(vpElegirTipoAp);
		document.form1.TipAptoGarant.focus();
		return;
	}else{
		if (document.form1.FamGarant.value ==''){
			alert(vpElegirFam);
			document.form1.FamGarant.focus();
			return;
		}else{
			if (document.form1.ModGarant.value ==''){
				alert(vpElegirMod);
				document.form1.ModGarant.focus();
				return;
			}else{
				document.form1.action="IntroGarantia2.jsp";
				document.form1.idcatalogo.value=document.form1.TipAptoGarant.options[document.form1.TipAptoGarant.selectedIndex].value;
				document.form1.catalogo.value=document.form1.TipAptoGarant.options[document.form1.TipAptoGarant.selectedIndex].text;
				document.form1.familia.value=document.form1.FamGarant.options[document.form1.FamGarant.selectedIndex].text;
				document.form1.modelo.value=document.form1.ModGarant.options[document.form1.ModGarant.selectedIndex].text;
				document.form1.submit();
			}
		}
	}
}

/*function checkNSerie(str){
	var str;
	var filter  = /^([a-zA-Z0-9\<\>\/\(\)\#\Ñ\ñ])+$/;
	if (filter.test(str)) return true;
	else{
		return false;
	}
}*/
function validarNumSerie(nSerieGarant){
	for(var i=0;i<nSerieGarant.length; i++){
		if(!esNumeroValidoSinAlert(nSerieGarant.charAt(i)) && nSerieGarant.charAt(i) != "0" &&
		   nSerieGarant.charAt(i) != "<" && nSerieGarant.charAt(i) != ">" && nSerieGarant.charAt(i) != "/" && nSerieGarant.charAt(i) != "(" && nSerieGarant.charAt(i) != ")" && nSerieGarant.charAt(i) != "#" &&
 		   !(nSerieGarant.charCodeAt(i)>64 && nSerieGarant.charCodeAt(i)<91) && nSerieGarant.charCodeAt(i)!=209 &&
 		   !(nSerieGarant.charCodeAt(i)>96 && nSerieGarant.charCodeAt(i)<123) && nSerieGarant.charCodeAt(i)!=241){
			return false;
		}
	}
	return true;
}

function enviarGarantia2(sinDatosUsuario){
	
	//contratos no existe si seguimos el procedimiento habitual
	if(document.form1.contratos!=undefined){
		var elegido = false;
		for (i=0;i<document.form1.contratos.length;i++){
		     if (document.form1.contratos[i].value == 'si' &&
		    	   document.form1.contratos[i].checked==true){
		    	 	elegido = true;
			          
		    } else if (document.form1.contratos[i].value == 'no' &&
			    	   document.form1.contratos[i].checked==true){
				elegido = true;
		    } else if (document.form1.contratos[i].value == 'nada' &&
			    	   document.form1.contratos[i].checked==true){
				alert("Debe elegir un valor para el campo contrato de mantenimiento.");
				return;
		    }
		}
		if (!elegido) {
			alert("Debe elegir un valor para el campo contrato de mantenimiento.");
			return;
		}
	}
	if(sinDatosUsuario!=null && sinDatosUsuario!="undefined"){
		if (document.form1.UsuarioGarant.value==''){
			document.getElementById("capaObligatorios").style.display="block";
			document.form1.UsuarioGarant.focus();
			return;
		}else if (document.form1.UsuarioApellidos.value ==''){
			document.getElementById("capaObligatorios").style.display="block";
			document.form1.UsuarioApellidos.focus();
			return;
		}else if (document.form1.DirGarant.value==''){
			document.getElementById("capaObligatorios").style.display="block";
			document.form1.DirGarant.focus();
			return;
		}
	}	
	
	
	//validamos los campos que ha metido
	if (document.form1.NSerieGarant.value ==''){
		alert(vpIntroducirNSerie);
		document.form1.NSerieGarant.focus();
		return;
	}//else{
//		if (document.form1.noFechaPMarcha.checked==false){
//			if (document.form1.FechaPMGarant.value==''){
//				alert(vpIntroducirFechaPMarcha);
//				document.form1.FechaPMGarant.focus();
//				return;
//			}
//		}
//		if (document.form1.UsuarioGarant.value==''){
//			alert(vpIntroducirNom);
//			document.form1.UsuarioGarant.focus();
//			return;
//		}else if (document.form1.UsuarioApellidos.value ==''){
//			alert(vpIntroducirApel);
//			document.form1.UsuarioApellidos.focus();
//			return;
//		}else if (document.form1.tipoVia.value==''){
//			alert("Seleccione Tipo de Via");
//			document.form1.tipoVia.focus();
//			return;
//		}else if (document.form1.DirGarant.value==''){
//			alert(vpIntroducirDir);
//			document.form1.DirGarant.focus();
//			return;
//		}else if (document.form1.PoblGarant.value==''){
//			alert(vpIntroducirPobl);
//			document.form1.PoblGarant.focus();
//			return;
//		}else if (document.form1.ProvGarant.value==''){
//			alert(vpElegirProv);
//			document.form1.ProvGarant.focus();
//			return;
//		}else if ( !codigoPostalValido(document.form1.CPostGarant)){
//			document.form1.CPostGarant.focus();
//			return;
//		}else if (document.form1.TfnoGarant.value==''){
//			alert(vpIntroducirTelef);
//			document.form1.TfnoGarant.focus();
//			return;
//		}else if (document.form1.TfnoGarant.value!='' && !telefonoValido(document.form1.TfnoGarant)){
//			document.form1.TfnoGarant.focus();
//			return;
		//}
	else if(document.form1.NSerieGarant && document.form1.NSerieGarant.value!="" && !validarNumSerie(document.form1.NSerieGarant.value)){
			alert(vpNSerieNoValido);
			document.form1.NSerieGarant.focus();
			return;
		}else{
			//document.form1.action="InformeGarantia.jsp";
			document.form1.action="IntroGarantia.jsp";
			document.form1.nombreProv.value=document.form1.ProvGarant[document.form1.ProvGarant.selectedIndex].text;
			document.form1.FUNCION.value="introduccionGarantia";
//			//Actualizar datos de hidden
//                        document.form1.idcatalogo.value=document.form1.selectTA.options[document.form1.selectTA.selectedIndex].value;
//                        document.form1.catalogo.value=document.form1.selectTA.options[document.form1.selectTA.selectedIndex].text;
//                        //document.form1.idfamilia.value=document.form1.selectFam.options[document.form1.selectFam.selectedIndex].value;
//			document.form1.familia.value=document.form1.selectFam.options[document.form1.selectFam.selectedIndex].text;
//                        document.form1.idProducto.value=document.form1.selectTE.options[document.form1.selectTE.selectedIndex].value;
//                        document.form1.modelo.value=document.form1.selectTE.options[document.form1.selectTE.selectedIndex].text;
//			document.form1.ModGarant.value=document.form1.selectTE.options[document.form1.selectTE.selectedIndex].text;
			document.form1.submit();
		}
	//}
}

function introducirMismaGarantia(){
	document.form1.action = "IntroGarantia2.jsp";
	document.form1.submit();
}

function introducirGarantias(){
	document.form1.action = "IntroGarantia1.jsp";
	document.form1.submit();
}

function irDatosSocio(){
	document.form1.action="SocioInstalOk.jsp";
	document.form1.submit();
}

function deshabilitarSolicAlta(){
	if (document.form1.direccionParticular.checked == false){
		//deshabilitar campos
		document.form1.DirPartiAlta.value='';
		document.form1.DirPartiAlta.disabled= true;
		document.form1.PoblPartAlta.value='';
		document.form1.PoblPartAlta.disabled= true;
		document.form1.CpPartAlta.value='';
		document.form1.CpPartAlta.disabled= true;
		document.form1.ProvPartAlta.value='';
		document.form1.ProvPartAlta.disabled= true;
		if(document.form1.PaisPartAlta){
			document.form1.PaisPartAlta.value='';
			document.form1.PaisPartAlta.disabled= true;
		}
		document.form1.TfnoPartAlta.value='';
		document.form1.TfnoPartAlta.disabled= true;
		document.form1.MovPartAlta.value='';
		document.form1.MovPartAlta.disabled= true;
		if(document.form1.sms2){
			document.form1.sms2.checked=false;
			document.form1.sms2.disabled= true;
		}
		document.form1.MailPartAlta.value='';
		document.form1.MailPartAlta.disabled= true;
		//document.form1.mail2.checked=false;
		//document.form1.mail2.disabled= true;
	}else{
		//deshabilitar campos
		document.form1.DirPartiAlta.disabled= false;
		document.form1.PoblPartAlta.disabled= false;
		document.form1.CpPartAlta.disabled= false;
		document.form1.ProvPartAlta.disabled= false;
		if(document.form1.PaisPartAlta){
			document.form1.PaisPartAlta.disabled= false;
		}
		document.form1.TfnoPartAlta.disabled= false;
		document.form1.MovPartAlta.disabled= false;
		if(document.form1.sms2){
			document.form1.sms2.disabled= false;
		}
		document.form1.MailPartAlta.disabled= false;
		//document.form1.mail2.disabled= false;
	}
}

function volverInstalRealizadas(){
	document.form1.action = "InstalRealizadasListado.jsp";
	document.form1.VOLVER.value="S";
	document.form1.FECHA_INI.value="";
	document.form1.FECHA_FIN.value="";
	document.form1.AnnoInstal.value="";
	document.form1.TipAptoPuntos.value="";
	document.form1.ModInstal.value="";
	document.form1.DirInstal.value="";
	document.form1.PoblInstal.value="";
	document.form1.ProvInstal.value="";
	document.form1.CPInstal.value="";
	document.form1.submit();
}

function buscarRegalosPuntos(jsp, puntos){
	document.formPUNTOS.action = jsp;
	document.formPUNTOS.Puntos.value=desformatearPuntos(puntos);
	document.formPUNTOS.submit();
}

//FUNCIONES DISTALCLUB
function buscarPuntosObtenidos(){
	document.form1.action = "PuntosCompra.jsp";
	//comprobamos que el  anyo es un número
	if(document.form1.Anyo.value!= '' && !esNumeroValido(document.form1.Anyo.value) ){
		document.form1.Anyo.focus();
		return;
	}else{
		document.form1.submit();
	}
}

function verListadoCompletoPuntosCompra(){
	document.form1.action="PuntosCompra.jsp";
	document.form1.Anyo.value="";
	document.form1.MesInicio.value="";
	document.form1.MesHasta.value="";
	document.form1.submit();
}

function cargarCombosPuntosCompra(mesInicio, mesFin){
	if (mesInicio != ''){
		document.form1.MesInicio.value=mesInicio;
	}
	if (mesFin != ''){
		document.form1.MesHasta.value=mesFin;
	}
}

function verPedido(jsp){
	document.form1.action = jsp;
	document.form1.submit();
}

function codigoPostalValido(campo){
	if (campo.value==''){
		alert(vpIntroducirCP);
		return false;
	}else{
		//si es numerico
		if(!esNumeroValido(campo.value)){
			return false;
		}else{
			if (campo.value.length!=5){
				alert(vpIntroducirCPValido);
				return false;
			}else{
				return true;
			}
		}
	}
}

function telefonoValido(campo){
	if (campo.value==''){
		alert(vpIntroducirNumTelef);
		return false;
	}else{
		//si es numerico
		if(!esNumeroValido(campo.value)){
			return false;
		}else{
			if (campo.value.length!=9){
				alert(vpIntroducirNumTelefValido);
				return false;
			}else{
				return true;
			}
		}
	}
}

function telefonoValidoNoObligatorio(campo){
	if (campo.value==''){
		return true;
	}else{
		//si es numerico
		if(!esNumeroValido(campo.value)){
			return false;
		}else{
			if (campo.value.length!=9){
				alert(vpIntroducirNumTelefValido);
				return false;
			}else{
				return true;
			}
		}
	}
}

function direccionCorreoValida( campo ){
	if (campo.value==''){
		alert(vpIntroducirCorreo);
		return false;
	}else{
		//si es numerico
		if(!checkMail(campo)){
			return false;
		}else{
			return true;
		}
	}
}

function faxValidoNoObligatorio(campo){
	if(campo.value!=""){
		//si es numerico
		if(!esNumeroValido(campo.value)){
			return false;
		}else{
			if (campo.value.length!=9){
				alert(vpIntroducirFaxValido);
				return false;
			}else{
				return true;
			}
		}
	}else{
		return true;
	}
}

function faxValido(campo){
	if (campo.value==''){
		alert(vpIntroducirFax);
		return false;
	}else{
		//si es numerico
		if(!esNumeroValido(campo.value)){
			return false;
		}else{
			if (campo.value.length!=9){
				alert(vpIntroducirFaxValido);
				return false;
			}else{
				return true;
			}
		}
	}
}

/*
* Método que llama a la jsp poder ver el contenido de un fichero
*/
function verDocumentoPDF(valor){
	if(!document.form1.ID){
		if(!document.getElementById("ID")){
			var input1 = document.createElement('INPUT');
			input1.type = "hidden";
			input1.value = valor;
			input1.name = "ID";
			input1.id = "ID";
			document.form1.appendChild(input1);
		}
	}
	else{
		var input1 = document.getElementById("ID");
		input1.value = valor;
	}
	if (valor = '2783') {		
		var pageTracker = _gat._getTracker("UA-5787431-1");
		pageTracker._trackPageview("/descarga/PDFPromo");
	}
//	document.form1.action="documento.jsp";
	document.form1.action="DocumentoServlet";
	document.form1.submit();
}

function dateCompareVP(fechaD,fechaH){
	var yearone = fechaD.charAt(6) + fechaD.charAt(7) + fechaD.charAt(8) + fechaD.charAt(9);
	var monthone = fechaD.charAt(3) + fechaD.charAt(4);
	var dayone = fechaD.charAt(0) + fechaD.charAt(1);

	var yeartwo = fechaH.charAt(6) + fechaH.charAt(7) + fechaH.charAt(8) + fechaH.charAt(9);
	var monthtwo = fechaH.charAt(3) + fechaH.charAt(4);
	var daytwo = fechaH.charAt(0) + fechaH.charAt(1);

	var fechaDNumeric = (yearone + monthone + dayone) * 1;
	var fechaHNumeric = (yeartwo + monthtwo + daytwo) * 1;

	if(fechaDNumeric > fechaHNumeric)
		return "NOT_OK";
	else
		return "OK";
}


function pedirAyuda(idSocio){
	document.getElementById("capaAyuda").style.display = 'block';
    urlRespuesta = "ServletAyudaVaillantPremium?idSocio=" + idSocio;
   
    getResponseXml(urlRespuesta);
}

function setAyudaText(){
	document.getElementById("Ayuda").value = "     Ayuda\n\r   On Line";
}

function buscarPreguntas(){
	if (document.formFAQ.consulta.value=="") {
		alert("Introduzca la consulta");
		document.formFAQ.consulta.focus();
		return;
	} else {
		document.formFAQ.FUNCION.value="SELECT";
		document.formFAQ.CRITERIO.value=document.formFAQ.consulta.value;
		document.formFAQ.action="PreguntasFrecuentes.jsp";
		document.formFAQ.submit();
	}
}
function hacerConsulta(idFAQ, respuesta){
	document.formConsulta.idPregunta.value = idFAQ;
		
	
			document.formConsulta.RESPUESTA.value = respuesta;
			
			if(respuesta == "si"){
				document.formConsulta.FUNCION.value="INSERTAR_FAQ_SOCIO";
		      	document.formConsulta.action="MensajeFAQ.jsp";
				document.formConsulta.submit();
			}else if(respuesta == "no"){	
				document.formConsulta.FUNCION.value="INSERTAR_FAQ_SOCIO";
				document.formConsulta.action="PreguntarOperadora.jsp";
				document.formConsulta.submit();
			}
      		

}
function irDetalleFaq(idFAQ, idRes) {
 	document.formDetalleFaq.idPregunta.value = idFAQ;
 	document.formDetalleFaq.idRespuesta.value = idRes;
	document.formDetalleFaq.action= "DetalleFAQ.jsp";
	document.getElementById("formDetalleFaq").submit();

}

function hacerPregunta(idSocio){	
	urlRespuesta = "ServletAyudaVaillantPremium?idSocio=" + idSocio;
    //getResponseXml(urlRespuesta);
    
	document.formPreguntar.FUNCION.value="INSERTAR_PREG_ALTER";	
	document.formPreguntar.pregunta.value = 	document.formPreguntar.pregunta.value;
	document.formPreguntar.telefonoAl.value = 	document.formPreguntar.telefonoAl.value;
		

	if(document.formPreguntar.telefonoAl.value =="" && document.formPreguntar.email.value =="" ){
		alert("Debe rellenar una forma de contacto.");
	}else if(document.formPreguntar.pregunta.value =="" ){
		alert("Debe rellenar una pregunta.");
	}else{
		document.formPreguntar.action="MensajeFAQ.jsp";
		document.formPreguntar.submit();
	}
	
   function hacerConsultaMail(idSocio){
    urlRespuesta = "ServletFAQVaillantPremium?idSocio=" + idSocio;
    }   

}


