/*VALIDACION FORMULARIOS
AUTOR: MAURICIO JIMENEZ
CREO: MAURICIO JIMENEZ
FECHA: 28 AGOSTO 2003*/

function CheckForm(form)
{
	

	var i;
	var arr;
	var str;
	var x;
	var nameElement;
	var obj;

	
	for (i=0;i<form.elements.length;i++)
	{
		if (!form.elements[i].disabled)
			if(form.elements[i].name.substr(0,4) == "CHK_")
			{
				str = GetFieldValueByName(form,form.elements[i].name.substr(4));
				nameElement = form.elements[i].name.substr(4,form.elements[i].name.length);
				obj = GetElementByName(form,nameElement);				
				if(str != null && obj.style.visibility != "hidden")
				{	
					arr = form.elements[i].value.split("|");
					switch(arr[0])
					{
						case "STR":
							//check mandatory field
							if ((str.length == 0) && (arr[3] == "True"))
							{
								alert("Debe Ingresar -> " + arr[4]);								
								obj.focus();
								return false;
							}
							
							if (Trim(str).length == 0 && (arr[3] == "True"))
							{
								alert("No se aceptan espacios -> " + arr[4]);								
								obj.focus();
								return false;
							}
								
							//check min length
							if (str.length < parseInt(arr[1]) && arr[3] == "True")
							{
								alert("El número de dígitos o caracteres en: >" + arr[4] + "< debe ser mínimo de " + arr[1]);
								obj.focus();
								return false;
							}

							//check max length
							if (str.length > parseInt(arr[2]) && arr[3] == "True")
							{
								alert("El valor en el campo >" + arr[4] + "< contiene más de los caractéres permitidos: " + arr[2]);								
								obj.focus();
								return false;
							}
							
							//check AlphaNumeric
							if (!IsAlphaNumeric(str))							
							{
								alert("El campo -> " + arr[4] + "\nDebe tener solamente caracteres Alfabéticos, Numéricos y Espacios");								
								obj.focus();
								return false;
							}
							
							//Validar si tiene información y no cumple
							if (str.length > 0 && str.length < parseInt(arr[1]) && arr[3] == "False")
							{
								alert("El valor en el campo >" + arr[4] + "< contiene más de los caractéres permitidos: " + arr[2]);								
								obj.focus();
								return false;
							}
							
							if (str.length = 0 && str.length < parseInt(arr[1]) && arr[3] == "False")
							{
								alert("El número de dígitos o caracteres en: >" + arr[4] + "< debe ser mínimo de " + arr[1]);
								obj.focus();
								return false;
							}
							break;
					case "STRS":
							//check mandatory field
							if ((str.length == 0) && (arr[3] == "True"))
							{
								alert("Debe Seleccionar -> " + arr[4]);								
								obj.focus();
								return false;
							}
							
							if (Trim(str).length == 0 && (arr[3] == "True"))
							{
								alert("No se aceptan espacios -> " + arr[4]);								
								obj.focus();
								return false;
							}
								
							//check min length
							if (str.length < parseInt(arr[1]) && arr[3] == "True")
							{
								alert("Debe Seleccionar -> " + arr[4]);								
								obj.focus();
								return false;
							}

							//check max length
							if (str.length > parseInt(arr[2]) && arr[3] == "True")
							{
								alert("El valor en el campo >" + arr[4] + "< contiene más de los caractéres permitidos: " + arr[2]);								
								obj.focus();
								return false;
							}
							
							//check AlphaNumeric
							if (!IsAlphaNumeric(str))							
							{
								alert("Debe Seleccionar -> " + arr[4]);								
								obj.focus();
								return false;
							}
							
							//Validar si tiene información y no cumple
							if (str.length > 0 && str.length < parseInt(arr[1]) && arr[3] == "False")
							{
								alert("El valor en el campo >" + arr[4] + "< contiene más de los caractéres permitidos: " + arr[2]);								
								obj.focus();
								return false;
							}
							
							if (str.length = 0 && str.length < parseInt(arr[1]) && arr[3] == "False")
							{
								alert("El número de dígitos o caracteres en: >" + arr[4] + "< debe ser mínimo de " + arr[1]);
								obj.focus();
								return false;
							}
							break;		
							
					case "DIR":
							//check mandatory field
							if ((str.length == 0) && (arr[3] == "True"))
							{
								alert("Debe Ingresar -> " + arr[4]);								
								obj.focus();
								return false;
							}
							
							if (Trim(str).length == 0 && (arr[3] == "True"))
							{
								alert("No se aceptan espacios -> " + arr[4]);								
								obj.focus();
								return false;
							}
								
							//check min length
							if (str.length < parseInt(arr[1]) && arr[3] == "True")
							{
								alert("El número de dígitos o caracteres en: >" + arr[4] + "< debe ser mínimo de " + arr[1]);
								obj.focus();
								return false;
							}

							//check max length
							if (str.length > parseInt(arr[2]) && arr[3] == "True")
							{
								alert("El valor en el campo >" + arr[4] + "< contiene más de los caractéres permitidos: " + arr[2]);								
								obj.focus();
								return false;
							}
							
							//check AlphaNumeric
							if (!IsDirec(str))							
							{
								alert("El campo -> " + arr[4] + "\nDebe tener solamente caracteres Alfabéticos, Numéricos y Espacios");								
								obj.focus();
								return false;
							}
							
							//Validar si tiene información y no cumple
							if (str.length > 0 && str.length < parseInt(arr[1]) && arr[3] == "False")
							{
								alert("El valor en el campo >" + arr[4] + "< contiene más de los caractéres permitidos: " + arr[2]);								
								obj.focus();
								return false;
							}
							
							if (str.length = 0 && str.length < parseInt(arr[1]) && arr[3] == "False")
							{
								alert("El número de dígitos o caracteres en: >" + arr[4] + "< debe ser mínimo de " + arr[1]);
								obj.focus();
								return false;
							}
							break;
					case "Tel":
							//check mandatory field
							if ((str.length == 0) && (arr[3] == "True"))
							{
								alert("Debe Ingresar -> " + arr[4]);								
								obj.focus();
								return false;
							}
							
							if (Trim(str).length == 0 && (arr[3] == "True"))
							{
								alert("No se aceptan espacios -> " + arr[4]);								
								obj.focus();
								return false;
							}
								
							//check min length
							if (str.length < parseInt(arr[1]) && arr[3] == "True")
							{
								alert("El número de dígitos o caracteres en: >" + arr[4] + "< debe ser mínimo de " + arr[1]);
								obj.focus();
								return false;
							}

							//check max length
							if (str.length > parseInt(arr[2]) && arr[3] == "True")
							{
								alert("El valor en el campo >" + arr[4] + "< contiene más de los caractéres permitidos: " + arr[2]);								
								obj.focus();
								return false;
							}
							
							//check AlphaNumeric
							if (!IsTel(str))							
							{
								alert("El campo -> " + arr[4] + "\nDebe tener solamente caracteres Alfabéticos, Numéricos y Espacios");								
								obj.focus();
								return false;
							}
							
							//Validar si tiene información y no cumple
							if (str.length > 0 && str.length < parseInt(arr[1]) && arr[3] == "False")
							{
								alert("El valor en el campo >" + arr[4] + "< contiene más de los caractéres permitidos: " + arr[2]);								
								obj.focus();
								return false;
							}
							
							if (str.length = 0 && str.length < parseInt(arr[1]) && arr[3] == "False")
							{
								alert("El número de dígitos o caracteres en: >" + arr[4] + "< debe ser mínimo de " + arr[1]);
								obj.focus();
								return false;
							}
							break;
								
						case "RAD":
							
							//check mandatory field
							
							if ((Trim(str).length == 0)  && (arr[3] == "True"))
							{
								alert("Debe Ingresar -> " + arr[4]);								
								return false;
							}
							break;
							
							
						case "ALPHA":
							//check mandatory field
							if ((str.length == 0) && (arr[3] == "True"))
							{
								alert("Debe Ingresar -> " + arr[4]);								
								obj.focus();
								return false;
							}
							
							if (Trim(str).length == 0 && (arr[3] == "True"))
							{
								alert("No se aceptan espacios -> " + arr[4]);								
								obj.focus();
								return false;
							}
								
							//check min length
							if (str.length < parseInt(arr[1]) && arr[3] == "True")
							{
								alert("El número de dígitos o caracteres en: >" + arr[4] + "< debe ser mínimo de " + arr[1]);
								obj.focus();
								return false;
							}

							//check max length
							if (str.length > parseInt(arr[2]) && arr[3] == "True")
							{
								alert("El valor en el campo >" + arr[4] + "< contiene más de los caractéres permitidos: " + arr[2]);								
								obj.focus();
								return false;
							}
							
							//check Alphabetic
							if (!IsAlpha(str))							
							{
								alert("El campo -> " + arr[4] + "\nDebe tener solamente caracteres Alfabéticos y Espacios");								
								obj.focus();
								return false;
							}
							
							//Validar si tiene información y no cumple
							if (str.length > 0 && str.length < parseInt(arr[1]) && arr[3] == "False")
							{
								alert("El valor en el campo >" + arr[4] + "< contiene más de los caractéres permitidos: " + arr[2]);								
								obj.focus();
								return false;
							}
							
							if (str.length = 0 && str.length < parseInt(arr[1]) && arr[3] == "False")
							{
								alert("El número de dígitos o caracteres en: >" + arr[4] + "< debe ser mínimo de " + arr[1]);
								obj.focus();
								return false;
							}
							break;
							
						case "ALFANUMERICTRIM":
						
							//check mandatory field
							if ((str.length == 0) && (arr[3] == "True"))
							{
								alert("Debe Ingresar -> " + arr[4]);								
								obj.focus();
								return false;
							}
						
							//check min length
							if (str.length < parseInt(arr[1]) && (arr[3] == "True"))
							{
								alert("El número de dígitos o caracteres en: >" + arr[4] + "< debe ser mínimo de " + arr[1]);								
								obj.focus();
								return false;
							}

							//check max length
							if (str.length > parseInt(arr[2]) && (arr[3] == "True"))
							{
								alert("El valor en el campo >" + arr[4] + "< contiene más de los caractéres permitidos: " + arr[2]);					
								obj.focus();
								return false;
							}
						
							//check AlphaNumeric
							if (!IsAlphaNumeric(str))							
							{
								alert("El campo -> " + arr[4] + "\nDebe tener solamente caracteres Alfabéticos y números");					
								obj.focus();
								return false;
							}
						
							if (IsSpace(str))
							{
								alert("El valor en el campo >" + arr[4] + "< no debe contener espacios");
								obj.focus();
								return false;	
							}	
							break;
							
						case "INT":

							//check mandatory field
							if ((str.length == 0) && (arr[3] == "True"))
							{
								alert("Debe Ingresar -> " + arr[4]);
								obj.focus();
								return false;
							}

							//check sanity
							if(!(IsNumeric(str)))
							{
								alert("El valor en el campo >" + arr[4] + "< debe ser numérico entero");								
								obj.focus();
								return false;
							}			
							
							if (parseInt(str) < parseInt(arr[1]))
							{
								alert("El Valor en el Campo >" + arr[4] + "< es muy pequeño");								
								obj.focus();
								return false;
							}
							
							//Chequear Limite Superior
							if (parseInt(str) > parseInt(arr[2]))
							{
								alert("El valor Máximo en el campo >" + arr[4] + "< es " + parseInt(arr[2]));								
								obj.focus();
								return false;
							}
													
							//chequer que sea positivo
							if (str < 0)
							{
								alert("El valor en el campo >" + arr[4] + "< debe ser positivo");								
								obj.focus();
								return false;							
							}
								
							break;
						case "INTS":

							//check mandatory field
							if ((str.length == 0) && (arr[3] == "True"))
							{
								alert("Debe Seleccionar -> " + arr[4]);
								obj.focus();
								return false;
							}

							//check sanity
							if(!(IsNumeric(str)))
							{
								alert("Debe Seleccionar -> " + arr[4]);								
								obj.focus();
								return false;
							}			
							
							if (parseInt(str) < parseInt(arr[1]))
							{
								alert("Debe Seleccionar -> " + arr[4]);								
								obj.focus();
								return false;
							}
							
							//Chequear Limite Superior
							if (parseInt(str) > parseInt(arr[2]))
							{
								alert("Debe Seleccionar -> " + arr[4]);								
								obj.focus();
								return false;
							}
													
							//chequer que sea positivo
							if (str < 0)
							{
								alert("Debe Seleccionar -> " + arr[4]);								
								obj.focus();
								return false;							
							}
								
						break;	
						case "FLOAT":
																				
							//check mandatory field
							if ((str.length == 0) && (arr[3] == "True"))
							{
								alert("El valor en el campo >" + arr[4] + "< debe ser Ingresado");
								obj.focus();
								return false;
							}
								
							//check sanity
							if(!(IsFloat(str)))
							{
								alert("El valor en el campo >" + arr[4] + "< debe ser Numérico");								
								obj.focus();
								return false;
							}
														
							//check min value
							if (arr[1] != "x")
							{
								if (parseFloat(str) < parseFloat(arr[1]))
								{
									alert("El valor en el campo >" + arr[4] + "< es muy pequeño");									
									obj.focus();
									return false;
								}
							}
								
							//check max length
							if (arr[2] != "x")
							{
								if (parseFloat(str) > parseFloat(arr[2]))
								{
									alert("El valor en el campo >" + arr[4] + "< es muy Grande");									
									obj.focus();
									return false;
								}
							}
								
							break;
					
						case "DATE":
													
							//check mandatory field
							if ((str.length == 0) && (arr[3] == "True"))
							{
								alert("The field >" + arr[4] + "< must be filled in");
								obj.focus();
								return false;
							}
								
							//check sanity
							if(!(IsDate(str)))
							{
								alert("The value in field >" + arr[4] + "< is not a valid date (MM/DD/YYYY)");
								obj.focus();
								return false;
							}
								
							//check min value
							if (arr[1] != "x")
							{
								if (GetDate(str) < GetDate(arr[1]))
								{
									alert("The date in field >" + arr[4] + "< is less than the minimum date");
									obj.focus();
									return false;
								}
							}
								
							//check max length
							if (arr[2] != "x")
							{
								if (GetDate(str) > GetDate(arr[2]))
								{
									alert("The value in field >" + arr[4] + "< is later than the maximum date");
									obj.focus();
									return false;
								}
							}
						
							break;
							
						case "DATECBO":						
							if (form.dpwYear.value == "-1" ||
								form.dpwMonth.value == "-1" ||
								form.dpwDay.value == "-1")
								{
									alert("Debe Ingresar -> " + arr[4]);
									form.dpwYear.focus();
									return false;
								}
						break;

						case "CBO":

							//check value
							if (((str == "-1") || (str == "")) && arr[3] == "True")
							{
								alert("Debe Seleccionar -> " + arr[4]);								
								obj.focus();
								return false;
							}
						break;
						
						case "LSTM":

							//check value
							if ((str == "-1") || (str == "0") || (str == ""))
							{
								alert("Debe Seleccionar por lo menos un valor en -> " + arr[4]);
								obj.focus();
								return false;
							}
						break;
							
						case "HTM":						
							if ((str.length == 11) && (arr[3] == "True"))
							{
								alert("Debe Ingresar -> " + arr[4]);							
								return false;
							}
						break;
								
						case "BOL":
						    if(obj.value=="0")
							{
						    alert("Debe Ingresar :" + arr[4]);							
							obj.focus();
							return false;
							}
							/*if(obj.value=="")
							{
                               alert("Debe elegir el calendario 2");
                               obj.focus();
                               return false;
			                }	*/
							
						break;
						
						case "EMAIL":
						{
							//check mandatory field
							if ((str.length == 0) && (arr[3] == "True"))
							{
								alert("Debe Ingresar una Dirección de Email válida -> " + arr[4]);
									obj.focus();
									return false;
							}
							
							if ((str.length > 0) && (arr[3] == "True"))
								if (!IsEmail(str))
								{
									alert("Debe Ingresar una Dirección de Email válida -> " + arr[4]);
										obj.focus();
										return false;
								}
							
							if ((str.length > 0) && (arr[3] == "false"))
							{
								if (!IsEmail(str))
								{
									alert("Debe Ingresar una Dirección de Email válida -> " + arr[4]);
									obj.focus();
									return false;
								}
							}
												
						}
						break;
						
						
					}
				}
			}
			
		}
		

	return true;

}

//============================================================================================
function Replace(string,replacechar,replacewith) 
{
	var temp = "";
	var i;
		
	string = '' + string;
	splitstring = string.split(replacechar);
	for(i = 0; i < splitstring.length; i++)
	{
		if(i < (splitstring.length -1))
			temp += splitstring[i] + replacewith;
		else
			temp += splitstring[i];
	}
	return temp;
}

//============================================================================================

function GetFieldValueByName(form,name)
{
	var i;
		
	for (i=0;i<form.elements.length;i++)
	{
		if(form.elements[i].name == name)
			return (form.elements[i].value);
	}
	return null;
}

/*
	function: GetElementByName
	proposito:	Recuperar la referencia a un control
				enviando el Nombre
	

*/

function GetElementByName(form,name)
{
	var i;
		
	for (i=0;i<form.elements.length;i++)
	{
		if(form.elements[i].name == name)
			return (form.elements[i]);
	}
	return null;
}

/*
======================= STANDARD HELPER FUNCTIONS BELOW =======================================
*/

function IsNumeric(str)
{
	var i;
	for(i=0;i<str.length;i++)
	{
		
		if(str.charAt(i) == ' ' || 
			str.charAt(i) == '.' || 
			str.charAt(i) == '-' ||
			!(str.charAt(i) >= '0' && str.charAt(i) <= '9'))
			return false;
	}	

	return true;
}

function IsFloat(str)	
{
	var i;
	for(i=0;i<str.length;i++)
	{
		if(str.charAt(i) == ' ' || 
			str.charAt(i) == ',' || 
			str.charAt(i) == '-' ||
			(!(str.charAt(i) >= '0' && str.charAt(i) <= '9') && str.charAt(i) != '.'))
			return false;
	}	
	return true;
}


//============================================================================================
function IsAlphaNumeric(str)
{
	var i;
	for(i=0;i<str.length;i++)
	{
	
		if(!(	((str.charAt(i) <= '9') && (str.charAt(i) >= '0')) ||
				((str.charAt(i) <= 'z') && (str.charAt(i) >= 'a')) ||
				((str.charAt(i) <= 'Z') && (str.charAt(i) >= 'A')) ||				
				(str.charAt(i) == 'á') || (str.charAt(i) == 'é') ||				
				(str.charAt(i) == 'í') || (str.charAt(i) == 'ó') ||
				(str.charAt(i) == 'ñ') || (str.charAt(i) == 'Ñ') ||
				(str.charAt(i) == 'ú') || (str.charAt(i) == ' ')))
				
			return(false);
	}
	return(true);
}

//============================================================================================


function IsDirec(str)
{
	var i;
	for(i=0;i<str.length;i++)
	{
	
		if(!(	((str.charAt(i) <= '9') && (str.charAt(i) >= '0')) ||
				((str.charAt(i) <= 'z') && (str.charAt(i) >= 'a')) ||
				((str.charAt(i) <= 'Z') && (str.charAt(i) >= 'A')) ||				
				(str.charAt(i) == 'á') || (str.charAt(i) == 'é') ||				
				(str.charAt(i) == 'í') || (str.charAt(i) == 'ó') ||
				(str.charAt(i) == 'ñ') || (str.charAt(i) == 'Ñ') ||
				(str.charAt(i) == '-') || (str.charAt(i) == '#') ||
				(str.charAt(i) == '.') || (str.charAt(i) == '·') ||
				(str.charAt(i) == '/') || (str.charAt(i) == '|') ||
				(str.charAt(i) == 'ª') || (str.charAt(i) == 'º') ||
				(str.charAt(i) == 'ú') || (str.charAt(i) == ' ')))
				
			return(false);
	}
	return(true);
}

//============================================================================================

function IsTel(str)
{
	var i;
	for(i=0;i<str.length;i++)
	{
	
		if(!(	((str.charAt(i) <= '9') && (str.charAt(i) >= '0')) ||
				((str.charAt(i) <= 'z') && (str.charAt(i) >= 'a')) ||
				((str.charAt(i) <= 'Z') && (str.charAt(i) >= 'A')) ||				
				(str.charAt(i) == 'á') || (str.charAt(i) == 'é') ||				
				(str.charAt(i) == 'í') || (str.charAt(i) == 'ó') ||
				(str.charAt(i) == '(') || (str.charAt(i) == ')') ||
				(str.charAt(i) == '-') || (str.charAt(i) == '#') ||
				(str.charAt(i) == '.') || (str.charAt(i) == '·') ||
				(str.charAt(i) == 'ª') || (str.charAt(i) == '*') ||
				(str.charAt(i) == 'ú') || (str.charAt(i) == ' ')))
				
			return(false);
	}
	return(true);
}

//============================================================================================



function IsAlpha(str)
{
	var i;
		
	for(i=0;i<str.length;i++)
	{
		if(!(	((str.charAt(i) <= 'z') && (str.charAt(i) >= 'a')) ||
				(str.charAt(i) == ' ') || (str.charAt(i) == 'á') ||
				(str.charAt(i) == 'é') || (str.charAt(i) == 'í') ||
				(str.charAt(i) == 'ó') || (str.charAt(i) == 'ú') ||
				(str.charAt(i) == 'ñ') || (str.charAt(i) == 'Ñ') ||
				(str.charAt(i) == 'é') || (str.charAt(i) == 'ß') ||
				
				((str.charAt(i) <= 'Z') && (str.charAt(i) >= 'A')) ))
			return(false);
	}
	return(true);
}


//============================================================================================


function Trim(valChar)
{
	//trim leding spaces
	while(true)
	{
		if(valChar.charAt(0) == ' ')
			valChar = valChar.substr(1);
		else
			break;
	}
		
	//trim trailing spaces
	while(true)
	{
		if(valChar.charAt(valChar.length-1) == ' ')
			valChar = valChar.substr(0,valChar.length-1);
		else
			break;
	}
	return(valChar);	
}

//============================================================================================

function IsDate(argDate)
{
	var date_split;
	var i;
	var tdate, tmonth, tyear;
		
	date_split = argDate.split('/');
		
	//check for date parts
	if(date_split.length != 3)
		return(false);
			
	//check for zero values
	for(i=0;i<date_split.length;i++)
	{
		if(parseInt(date_split[i]) == 0)
			return(false);
	}
		
	//check for 4-digit year
	if(date_split[2].length != 4)
		return(false);
			
	//check for valid date, e.g. 02/29/1997
	tdate = parseInt(date_split[1]);
	tmonth = parseInt(date_split[0]);
	tyear = parseInt(date_split[2]);
		
	var date = new Date(parseInt(date_split[2]),parseInt(date_split[0])-1,parseInt(date_split[1]));
		
	if(date.getDate() != tdate)
		return(false);
		
	if(date.getMonth() != (tmonth-1))
		return(false);
		
	if(date.getFullYear() != tyear)
		return(false);
			
	return(true);
}


function GetDate(argDate)
{
	//use IsDate() first !!!!
		
	var date_split;	
	var tdate, tmonth, tyear;
		
	date_split = argDate.split('/');
		
			
		
	tdate = parseInt(date_split[1]);
	tmonth = parseInt(date_split[0]);
	tyear = parseInt(date_split[2]);
		
	return date = new Date(parseInt(date_split[2]),parseInt(date_split[0])-1,parseInt(date_split[1]));
			
}

function IsEmail(valor)
{
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))
  {    
    return true;
  }
  else
  {
		return false;
  }
}

function IsSpace(str)
{
	var i;	
	for(i=0;i<str.length;i++)
	{
		if(str.charAt(i) == ' ')
		{		
			return true;
		}
	}	
	return false;
}


//VALIDACIONES PUNTUALES

function IsINT(obj, varMensaje, varMinimo, varMaximo)
{

	
	str = obj.value;	
//check mandatory field
	if ((str.length == 0))
	{
		alert("Debe Ingresar -> " + varMensaje);
		obj.focus();
		return false;
	}

	//check sanity
	if(!(IsNumeric(str)))
	{
		alert("El valor en el campo >" + varMensaje + "< debe ser numérico entero");								
		obj.focus();
		return false;
	}			
							
	if (parseInt(str) < parseInt(varMinimo))
	{
		alert("El Valor Mínimo en el Campo >" + varMensaje + "< es " + varMinimo);								
		obj.focus();
		return false;
	}
							
	//Chequear Limite Superior
	if (parseInt(str) > parseInt(varMaximo))
	{
		alert("El valor Máximo en el campo >" + varMensaje + "< es " + varMaximo);								
		obj.focus();
		return false;
	}
													
	//chequer que sea positivo
	if (str < 0)
	{
		alert("El valor en el campo >" + varMensaje + "< debe ser positivo");								
		obj.focus();
		return false;							
	}
	return true;
}

function IsALPHANUMERICTRIM(obj, varMensaje, varMinimo, varMaximo)
{
	
	
	str = obj.value;
	
	//check mandatory field
	if ((str.length == 0))
	{
		alert("Debe Ingresar -> " +  varMensaje);
		obj.focus();
		return false;
	}
						
	//check min length
	if (str.length < varMinimo)
	{
		alert("El número de dígitos o caracteres en: >" + varMensaje + "< debe ser mínimo de " + varMinimo);								
		obj.focus();
		return false;
	}

	//check max length
	if (str.length > varMaximo)
	{
		alert("El valor en el campo >" + varMensaje + "< contiene más de los caractéres permitidos: " + varMaximo);					
		obj.focus();
		return false;
	}
						
	//check AlphaNumericTrim
	if (!IsAlphaNumeric(str))							
	{
		alert("El campo -> " + varMensaje + "\nDebe tener solamente caracteres Alfabéticos y números");					
		obj.focus();
		return false;
	}
						
	if (IsSpace(str))
	{
		alert("El valor en el campo >" + varMensaje + "< no debe contener espacios");
		obj.focus();
		return false;	
	}	
	return true;
}
