function usernamevalidation(entered, alertbox){
	if (emptyvalidation(entered,'El campo Usuario es obligatorio') == false){
		return false;
	}
	var boxValue=entered.value;				//Get what the user typed in
	var boxLength=boxValue.length;
	for (var i=0; i!=boxLength; i++){		//Loop through each character
		aChar=boxValue.substring(i,i+1)		//Identifiy where to start
		if (aChar == " "){					//Identify what is legal
			entered.Value="";
			if (alertbox!=""){
				alert('El campo Usuario no permite blancos.');
			}
			return false;
		}
	}
	return true;
}



function emailvalidation(entered, alertbox){
	if (entered.value==""){
		return true;
	}
	with (entered){
		apos=value.indexOf("@"); 
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos < 1 || dotpos-apos < 2 || lastpos-dotpos > 3 || lastpos-dotpos < 2){
			if (alertbox){
				alert(alertbox);
			}
			focus();
			return false;
		}
		else{
			return true;
		}
	} 
}

function emptyvalidation(entered, alertbox){
	with (entered){
		if (value==null || value==""){
			if (alertbox!=""){
				alert(alertbox);
			}
			focus();
			return false;
		}
		else{
			return true;
		}
	}
}

function isNum(idx,alertbox)
//Checks the specified field for numeric entry 
	{
	var boxValue=idx.value//Get what the user typed in
	var boxLength=boxValue.length
	for(var i=0; i!=boxLength; i++)//Loop through each character
		{
		aChar=boxValue.substring(i,i+1)//Identifiy where to start
		if(aChar < "0" || aChar > "9")//Identify what is legal
		{
		idx.Value="";
		if (alertbox!="")
		{
			alert(alertbox);
		}
		idx.focus();
		return false
		}
	}
	//If correct let it go
	return true
}

function isDec(idx,alertbox)
//Checks the specified field for numeric entry 
	{
	var j=0
	var boxValue=idx.value//Get what the user typed in
	var boxLength=boxValue.length
	for(var i=0; i!=boxLength; i++)//Loop through each character
		{
		aChar=boxValue.substring(i,i+1)//Identifiy where to start
		if(aChar < "0" || aChar > "9")//Identify what is legal
		{
			if(aChar==","){
				j++;
				if(j==2){
					idx.Value="";
					if (alertbox!=""){
						alert(alertbox);
					}
					idx.focus();
					return false
				}
			}
			else{
				idx.Value="";
				if (alertbox!=""){
					alert(alertbox);
				}
				idx.focus();
				return false
			}
		}
	}
	//If correct let it go
	return true
}

function ValFecha(obj, txt)
{
	anioAc = "<%=year(now)%>";
	diaAc = "<%=Day(now)%>";
	mesAc = "<%=Month(now)%>";
	if(mesAc.length < 2)
		mesAc = "0" + mesAc
	if(diaAc.length < 2)
		diaAc = "0" + diaAc

	Fecha = obj.value;		
	if (Fecha.length != 10){
		alert("La " + txt + " debe estar en formato dd/mm/aaaa");
		obj.value = "";
		obj.focus();
		return ""};
	dia = Fecha.substring(0,2);
	if (dia.length < 2){
		alert("La " + txt + " debe estar en formato dd/mm/aaaa");
		obj.value = "";
		obj.focus();
		return ""};
	if(!isFinite(dia)){
		alert("La " + txt + " debe estar en formato dd/mm/aaaa");
		obj.value = "";			
		obj.focus();
		return ""};
	if(dia > 31){
		alert("El día no puede ser mayor a 31");
		obj.value = "";		
		obj.focus();
		return ""};
	FechaAux = dia;		
	mes = Fecha.substring(3,5);
	if (mes.length < 2){
		alert("La " + txt + " debe estar en formato dd/mm/aaaa");
		obj.value = "";					
		obj.focus();
		return ""};
	if(!isFinite(mes)){
		alert("La " + txt + " debe estar en formato dd/mm/aaaa");
		obj.value = "";		
		obj.focus();
		return ""};
	if(mes > 12){
		alert("El mes no puede ser mayor a 12");
		obj.value = "";		
		obj.focus();
		return ""};
	FechaAux += "/" + mes;
	anio = Fecha.substring(6,10);		
	if (anio.length < 1){
		obj.focus();
		return ""
	};
	if(!isFinite(anio)){return ""};		
	FechaAux += "/" + anio;				
	//aca se podrian poner validaciones de diaMax con los mexes años bis etc ....
	//Provisorio 
	if (mes == 2 && dia > 29){
		alert("La " + txt + " fue ingresada en forma incorrecta");
		obj.value = "";		
		obj.focus();
		return ""};
		
	if ((mes == 4 || mes == 6 || mes == 9 || mes == 11) && dia > 30){
		alert("La " + txt + " fue ingresada en forma incorrecta");
		obj.value = "";		
		obj.focus();
		return ""};
	obj.value = FechaAux;
	return FechaAux;
}


function isDate(Dia,Mes,Ano){
	if (Mes==4 || Mes==6 || Mes==9 || Mes==11){
		if (Dia==31){
			return false;
		}
		else{
			return true;
		}
	}
	if (Mes==2 && Dia>29){
		return false;
	}
	else{
		if (Mes==2 && Dia==29){
			//veo si el año es viciesto
			if (Ano%4==0){
				if (Ano%2000==0){
					return true;
				}
				else{
					if (Ano%400!=0){
						return true;
					}
					else{
						return false;
					}
				}
			}
			else{
				return false;
			}
		}
		else{
			return true;
		}
	}
}