

function current(id){

        $(id).addClass("current");
  //   alert("Hello world! 2");
  if(id == ".gallery")
	  $(id).attr("href","./gallery.php"); 
     
}

/**
 * Trigged on "onsubmit" in the form#sendmail_form. Check field and show an alert()
 * If no error occour use Ajax request to send in POST method data to php page for
 * send mail.
 *
 * @param			void
 * @return			{boolean}	Every FALSE
 */
function onSendmail() {
	
	alert('valido la mail');
    // regex mail
    var __filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    // ie fix
    var f = document.forms['sendmail_form'];
    // test all field
    if ($F('name') == "") {
        alert("ATTENZIONE!!\n\nIl campo 'Nome' e' vuoto!");
        // use this ofr return false
        f.name.focus();
        return false;
    }
    if ($F('email') == "") {
        alert("ATTENZIONE!!\n\nIl campo 'Email' e' vuoto!");
        f.email.focus();
        return false;
    }
    if (!__filter.test($F('email'))) {
        alert("ATTENZIONE!!\n\nIl campo 'Email' NON e' valido!");
        f.email.select();
        f.email.focus();
        return false;
    }
    if ($F('subject') == "") {
        alert("ATTENZIONE!!\n\nIl campo 'Oggetto' e' vuoto!");
        f.subject.focus();
        return false;
    }
    if ($F('body') == "") {
        alert("ATTENZIONE!!\n\nIl campo 'Messaggio' e' vuoto!");
        f.body.focus();
        return false;
    }
    if ($F('privacy') != 1) {
        alert("ATTENZIONE!!\n\nDevi autorizzare l'informativa sulla Privacy!");
        f.privacy.focus();
        return false;
    }
    // in waiting
    showHideIdle(true);
    // Ajax request    
    $('sendmail_form').request({
        onSuccess: function(transport){
            var status = transport.responseXML.getElementsByTagName('status')[0].firstChild.nodeValue;
            var mes = transport.responseXML.getElementsByTagName('message')[0].firstChild.nodeValue;
            
            // open result
            Shadowbox.open({
                title: 	'Invio Messaggio',
                player: 'html',
                content: mes,
                height: 200,
                width: 450
            }, {
                onClose: function(){
                    showHideIdle(false);
                    //
                    if (status == 0) {
                        // clear the form
                        var f = document.forms['sendmail_form'];
                        f.name.value = f.email.value = f.subject.value = f.body.value = "";
                        f.privacy.checked = false;
                        //
                        var s = $('navselection').getStyle('margin-left');
                        s = s.substr(0, (s.length - 2));
                        new Effect.Tween(null, s, (108) + (160 - 108), {
                            duration: .5,
                            transition: Effect.Transitions.sinoidal
                        }, function(p){
                            $('navselection').setStyle({
                                marginLeft: p + "px"
                            });
                        });
                        
                        var ul = $("undoslide_1").down();
                        var k = ul.getStyle('margin-left');
                        k = k.substr(0, (k.length - 2));
                        new Effect.Tween(null, k, 0, {
                            duration: .5,
                            transition: Effect.Transitions.sinoidal
                        }, function(p){
                            $("undoslide_1").down().setStyle({
                                marginLeft: p + "px"
                            });
                        });
                    }
                    else {
                        Form.Element.activate('name')
                    }
                    //
                }
            });
        }
        //onComplete: function(){ alert('Form data saved!') }
    })
	return false;
}

