/**
Gestion de la connexion client
*/
function inscription( ){
	var etape = $('lienConnexion').getAttribute('attr');
	var opt = {
	    method: 'post',
	    postBody: "action=submitInscription&etape="+ escape( etape ) +"&"+ $('formInscription').serialize(),
	    onSuccess: function(t) {
    		var rep 		= eval("(" + t.responseText + ")");
    	 	if( rep.error == 1 )
    	 		alert( rep.msg );
    	 	else
    	 	{
    	 		if( rep.etape == 1 )
    	 		{
    	 			$('divInscription').innerHTML = rep.msg;
    	 		}
    	 		else
    	 		{
	    	 		$('logging').innerHTML = rep.htmllogging;
	    	 		$('divInscription').innerHTML = rep.template;
	    	 		$('liendivCompte').observe('click', function(e) {
							Event.stop(e);
							affPopup( this.getAttribute('attr') );
						} );
						$('logging').className = 'loggON';
    	 		}
    	 	}
	    }
	  }
	  new Ajax.Request('dispatcher.php', opt);
}
function oubliePass( ){
	var opt = {
    method: 'post',
    postBody: "action=oubliePass&"+ $('formInscription').serialize(),
    onSuccess: function(t) {
    		var rep 		= eval("(" + t.responseText + ")");
    		alert( rep.msg );
    		if( rep.error == 2 )
    	 	{
    	 		$('divOubliPass').hide();
    	 		$('grise').hide();
    	 	}
    	 		
    }
  }
  new Ajax.Request('dispatcher.php', opt);
}
function logging( ){
	var opt = {
    method: 'post',
    postBody: "action=logging&"+ $('loggingForm').serialize(),
    onSuccess: function(t) {
    		var rep 		= eval("(" + t.responseText + ")");
    	 	if( rep.error == 1 )
    	 		alert( rep.msgHTMLlogging );
    	 	else
    	 	{
    	 		$('logging').className = 'loggON';
    	 		$('logging').innerHTML = rep.msgHTMLlogging;
    			$('liendivCompte').observe('click', function(e) {
						Event.stop(e);
						affPopup( this.getAttribute('attr') );
					} );
					if( rep.msgHTMLpanier != '' )
					{

						$('divContenuCommande').innerHTML = rep.msgHTMLpanier;
						$('divContenuCommande').show();
						initPopup("divContenuCommande");
						$('grise').show();
					}
					if( rep.msgHTMLcatalogue != '' )
					{
						$('content').innerHTML = rep.msgHTMLcatalogue;
					}
    	 	}
    }
  }
  new Ajax.Request('dispatcher.php', opt);
}
function deconnexion( ) {
	alert( lg_aurevoir );
  window.location.href = "./deconnexion.php";
}
