//funcion contra el spam
function antispam(cuenta,clase)
{
var dominio = "kabukicafe.com"
document.write("<a class='"+ clase +"' href=\"mailto:" + cuenta + "@" + dominio + "\">" + cuenta + "@" + dominio + "</a>");
}

function opcionmenu(){
	if ((self.location.href == 'http://servidor.kabukicafe/') || (self.location.href == 'http://www.kabukicafe.com/nueva/') || (self.location.href == 'http://www.kabukicafe.com/'))
	{
		var marcado='';
	}
	else
	{
		var documento = self.location.href.match( /\/([^/]+)$/ )[1];
		marcado = documento.replace(".aspx","");
	}
	
	if (document.getElementById("imagen_" + marcado)!=null)
	{
		document.getElementById("imagen_" + marcado).src="imagenes/"+ marcado +"_on.png";
		document.getElementById("imagen_" + marcado).onmouseout=function(){}
	}
}

// funciones para la fecha y hora
function fecha(){
	var mydate=new Date();
	var year=mydate.getYear();

	if (year < 1000)
		year+=1900;
		
	var day=mydate.getDay();
	var month=mydate.getMonth();
	var daym=mydate.getDate();

	if (daym<10)
	daym="0"+daym;

	var dayarray=new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado");
	var montharray=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
	document.write(dayarray[day]+ ", " + daym + " de " + montharray[month] + " de " + year);
}

function hora(){
	if (!document.layers&&!document.all&&!document.getElementById)

	return
	var Digital=new Date()
	var hours=Digital.getHours()
	var minutes=Digital.getMinutes()
	var seconds=Digital.getSeconds()
	var dn="am" 
	if (hours>12){
	dn="pm"
	hours=hours-12
	}

	if (hours==0)
	hours=12
	
	if (hours<=9)
	hours="0"+hours

	if (minutes<=9)
	minutes="0"+minutes

	if (seconds<=9)
	seconds="0"+seconds

	//change font size here to your desire

	myclock=hours+":"+minutes+" "+dn

	if (document.layers){
	document.layers.liveclock.document.write(myclock)
	document.layers.liveclock.document.close()
	}
	else if (document.all)
	liveclock.innerHTML=myclock
	else if (document.getElementById)
	document.getElementById("liveclock").innerHTML=myclock
	setTimeout("hora()",1000)
}

// Validar formulario de registro en el club
function validar_registro(formulario){
	if ((formulario.nombre.value == "") || (formulario.apellidos.value == "") || (formulario.dni.value == "") || (formulario.edad.value == "") || (formulario.telefono.value == "") || (formulario.email.value == "") || (formulario.poblacion.value == "")){
		alert("Todos los campos son obligatorios");
		return(false);
	}
	
	else{
		if (validarEmail(formulario.email.value)==false){
			alert("El formato del e-mail no es v"+String.fromCharCode(225)+"lido.");
			return(false);
		}
		else{
		    if (formulario.edad.value < 18){
			    alert("Tienes que ser mayor de 18 a"+String.fromCharCode(241)+"os para poder inscribirte.");
			    return(false);		        
		    }
		    else{
		        if (nif(formulario.dni.value)==false){
			        alert("Introduce un DNI correcto.");
			        return(false);		        		        
		        }
		        else{
                    return(true);		        
		        }
			}
		}
	}
}

//Funcion para validar un dni
function nif(dni){
if (dni.length == 9){
      numero = dni.substr(0,dni.length-1);
      let = dni.substr(dni.length-1,1);
      numero = numero % 23;
      letra='TRWAGMYFPDXBNJZSQVHLCKET';
      letra=letra.substring(numero,numero+1);
      if (letra!=let) {
        return false;
      }else{
        return true;
      }
  }
  else{
    return false;
  }
}

// Funcion que valida un Email
function validarEmail(TMP){	
	var posicion;
	var mensaje;
	
	posicion=TMP.indexOf("@");
	switch (posicion)
	{
	case -1:
		return false;
	case 0:
		return false;
	case TMP.length-1:
		return false;
	default:
		TMP=TMP.substr(posicion+1);
		posicion=TMP.indexOf("@");
		if (posicion>-1)
		{
			return false;
		}
		posicion=TMP.indexOf(".");
		if (posicion==-1)
		{
			return false;
		}
		if (posicion==0)
		{
			return false;
		}
		while (posicion>-1)
		{				
			if (posicion==TMP.length-1)
			{
				return false;
			}
			TMP=TMP.substr(posicion+1);
			posicion=TMP.indexOf(".");
		}
	}
	return true;
}

// ----------------------------------------------------------------------------------
//Función que permite solo meter enteros en un INPUT
function esEntero(e){
	var charCode
	
	if (navigator.appName == "Netscape") // Veo si es Netscape o Explorer (mas adelante lo explicamos)
		charCode = e.which // leo la tecla que ingreso
	else
		charCode = e.keyCode // leo la tecla que ingreso
	status = charCode 
	if (charCode > 31 && (charCode < 48 || charCode > 57)) { // Chequeamos que sea un numero comparandolo con los valores ASCII
		return false
	}
return true
}