function isMail(Cadena) {

        Punto = Cadena.substring(Cadena.lastIndexOf('.') + 1, Cadena.length)                        // Cadena del .com
        Dominio = Cadena.substring(Cadena.lastIndexOf('@') + 1, Cadena.lastIndexOf('.'))         // Dominio @lala.com
        Usuario = Cadena.substring(0, Cadena.lastIndexOf('@'))                                        // Cadena lalala@
        Reserv = "@/º\"\'+*{}\\<>?¿[]áéíóú#·¡!^*;,:"                                                // Letras Reservadas

        // Añadida por El Codigo para poder emitir un alert en funcion de si email valido o no
        valido = true

        // verifica qie el Usuario no tenga un caracter especial
        for (var Cont=0; Cont<Usuario.length; Cont++) {
                X = Usuario.substring(Cont,Cont+1)
                if (Reserv.indexOf(X)!=-1)
                        valido = false
        }

        // verifica qie el Punto no tenga un caracter especial
        for (var Cont=0; Cont<Punto.length; Cont++) {
                X=Punto.substring(Cont,Cont+1)
                if (Reserv.indexOf(X)!=-1)
                        valido = false
        }

        // verifica qie el Dominio no tenga un caracter especial
        for (var Cont=0; Cont<Dominio.length; Cont++) {
                X=Dominio.substring(Cont,Cont+1)
                if (Reserv.indexOf(X)!=-1)
                        valido = false
                }

        // Verifica la sintaxis básica.....
        if (Punto.length<2 || Dominio <1 || Cadena.lastIndexOf('.')<0 || Cadena.lastIndexOf('@')<0 || Usuario<1) {
                valido = false
        }

        return valido;
};

function validDate(Cadena) {
        Dia = Cadena.substring(0, 2);      // dos digitos y menos que 31
		Resto = Cadena.substring(3, Cadena.length);
        Mes = Resto.substring(0, 2)         // dos digitos y menor que 12
		Anio = Resto.substring(3, Resto.length);					// 4 digitos

        Numeros = "0123456789" // Numeros!

        valido = true;
		
        // verifica qie el Dia solo tenga numeros
        for (var Cont=0; Cont<Dia.length; Cont++) {
                X=Dia.substring(Cont,Cont+1)
                if (Numeros.indexOf(X)==-1)
                        valido = false
        }
        if (Dia.length!=2 || parseInt(Dia)>31 || parseInt(Dia)<0) {
			valido = false;
		};
        // verifica qie el Mes solo tenga numeros
        for (var Cont=0; Cont<Mes.length; Cont++) {
                X=Mes.substring(Cont,Cont+1)
                if (Numeros.indexOf(X)==-1)
                        valido = false
        }
        if (Mes.length!=2 || parseInt(Mes)>12 || parseInt(Mes)<0) {
			valido = false;
		};
        // verifica qie el Anio solo tenga numeros
        for (var Cont=0; Cont<Anio.length; Cont++) {
                X=Anio.substring(Cont,Cont+1)
                if (Numeros.indexOf(X)==-1)
                        valido = false
        }
        if (Anio.length!=4) {
			valido = false;
		};
		return valido;
}

function validTime(Cadena) {
        Hora = Cadena.substring(0, 2);      // dos digitos y menor que 24
		Resto = Cadena.substring(3, Cadena.length);
        Minutos = Resto.substring(0, 2)         // dos digitos y menor que 60

        Numeros = "0123456789" // Numeros!

        valido = true;
		
        // verifica que la Hora solo tenga numeros
        for (var Cont=0; Cont<Hora.length; Cont++) {
                X=Hora.substring(Cont,Cont+1)
                if (Numeros.indexOf(X)==-1)
                        valido = false
        }
        if (Hora.length!=2 || parseInt(Hora)>23 || parseInt(Hora)<0) {
			valido = false;
		};
        // verifica que los Minutos solo tenga numeros
        for (var Cont=0; Cont<Minutos.length; Cont++) {
                X=Minutos.substring(Cont,Cont+1)
                if (Numeros.indexOf(X)==-1)
                        valido = false
        }
        if (Minutos.length!=2 || parseInt(Minutos)>60 || parseInt(Minutos)<0) {
			valido = false;
		};
		return valido;
}

function chequear(form) {
        if((form.Fecha.value) && (!validDate(form.Fecha.value))) {
                alert ("El formato de la fecha debe ser: DD/MM/YYYY");
                form.Fecha.focus();
                return;
		}

   form.submit();
}

function send_save(form, url) {
	form.volver.value = url;
	form.submit();
}

function PopUp(theURL, winName, features, width, height) { 
	if(window.screen){
		var myLeft = (screen.width-width)/2;
		var myTop = (screen.height-(height+50))/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop+',width='+width+',height='+height;
	}
	window.open(theURL,winName,features);
}

function PopUpF(theURL, winName, width, height) { 
	if(window.screen){
		var myLeft = (screen.width-width)/2;
		var myTop = (screen.height-(height+50))/2;
		features='status=0, menubar=0, toolbar=0, resizable=0, scrollbars=1, titlebar=0, status=0'
		features+=',left='+myLeft+',top='+myTop+',width='+width+',height='+height;
	}
	window.open(theURL,winName,features);
}

function PopUp1(theURL, winName, width, height) { 
	if(window.screen){
		var myLeft = (screen.width-width)/2;
		var myTop = (screen.height-(height+50))/2;
		features='status=0, menubar=0, toolbar=0, resizable=0, scrollbars=0, titlebar=0, status=0'
		features+=',left='+myLeft+',top='+myTop+',width='+width+',height='+height;
	}
	window.open(theURL,winName,features);
}
function mostrar(nombreCapa){
	document.getElementById(nombreCapa).style.visibility="visible";
	document.getElementById("btn_i").src="../includes/images/right.png";
	document.getElementById("btn_h").href = "JavaScript:ocultar('"+nombreCapa+"')";
}

function ocultar(nombreCapa){
	document.getElementById(nombreCapa).style.visibility="hidden";
	document.getElementById("btn_i").src="../includes/images/down.png";
	document.getElementById("btn_h").href = "JavaScript:mostrar('"+nombreCapa+"')";
} 

var nav4 = window.Event ? true : false;
function aceptaNum(evt){
	// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
	var key = nav4 ? evt.which : evt.keyCode;
	if (key <= 13 || (key >= 48 && key <= 57)) {
		return true;
	};
	alert("ATENCIÓN: Este campo solo admite números!");
	return false;
};

function borrar_foto(url) {
	if (confirm('Esta seguro que desea borrar la foto?')) {
		window.location = url;
	}
}

function mostrar_desc(texto) {
	document.getElementById("Pizarra").value = texto;
}

function limpiar_desc() {
	document.getElementById("Pizarra").value = "";
}

function acomodar() {
	window.moveTo((window.opener.screen.availWidth-document.all.imagen.width)/2,(window.opener.screen.availHeight-document.all.imagen.height)/2);
	self.window.resizeTo(document.all.imagen.width+30, document.all.imagen.height+100);
			
}
