function trim(stringa){    while (stringa.substring(0,1) == ' '){        stringa = stringa.substring(1, stringa.length);    }    while (stringa.substring(stringa.length-1, stringa.length) == ' '){        stringa = stringa.substring(0,stringa.length-1);    }    return stringa;}

function send_quality_form() {

	/*
	
		Controllo se ha scelto i 4 aggettivi
		
	*/
	
	
	//Conto gli aggettivi scelti
	var quality_count = 0;
	
	$('quality_form').getElements().each(function (e) {
		if (e.checked == true) {
			quality_count++;
		}
	
	});
	
	
	if (quality_count < 11) {
		//alert('Devi completare il form per poter votare.');
		
		var modal = new  Dialog({		content:'<p>Devi completare il form per poter votare!<br /><a href="javascript:Dialogs.close();">chiudi</a></p>',		close:{			link:false,			overlay:false,			esc:false		}
		
		});
		modal.open();
		return false;
	}
	
	$('quality_form').submit();

}

function send_quality_form_voted() {

	var modal = new  Dialog({	content:'<p>Hai già votato!<br /><a href="javascript:Dialogs.close();">chiudi</a></p>',	close:{		link:false,		overlay:false,		esc:false	}
	
	});
	modal.open();

}