/********************************************************************
	Función para enviar el formulario de Suscripción al Boletín de Ofertas
*********************************************************************/

function EnviarSuscripcion(){
		if (document.form.suscribete.value!=""){
			if (!es_mail(document.form.suscribete.value)){
				alert("El E-MAIL no tiene el formato correcto");
				document.form.suscribete.focus();
				return;
			}
		}
	document.getElementById ('enviar').style.display = 'none';
	document.form.submit(); 

}

/********************************************************************
	Función para comprobar formato e-mail
*********************************************************************/
function es_mail(mail){
		if (mail.indexOf('@')==-1){
			return false;
		}
		else{
			mail_tmp=mail.substring(mail.indexOf('@'),mail.length);
			if (mail_tmp.indexOf('.')==-1){
				return false;
			}
			else{
				return true;
			}
		}
	}
	
/********************************************************************
	Función para comprobar formato NIF
*********************************************************************/
function es_nif(dni) {
	numero = dni.substr(0,dni.length-1);
	let = dni.substr(dni.length-1,1);
	let = getUpper(let);
	numero = numero % 23;
	letra='TRWAGMYFPDXBNJZSQVHLCKET';
	letra=letra.substring(numero,numero+1);
	if (letra!=let) {
		return false;
	}else {
		return true;
	}
}

function getUpper(str){
	return str.toUpperCase();
}

/********************************************************************
	Función para comprobar formato numérico
*********************************************************************/	
	function es_numerico(texto){
			caracteres_validos="1234567890";
			for (k=0;k<texto.length;k++){
				tmp=texto.substr(k,1);
				if (caracteres_validos.search(tmp)=="-1"){
					return false;
				}
			}
			return true;
		}

function irAOferta(idOferta)
		{ 
			h=10;
			v=10;
			var WIN1=window.open('det_Oferta.asp?idOferta='+idOferta,'','width=400,height=400,scrollbars=yes');
			for (i=0;i<=10;i=i+1)
				{
					h=h+i;
					v=v+i;
					WIN1.moveTo(h,v)
				}	
		}

function irAReceta()
		{ 
			h=10;
			v=10;
			var WIN2=window.open('det_RecetaCheff.asp','','width=430,height=500,scrollbars=yes');
			for (i=0;i<=10;i=i+1)
				{
					h=h+i;
					v=v+i;
					WIN2.moveTo(h,v)
				}	
		}
function irAHotelMes()
		{ 
			h=10;
			v=10;
			var WIN3=window.open('det_HotelMes.asp','','width=555,height=575,scrollbars=yes');
			for (i=0;i<=10;i=i+1)
				{
					h=h+i;
					v=v+i;
					WIN3.moveTo(h,v)
				}	
		}

/********************************************************************
	Función para cambiar el idioma
*********************************************************************/

//esta función no actua, la he cambiado por cambioIdioma.
//function cambiarIdioma2(idi){

//	if (document.location.href.indexOf("idioma")!=-1){
//		longitudURL = document.location.href.length;
//		if (document.location.href.substring((longitudURL-9),(longitudURL-3))== "idioma"){
//		nuevaLocation=document.location.href.substring(0,(longitudURL-10));
//		}else{
//		nuevaLocation=document.location.href;
//		}
//		if (nuevaLocation.indexOf("?")!=-1){
//				document.location=nuevaLocation + "&idioma=" + idi;
//			}else{
//				document.location=nuevaLocation + "?idioma=" + idi;			
//		}
//	}else{
//		if (document.location.href.indexOf("?")!=-1){
//		document.location=document.location.href + "&idioma=" + idi;
//			}else{
//		document.location=document.location.href + "?idioma=" + idi;		
//		}
//	}
//}


function cambiarIdioma(idi){
	cambioIdioma(idi,this.location);	
}
function cambioIdioma(idi,url){
	this.location="http://web.desarrollando.net/zenit/cambioIdioma.asp?idioma="+idi+"&url="+url;
}




/********************************************************************
	Validación de Fechas
*********************************************************************/
var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29;
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;

function makeArray(n) {
   for (var i = 1; i <= n; i++) {
      this[i] = 0;
   } 
   return this;
}

function daysInFebruary(whichYear) {
    return (whichYear % 4 == 0 && (!(whichYear % 100 == 0) || (whichYear % 400 == 0)) ? 29 : 28);
}

function esFecha(dd, mm, yyyy) {
	var blnFechaIncorrecta;

	/* COMENTARIOS
		if (dd !="" && !(dd > 0 && dd < 32))
		{
			alert ("Día no válido..");
			return false;
		}
		if (yyyy !="" && !(yyyy > 1889 && yyyy < 2011)){
			alert ("Año no válido.");
			return false;
		}
	FIN DE COMENTARIOS */


	if ((dd!="" && mm!="") && dd > daysInMonth[mm])
	{
		blnFechaIncorrecta=1;
	}
	if ((mm=="2" || mm=="02" && dd!="" && yyyy!="") && dd > daysInFebruary(yyyy))
	{
		blnFechaIncorrecta=1;
	}
	if(blnFechaIncorrecta==1){
		//alert("La fecha no es correcta");
		return false;
	}else{
		return true;
	}
}


/********************************************************************
	Función para abrir pop up de Hoteles
*********************************************************************/

function AbrirPop(pagina){
	laventana=window.open(pagina,'','width=430,height=500,scrollbars=yes');
	

}
function AbrirGaleria(pagina){
	laventana=window.open(pagina,'','width=580,height=505,scrollbars=no');
}

/********************************************************************
	Función para abrir pop up de Aviso legal y privacidad
*********************************************************************/

function abrePopCondiciones(pagina){
	window.open(pagina,'','width=570,height=300,scrollbars=no');
}


/********************************************************************
	Función para abrir ampliación de imágenes
*********************************************************************/

function AbreImagen(pagina){

	laventana=window.open(pagina,'','width=430,height=460,scrollbars=auto');
	

}

/********************************************************************
	Función para mostrar capas de hoteles en hoteles.asp
*********************************************************************/


function mostrarCapa2(amostrar, totalcapas)
		{
			if (document.layers)
				{ 
					for(i=1;i<totalcapas+1;i++)
						{	document.layers[i].visibility="hide"; }
					document.layers[amostrar].visibility="show"; }
			else
				{
					for(i=1;i<totalcapas+1;i++)
						{	document.getElementById(i).style.visibility="hidden"; }
					document.getElementById(amostrar).style.visibility="visible";
				}
		}
		
		mostrado=null;
		
function mostrarCapa(amostrar)
		{
			if (document.layers)
				{ 
					if(mostrado!=null){
						document.layers[mostrado].visibility="hide";
					}
					document.layers[amostrar].visibility="show"; 
			}else{
					if(mostrado!=null){
						document.getElementById(mostrado).style.visibility="hidden"
					}
					document.getElementById(amostrar).style.visibility="visible";
			}
			mostrado=amostrar;
		}


function paginar(pag)
	{
		switch (wPagASP)
			   { 
				case (1):	document.location="noticias.asp?pag="+pag;
							break;
				case (2):	document.location="ofertas.asp?pag="+pag;
							break;
				case (3):	document.location="salones.asp?pag="+pag;
							break;
			   }
		
	}


impreso=false;
function imprimir(){
	document.getElementById('elScroll').style.overflow="visible";
	window.focus();
	impreso=true;
	window.print();
}
	
function volver(){
	if (impreso){
		document.getElementById('elScroll').style.overflow="auto";
		impreso=false;
	}
}	

/********************************************************************
	Función para sacar el pop-up del restaurante desde la sección restauración
*********************************************************************/
function enviarRestaurante(){
	var id=formRest.RestauranteID.value;
	if (id!=0){
	window.open("popRestauracion.asp?RestID="+id ,"","width=430,height=500,scrollbars=yes");
	}
}

function cerosIzquierda(sTexto, tamTotal){
		while (sTexto.length<tamTotal){
			sTexto = "0" + sTexto;
		}
		return sTexto;
	}