function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

// JavaScript Documentfunction mail(texto){ 
function mail(texto){ 

    var mailres = true;             
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-"; 
     
    var arroba = texto.indexOf("@",0); 
    if ((texto.lastIndexOf("@")) != arroba) arroba = -1; 
     
    var punto = texto.lastIndexOf("."); 
                 
     for (var contador = 0 ; contador < texto.length ; contador++){ 
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){ 
            mailres = false; 
            break; 
     } 
    } 

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1)) 
     mailres = true; 
    else 
     mailres = false; 
                 
    return mailres; 
} 

<!-- Comprobar si es vacío el valor de una caja de texto -->
function isEmpty(inputStr) {
	if (inputStr == "" || inputStr == null) {
		return true
	}
	return false
}
<!-- Comprobar si es una letra-->
function esLetra(n){
	if((n<"A")||(n>"Z")){
		if((n<"a")||(n>"z")){
			return false;
		}
	}
	return true;
}

<!-- Comprobar si es un numero-->
function esNumero(n){
	if((n<"0")||(n>"9")){
		return false;
	}
	return true;
}

//Formato Nif= 8numeros-letra
function nif(ele) {
	if ((ele.value=="") || (ele.value== null)) {
		//ele.focus();
		return false;
	}else{
		var longitud;
		var v=new Array;
		v=ele.value;
		longitud=v.length;

		if(longitud!=9){
			//ele.focus();
			return false;
		}else{
			var i;
			for(i=0;i<longitud-1;i++){
				if(!esNumero(v.charAt(i))){
					//ele.focus();
					return false;
				}
			 }//fin for
			//Comprobar la letra
			if(!esLetra(v.charAt(8))){
				//ele.focus();
				return false;
			}else{
				return true;
			}
		}
	}
}
//Formato Nif= letra-8numeros
function nifExt(ele) {
	if ((ele.value=="") || (ele.value== null)) {
		//ele.focus();
		return false;
	}else{
		var longitud;
		var v=new Array;
		v=ele.value;
		longitud=v.length;

		if(longitud!=9){
			//ele.focus();
			return false;
		}else{
			//Comprobar la letra
			if(!esLetra(v.charAt(0))){
				//ele.focus();
				return false;
			} else{
				var i;
				for(i=1;i<longitud;i++){
					if(!esNumero(v.charAt(i))){
						//ele.focus();
						return false;
					}
				 }//fin for
				 return true;
			}
		}
	}
}

//Formato nif= letra-7numeros-letra
function nifExtranjero(ele) {
	if ((ele.value=="") || (ele.value== null)) {
		//ele.focus();
		return false;
	} else{
		var longitud;
		v=ele.value;
		longitud=v.length;
	
		if(longitud!=9){
			//ele.focus();
			return false;
		}else{
			var i;
			//Comprobar la letra primera
			if(!esLetra(v.charAt(0))){
					//ele.focus();
					return false;
			}
			for(i=1;i<longitud-1;i++){
				if(!esNumero(v.charAt(i))){
					//ele.focus();
					return false;
				}
			}
			//Comprobar la letra ultima
			if(!esLetra(v.charAt(8))){
					//ele.focus();
					return false;
			}else{
				return true;
			}
		}
	}
}


//Formato Cif= letra-8numeros-letra
function cif(ele) {
	if ((ele.value=="") || (ele.value== null)) {
		ele.focus();
		return false;
	} else{
		var longitud;
		v=ele.value;
		longitud=v.length;
	
		if(longitud!=10){
			ele.focus();
			return false;
		}else{
			var i;
			//Comprobar la letra primera
			if(!esLetra(v.charAt(0))){
					ele.focus();
					return false;
			}
			for(i=1;i<longitud-1;i++){
				if(!esNumero(v.charAt(i))){
					ele.focus();
					return false;
				}
			}
			//Comprobar la letra ultima
			if(!esLetra(v.charAt(9))){
					ele.focus();
					return false;
			}else{
				return true;
			}
		}
	}
}

//Formato Cif= letra-8numeros
function cifEmpresa(ele) {
	if ((ele.value=="") || (ele.value== null)) {
		ele.focus();
		return false;
	}else{
		var longitud;
		var v=new Array;
		v=ele.value;
		longitud=v.length;

		if(longitud!=9){
			ele.focus();
			return false;
		}else{
			//Comprobar la letra
			if(!esLetra(v.charAt(0))){
				ele.focus();
				return false;
			} else{
				var i;
				for(i=1;i<longitud;i++){
					if(!esNumero(v.charAt(i))){
						ele.focus();
						return false;
					}
				 }//fin for
				 return true;
			}
		}
	}
}


//Formato cif= 9numeros
function cifPortugues(ele) {
	if ((ele.value=="") || (ele.value== null)) {
		ele.focus();
		return false;
	}else{
		var longitud;
		var v=new Array;
		v=ele.value;
		longitud=v.length;

		if(longitud!=9){
			ele.focus();
			return false;
		}else{
			var i;
			for(i=0;i<longitud;i++){
				if(!esNumero(v.charAt(i))){
					ele.focus();
					return false;
				}
			 }//fin for
			 return true;
		}
	}
}
//Comprobar formato de la fecha
function comprobarFecha(ele){
//alert("entra en comprobar fecha "+ele.value+" long="+ele.value.length);


	if (ele.value!="") {
		var i;
		var correcto=1;
		var longitud;
		var v=new Array;
		v=ele.value;
		longitud=v.length;
		
		if(longitud!=10){
			correcto=0;
		}else{
			if(!esNumerico(v.charAt(0))){
				correcto=0;
			}
			if(!esNumerico(v.charAt(1))){
				correcto=0;
			}
			if(v.charAt(2)!="-"){
				correcto=0;
			}
			if(!esNumerico(v.charAt(3))){
				correcto=0;
			}
			if(!esNumerico(v.charAt(4))){
				correcto=0;
			}
			if(v.charAt(5)!="-"){
				correcto=0;
			}

			for(i=6;i<longitud;i++){
				if(!esNumerico(v.charAt(i))){
				correcto=0;
				}
			}
		}
	
		if(correcto==0){
			alert("Fomato incorrecto de Fecha.\n Ejemplo: dd-mm-yyyy");
			ele.focus();
			ele.value="";
			return false;
		}else{
			var dia=v.substr(0,2);
			var mes=v.substr(3,2);
			var ano=v.substr(6,4);
			if(!isDate(dia,mes,ano)){
				alert("Fecha no válida.");
				ele.focus();
				ele.value="";
				return false;
				
			}else
				return true;
		}
	}
	return true;

}

//Comprobar formato de la fecha
function comprobarFechaHora(ele){
//alert("entra en comprobar fecha  y hora"+ele.value+" long="+ele.value.length);


	if (ele.value!="") {
		var i;
		var correcto=1;
		var longitud;
		var v=new Array;
		v=ele.value;
		longitud=v.length;
		
		if(longitud!=19){
			correcto=0;
		}else{
			if(!esNumerico(v.charAt(0))){
				correcto=0;
			}
			if(!esNumerico(v.charAt(1))){
				correcto=0;
			}
			if(v.charAt(2)!="-"){
				correcto=0;
			}
			if(!esNumerico(v.charAt(3))){
				correcto=0;
			}
			if(!esNumerico(v.charAt(4))){
				correcto=0;
			}
			if(v.charAt(5)!="-"){
				correcto=0;
			}

			for(i=6;i<10;i++){ //Anyo
				if(!esNumerico(v.charAt(i))){
				correcto=0;
				}
			}
			if(v.charAt(10)!=" "){
				correcto=0;
			}
			if(!esNumerico(v.charAt(11))){
				correcto=0;
			}
			if(!esNumerico(v.charAt(12))){
				correcto=0;
			}
			if(v.charAt(13)!=":"){
				correcto=0;
			}
			if(!esNumerico(v.charAt(14))){
				correcto=0;
			}
			if(!esNumerico(v.charAt(15))){
				correcto=0;
			}
			if(v.charAt(16)!=":"){
				correcto=0;
			}
			if(!esNumerico(v.charAt(17))){
				correcto=0;
			}
			if(!esNumerico(v.charAt(18))){
				correcto=0;
			}
			

		}
	
		if(correcto==0){
			alert("Fomato incorrecto de Fecha.\n Ejemplo: dd-mm-yyyy hh:mm:ss");
			ele.focus();
			ele.value="";
			return false;
		}else{
			var dia=v.substr(0,2);
			var mes=v.substr(3,2);
			var ano=v.substr(6,4);
			if(!isDate(dia,mes,ano)){
				alert("Fecha no válida.");
				ele.focus();
				ele.value="";
				return false;
				
			}
			var hora=v.substr(11,2);
			var minutos=v.substr(14,2);
			var segundos=v.substr(17,2);
			if(!isHora(hora,minutos,segundos)){
				alert("Hora no válida.");
				ele.focus();
				ele.value="";
				return false;
			}
			return true;				
			

			
		}
	}
	return true;

}

function comprobarHora(ele){
	var correcto=1;

	//alert("elemento="+ele.value);
	if (ele.value!="") {
			v=ele.value;
			if(!esNumerico(v.charAt(0))){
				correcto=0;
			}
			if(!esNumerico(v.charAt(1))){
				correcto=0;
			}
			if(v.charAt(2)!=":"){
				correcto=0;
			}
			if(!esNumerico(v.charAt(3))){
				correcto=0;
			}
			if(!esNumerico(v.charAt(4))){
				correcto=0;
			}
			
			if(correcto==0){//FORMATO INCORRECTO
				alert("Fomato incorrecto de Hora.\n Ejemplo: hh:mm . \n\n");
				ele.focus();
				ele.value="";
				return false;
			}else{
				var hora=v.substr(0,2);
				var minutos=v.substr(3,2);
				
				if(!isHoraMin(hora,minutos)){
					alert("Hora no válida.\n\n");
					ele.focus();
					ele.value="";
					return false;
				}
				return true;				
				
			}
	}
	return true;
}

//Es un numero
function esNumerico(strInput) {
	//var valor=strInput.value;
	var valor=strInput;
	if (valor != '') {
		if (!valor.match(/[^0-9]/)) {
			return true;
		}else{
			//alert("Este campo es númerico. Introduzca solo números.");
			//strInput.value="";
			//strInput.focus();
			return false;
		}
	}
	return false;
}
function y2k(number) { return (number < 1000) ? number + 1900 : number; }

function isHora (hora,minutos,segundos) {
	//alert("Hora="+hora+" Minutos="+minutos+" segundos="+segundos);
	if(hora>23 || hora<0){
		return false;
	}
	if (minutos>60 || minutos<0){
		return false;
	}
	if (segundos>60 || segundos<0){
		return false;
	}
	return true;
	
}
function isHoraMin (hora,minutos) {
	//alert("Hora="+hora+" Minutos="+minutos+" segundos="+segundos);
	if(hora>23 || hora<0){
		return false;
	}
	if (minutos>60 || minutos<0){
		return false;
	}
	return true;
	
}
function isDate (day,month,year) {
// checks if date passed is valid
// will accept dates in following format:
// isDate(dd,mm,ccyy), or
// isDate(dd,mm) - which defaults to the current year, or
// isDate(dd) - which defaults to the current month and year.
// Note, if passed the month must be between 1 and 12, and the
// year in ccyy format.

    var today = new Date();
    year = ((!year) ? y2k(today.getYear()):year);
    month = ((!month) ? today.getMonth():month-1);
    if (!day) return false
    var test = new Date(year,month,day);
    if ( (y2k(test.getYear()) == year) &&
         (month == test.getMonth()) &&
         (day == test.getDate()) )
        return true;
    else
        return false
}
//No escribe salvo que sean numeros
function CP_onkeypress(){
	var LnKeyCode = window.event.keyCode;
	if (!(LnKeyCode >=48 & LnKeyCode <=57)) window.event.keyCode = 0;
		return true;
}
//No escribe salvo que sean numeros y coma
function CP_onkeypressComa(){
	var LnKeyCode = window.event.keyCode;
	//alert("codigo="+LnKeyCode);
	
	if (!(LnKeyCode >=48 & LnKeyCode <=57)) window.event.keyCode = 0;
	if(LnKeyCode==44) window.event.keyCode=44;
	
		return true;
}

//No escribe salvo que sean numeros
function CP_onkeypressDecimal(){
	var LnKeyCode = window.event.keyCode;
	//alert("codigo="+LnKeyCode);
	if (!(LnKeyCode >=48 & LnKeyCode <=57)) window.event.keyCode = 0;
	if(LnKeyCode==46) window.event.keyCode=46;
		return true;
}


function comprobarPassword(){
	var error_message = "";
	var error=false;

		if (isEmpty(document.forms[0].textlogin.value)){
			error_message = error_message + "* Por favor, intuduzca el login de acceso para el Empleado.\n\n";
			error=true;
		
		}
		password=document.forms[0].textpassword.value;
		password_confirmacion=document.forms[0].password_confirmacion.value;
	
		if (isEmpty(password)){
			error_message = error_message + "* Por favor, intuduzca el password de acceso para el Empleado.\n\n";
			error=true;
		
		}else if(password != password_confirmacion){
			error_message = error_message + "* Por favor, el password y la confirmación de password no coinciden.\n\n";
			error=true;
		}else if(password.length<4 ){
			error_message = error_message + "* Por favor, el password debe tener una longitud igual o superior a 4.\n\n";
			error=true;
		}

	if (error == true) {
    	alert(error_message);
	    return false;
	}
	return true;
}

/* fi tiene que ser menor que ff */
function comparar_fechas(fi,ff){

/*var dia1 =fi.substring(0,2);
var mes1 =fi.substring(3,5);
var anio1=fi.substring(6,10);

var dia2 =ff.substring(0,2);
var mes2 =ff.substring(3,5);
var anio2=ff.substring(6,10);

dia1 = parseInt(dia1,10);
mes1 = parseInt(mes1,10);
anio1= parseInt(anio1,10);

dia2 = parseInt(dia2,10);
mes2 = parseInt(mes2,10);
anio2= parseInt(anio2,10); 

/*iniciamos comparando los años*/

/*if (anio1<anio2){
	return true;
} */
/*Ahora se comparan los meses*/
/*if ((anio1<=anio2) && (mes1<=mes2)){
	return true;
} */
/*Ahora se comparan los dias*/
/*if ((anio1<=anio2) && (mes1<=mes2) && (dia1<=dia2)){
	return true;
} 
	return false; */
	
Data1_arr = fi.split('-')
Data2_arr = ff.split('-')

String1 = Data1_arr[2] + Data1_arr[1] + Data1_arr[0] 
String2 = Data2_arr[2] + Data2_arr[1] + Data2_arr[0]
String1 = parseInt(String1);
String2 = parseInt(String2);
//alert("String1="+String1+" String2="+String2);
//if (String1 >= String2) {
if (String1 > String2) {
return true;
}
return false;
	
}