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_petition_form() {

	/*
	
		Controllo se il file č gių sul DB
		
	*/
	
	if (trim($F('nome')) == '') {
		alert('Devi riempire i campi obbligatori.');
		return false;
	}
	if (trim($F('citta')) == '') {
		alert('Devi riempire i campi obbligatori.');
		return false;
	}
	if (trim($F('body')) == '') {
		alert('Devi riempire i campi obbligatori.');
		return false;
	}
	
	if ($F('accept') != '1') {
		alert('Devi leggere ed accettare le condizioni sulla privacy, le note regali ed il regolamento.');
		return false;	
	}
	
	show_progress()
	$('petition_form').request({
		onComplete: function(){ 
		show_success();
		 }
	});

}

function show_progress() {


	//Nascondo il form
	$('form_user').hide();
	//Azzero e mostro la barra di progresso
	$('processing').show();
	
}

function show_success() {

	$('processing').hide();
	$('success').show();
}
