function ckFrm_empty(campo,allerta){// Controlla Se il campo è pieno o vuoto
	var re = /[\s]/g;
	var str = campo.value.replace(re,'');
	if (str==""){
		if(allerta!=null) alert(allerta);
		else alert("Attenzione: il campo e' vuoto!");
		campo.focus();
		return false;
	}
	return true;
}
function ckFrm_empty2(campo){// Controlla Se il campo è pieno o vuoto senza alert
	var re = /[\s]/g;
	var str = campo.value.replace(re,'');
	if (str==""){
		return false;
	}
	return true;
}
function ckFrm_notEqual(campo,valore,allerta){// Controlla che il campo sia diverso da un valore specifico
	if (campo.value==valore){
		if(allerta!=null) alert(allerta);
		else alert("Attenzione: il campo non e' stato compilato!");
		campo.focus();
		return false;
	}
	return true;
}
function ckFrm_notEqual2(campo,valore,allerta){// Controlla che il campo sia diverso da un valore specifico senza alert
	if (campo.value==valore){
		return false;
	}
	return true;
}
function ckFrm_length(campo,lunghezza,allerta){// Controlla la lunghezza fissa di un campo
	if(campo.value.length != lunghezza){
		if(allerta!=null) alert(allerta);
		else alert("Attenzione: la dimensione del campo non e' di "+ lunghezza +" caratteri!");
		campo.focus();
		return false;
	}
	return true;
}
function ckFrm_email(campo,allerta){// Controllo del campo Email
	value = campo.value;
	pattern = /[^@_\-\.\w\d]|@@|\.\.|__|^@|^\.|^_|@$|\.$|_$|@\.|\.@|\._|_\.|(@)[^@]*\1/g; 
	if((((value.match(/@/)) && (value.match(/\./))) == null) || (value.match(pattern) != null)){
		if(allerta!=null) alert(allerta);
		else alert("Attenzione: l'indirizzo email inserito non e' corretto!");
		campo.focus();
		return false;
	}
	return true;
}
function ckFrm_number(campo,allerta){// Controlla se il campo è numerico
	if (isNaN(campo.value)){
		if(allerta!=null) alert(allerta);
		else alert("Attenzione: il campo non e' un numero!");
		campo.focus();
		return false;
	}
	return true;
}
function ckFrm_isDate(campo,allerta){// Controllo campo Data
	var regiornomese = new Array(2);
	var ok = true;
	var strdata = campo.value;
	var redata = new RegExp('^([0][1-9]|[1-2][0-9]|[3][0-1])[\/]([0][1-9]|[1][0-2])[\/](19|20)[0-9]{2}$');
	regiornomese[0] = new RegExp('^(((0[1-9]|1[0-9]|2[0-8])[\/]02)|((0[1-9]|[12][0-9]|30)[\/](04|06|09|11))|((0[1-9]|[12][0-9]|30|31)[\/](01|03|05|07|08|10|12)))$');
	regiornomese[1] = new RegExp('^(((0[1-9]|1[0-9]|2[0-9])[\/]02)|((0[1-9]|[12][0-9]|30)[\/](04|06|09|11))|((0[1-9]|[12][0-9]|30|31)[\/](01|03|05|07|08|10|12)))$');
	if(strdata.search(redata) == -1) ok = false;
	else{
		anno = strdata.substring(6,10);
		giornomese = strdata.substring(0,5);
		anno1 = anno.substring(0,2);
		anno2 = anno.substring(2,4);
		bisestile = 0;
		if((parseInt(anno/4) == anno/4) && ((anno2 != '00') || ((anno2 == '00') && (parseInt(anno1/4) == anno1/4)))) bisestile = 1;
		if(giornomese.search(regiornomese[bisestile]) == -1) ok=false;
	}
	if(!ok){
		if(allerta!=null) alert(allerta);
		else alert("Attenzione!\nInserire la data nel formato gg/mm/aaaa");
		campo.focus();
		return false;
	}
	return true;
}
function ckFrm_selected(campo,allerta){// Controlla se è stato selezionato un valore in una select
	var re = /[\s]/g;
	var str = campo.options[campo.selectedIndex].value.replace(re,"");
	if (str==""){
		if(allerta!=null) alert(allerta);
		else alert("Attenzione: seleziona la tua scelta!");
		campo.focus();
		return false;
	}
	return true;
}
function ckFrm_radio(campo,allerta){// Controlla se è stato selezionato un radio
	var found = false;
	for (var j=0;j<campo.length;j++){	
		if (campo[j].checked){
			found = true;
			break;
		}
	}
	if (!found){
		if(allerta!=null) alert(allerta);
		else alert("Attenzione: seleziona la tua scelta!");
		campo[0].focus();
		return false;
	}
	return true;
}
function ckFrm_checkbox(campo,allerta){// Controlla se è stato selezionato un checkbox
	if(!campo.checked) {
		if(allerta!=null) alert(allerta);
		else alert("Attenzione: seleziona la tua scelta!");
		campo.focus();
		return false;
	}
	return true;
}
function ckFrm_checkbox2(campo,allerta){// Controlla se è stato selezionato un checkbox senza allerta
	if(!campo.checked)return false;
	return true;
}