//Posa els noms dels camps en ordre
function NomsCamps(objForm){
	var form = objForm
	
	if(objForm.camps){
		for(var i=0;i<objForm.length;i++){
			objForm.camps.value += objForm[i].name + ","
		}
	}
	
}

function isNumeric(value, msg) {
	var val = new Number(value);
	if (isNaN(val)) {
		alert (msg);
		return false;
	}else{
		return true;
	}
}

function validarData(valor, msg){
	var txt = msg;
	if ((valor.charAt(2) == '/') && (valor.charAt(5) == '/')){
		if (!isNaN(valor.substring(0,2)) && !isNaN(valor.substring(3,5)) && !isNaN(valor.substring(6,10))){
			if (valor.length > 10){
				alert(txt);
				validacion = 10;
				return false;
			}else{
				if (valor.length < 10){
					alert(txt);
					validacion = 1;
					return false;
				}else{
					if((parseInt(valor.substring(3,5),10) > 12) || (parseInt(valor.substring(3,5),10) < 1)){
						alert(txt);
						validacion = 2;
						return false;
					}else{
						if((parseInt(valor.substring(6,10),10) > 2500) || (parseInt(valor.substring(6,10),10) < 1000)){
							alert(txt);
							validacion = 3;
							return false;
						} else {
							if((valor.substring(3,5) == '01') || 
								(valor.substring(3,5) == '03') ||
								(valor.substring(3,5) == '05') ||
								(valor.substring(3,5) == '07') ||
								(valor.substring(3,5) == '08') ||
								(valor.substring(3,5) == '10') ||
								(valor.substring(3,5) == '12')){
								if((parseInt(valor.substring(0,2),10) > 31) || (parseInt(valor.substring(0,2),10) < 1)){
									alert(txt);
									validacion = 4;
									return false;
								}
							}
							if((valor.substring(3,5) == '04') ||
								(valor.substring(3,5) == '09') ||
								(valor.substring(3,5) == '11')){
								if((parseInt(valor.substring(0,2),10) > 30) || (parseInt(valor.substring(0,2),10) < 1)){
									alert(txt);
									validacion = 5;
									return false;
								}
							}
							if((valor.substring(3,5) == '02')) {
								if((parseInt(valor.substring(6,10),10) % 4) == 0){
									if((parseInt(valor.substring(0,2),10) > 29) || (parseInt(valor.substring(0,2),10) < 1)){
										alert(txt);
										validacion = 6;
										return false;
									}
								}
								if((parseInt(valor.substring(6,10),10) % 4) != 0){
									if((parseInt(valor.substring(0,2),10) > 28) || (parseInt(valor.substring(0,2),10) < 1)){
										alert(txt);
										validacion = 7;
										return false;
									}
								}
							}
						}
					}
				}
			}
		}else{
			validacion = 8;			
			alert(txt);
			return false;
		}
	}else{
		validacion = 9;		
		alert(txt);
		return false;
	}
	return true;
}