function checkForm(){
	//return true; // MODO DEBUG
	var args = checkForm.arguments;
	var aArgs = args[0].split(",");
	var n,swError = false, obj, cmp, nom, aux;
	var error = "";
	for (n = 0; n<aArgs.length; n++)
	{
		aux = aArgs[n].split("|");
		cmp = aux[0];
		nom = aux[1];
		arg = "";
		if (aux.length > 2){arg = aux[2];}
		obj = document.getElementById(cmp);
		if (obj != null){
			if (obj.value.trim().length <= 0)
			{
				swError = true;
				error += "Campo requerido: "+ nom+"\n";
			}
			if (arg.trim().length > 0){
				if (arg == "email")
				{
					if (!isValidEmail(obj.value.trim()))
					{
						swError = true;
						error += "Formato no valido en campo: "+ nom+"\n";
					}
					var obj2 = document.getElementById(obj.id+"_repeat");
					if (obj2){
						if (!checkSameEmail(obj.value.trim(),obj2.value.trim())){
							swError = true;
							error += " Los email no son iguales";
						}
					}
				}
			}
		}
	}
	if (swError)
	{
		alert(error);
		return false;
	}
	return true;
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function isValidDate(fecha){
	if (fecha.length <= 0){return true;}
	var vFecha = fecha.split("-");
	var ano = parseInt(vFecha[0]);
	var mes = parseInt(vFecha[1]);
	var dia = parseInt(vFecha[2]);
	var diasMeses = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	if (ano < 1900){return false;}
	if (ano % 4 == 0) {diasMeses[1] = 29;}
	if ((mes <= 0) && (mes > 12)){ return false;}
	return ((dia > 0) && (dia <= diasMeses[mes-1]));
}

function isValidNumber(valor){ 
	if (valor.length <= 0) return true;
    //intento convertir a entero. 
    //si era un entero no le afecta, si no lo era lo intenta convertir
	var valores = "0987654321";var letter, test;
	for (var i = 0;i<=valor.length-1;i++)
	{
		letter = valor[i];
		if (valores.indexOf(letter) < 0)
		{
			return false;
		}
	}
	return true;
}
function isValidEmail(str) {
   if (str.length <= 0) return true;
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}
function checkSameEmail(str1,str2){
	return (str1 == str2);	
}

