// JavaScript Document
// VALIDACIO DE FORMULARIS
function checkForm(id) {
	var error = false;
	$$('form#'+id+' .required').each(function(node){
		if (node.value == "") {
			error = true;
			node.style.background = "#FF9900";
		} else{
			node.style.background = "#faf1d2";
		}
	});
	$$('form#'+id+' .email').each(function(node){
		if (node.value != "") {							  
			if ((node.value.indexOf(".") < 5) || (node.value.indexOf("@") == -1)) {
				error = true;
				node.style.background = "#FF9900";
			} else{
				node.style.background = "#faf1d2";
			}
		}
	});
	$$('form#'+id+' .numeric').each(function(node){
		var strChars = "0123456789.-,";
		for (i = 0; i < node.value.length; i++) {
			strChar = node.value.charAt(i);
			if (strChars.indexOf(strChar) == -1) {
				error = true;
			}
			if (error){
			node.style.background = "#FF9900";
		}else{
			node.style.background = "#faf1d2";
		}
		}
	});
	$$('form#'+id+' .telfs').each(function(node){
		var strChars = "0123456789.-,";
		for (i = 0; i < node.value.length; i++) {
			strChar = node.value.charAt(i);
			if (strChars.indexOf(strChar) == -1) {
				error = true;
			}
		}
		if (error){
			node.style.background = "#FF9900";
		}else{
			node.style.background = "#faf1d2";
		}
	});
	$$('form#'+id+' .fecha').each(function(node){
		var strChars = "0123456789-/";
		for (i = 0; i < node.value.length; i++) {
			strChar = node.value.charAt(i);
			if (strChars.indexOf(strChar) == -1) {
				error = true;
			}
		}
		if (error){
			node.style.background = "#FF9900";
		}else{
			node.style.background = "#faf1d2";
		}
	});
	return error;
}