function ajaxmenu(page) {
   if (page == '') return;
   var url = 'p/'+page+'.php';
      
	new Ajax.Updater(
		{success:'td-page-content'},
	   url,
	      {
	         method: 'post'
	      }
	);
    
    document.location.hash=page; 
    return false;
   
}

function ajaxcompetence(page) {
    new Ajax.Updater(
       'td-competence-content',
       'p/competences/'+page+'.htm',
        { method: 'post' }
    );
    
 }

function envoyerMail () {
	$('frm-envoi-MP').request({
		onSuccess: function(transport){ 
			$('e_envoyer').update(transport.responseText);
			$('frm-envoi-MP').reset();
			$('b_envoyer').disable();
		}
	})
}

function submitInscription(p_form) {
    $(p_form).request({
		onSuccess: function(transport){ 
            $$('span.message').each(function(item) {
                item.hide();
            });

            var json = transport.headerJSON;
			for(var key in json.erreur){
                $('msg-'+key).update(json.erreur[key]);
                $('msg-'+key).setStyle({
                    color: 'red',
                    fontWeight: 'bold',
                    fontStyle: 'italic'
                });

                $('msg-'+key).show();
            }
            
            if (typeof( json.ok ) != "undefined" ) {
                $('msg-global').update(json.ok);
                $('msg-global').setStyle({
                    color: 'green',
                    fontWeight: 'bold',
                    fontStyle: 'italic'
                });

                $(p_form).disable();
                Lightview.show({ 
                    href: 'msg-global', 
                    rel: 'inline', 
                    title: 'Mail envoy&eacute;',
                    options: { 
                        width: 400, 
                        height: 80, 
                        closeButton: false, 
                        overlayClose: false
                    }
                });
                    
                $('msg-global').observe('lightview:hidden', function(event) {
                    alert('test');
                    document.location = 'http://atlantis.localhost.internal/';
                });

            }
		}
	});

    return false;
}
