encode = function(x){
	
	var charCodes=new Array(36);

	charCodes["a"]=". _";
	charCodes["b"]="_ . . .";
	charCodes["c"]="_ . _ .";
	charCodes["d"]="_ . .";
	charCodes["e"]=".";
	charCodes["f"]=". . _ .";
	charCodes["g"]="_ _ .";
	charCodes["h"]=". . . .";
	charCodes["i"]=". .";
	charCodes["j"]=". _ _ _";
	charCodes["k"]="_ . _";
	charCodes["l"]=". _ . .";
	charCodes["m"]="_ _";
	charCodes["n"]="_ .";
	charCodes["o"]="_ _ _";
	charCodes["p"]=". _ _ .";
	charCodes["q"]="_ _ . _";
	charCodes["r"]=". _ .";
	charCodes["s"]=". . .";
	charCodes["t"]="_";
	charCodes["u"]=". . _";
	charCodes["v"]=". . . _";
	charCodes["w"]=". _ _";
	charCodes["x"]="_ . . _";
	charCodes["y"]="_ . _ _";
	charCodes["z"]="_ _ . .";
	charCodes["1"]=". _ _ _ _";
	charCodes["2"]=". . _ _ _";
	charCodes["3"]=". . . _ _";
	charCodes["4"]=". . . . _";
	charCodes["5"]=". . . . .";
	charCodes["6"]="_ . . . .";
	charCodes["7"]="_ _ . . .";
	charCodes["8"]="_ _ _ . .";
	charCodes["9"]="_ _ _ _ .";
	charCodes["0"]="_ _ _ _ _";
	charCodes["."]=". _ . _ . _";
	charCodes[","]="_ _ . . _ _";
	charCodes["?"]=". . _ _ . .";
	charCodes["!"]=". . . _ .";
	charCodes["è"]=". . _ . .";
	charCodes["é"]=". . _ . .";
	charCodes["à"]=". _ _ . _";
	charCodes["ù"]=". . _ _";
	charCodes["ò"]="_ _ _ .";
	charCodes["ì"]=". .";
	charCodes[" "]=" ";
	var out = '';
	for(var i=0;i<x.length;i++) out += (charCodes[x.charAt(i)]=="undefined"?"":charCodes[x.charAt(i)]+"/"); 	
	return out;
}

isPhone = function (elementValue){
	var phonePattern = /[0-9]{8,15}/;
	return phonePattern.test(elementValue);
}

validate = function(){
	if($F('famiglia') == "") {
		alert("Il campo Famiglia deve essere inserito obbligatoriamente");
		return false;
	}
	if($F('telefono')!="" && !isPhone($F('telefono'))) {
		alert("Nel caso in cui si voglia lasciare il numero di telefono occorre scriverlo senza spazi.\nEs. 071123456");
		return false;
	}
	if(!$F('gioco') && !$F('degustazione') && !$F('preparazione') && !$F('fuoco')){
		alert("Almeno una delle opzioni deve essere selezionata");
		return false;
	}
	else return true;
}