////////////////////////////////////////////////////////////////////////////////////////
// Script usr
var FB = null;
function sendLogin365() {
    
    error = false;
    if($('#login').val() == '' || $('#login').val() == undefined)
    {
    	error = true;
      $('#login').css('border', '1px solid #F6629A');
    }
    
    if($('#passwd').val() == '' || $('#passwd').val() == undefined)
    {
    	error = true;
      $('#passwd').css({border: '1px solid #F6629A'});
    }
    
    if(error)
    	return false;


  	$.ajax({
  	  type: 'POST',
  		url: '/ajax.php?page=utilisateur&sc=log',
  		data: "insc=1&email="+$('#login').val()+"&pw="+$('#passwd').val(),
      success: function(msg){

            //alert(msg);
		  			if(msg == 'okay') {

          			$.ajax({
                 type: "GET",
                 url: '/ajax.php?page=utilisateur',
                 success: function(data){
                      $('#votreEspaceContent').html(data);
                    }          
                });

				  	}
		  			else
		  			{
		  			   alert('Votre Login et/ou votre mot de passe ne sont pas correct(s)...');
		  			   getLoginForm();
		  			}
				  	
				  	
       } 
  	});   

	  
    return false;

}
 

var logged = 0;
function getLoginForm(){

  if(document.getElementById('votreEspaceContent'))
	{
		if(FB)
		{
			if(FB.Connect)
				FB.Connect.ifUserConnected(auth_using_fb,getLoginForm2)
			else
				getLoginForm2();
		}
		else
			getLoginForm2();
	}
}

function getLoginForm2(){

  if(document.getElementById('votreEspaceContent'))
	{
			$.ajax({
       type: "GET",
       url: '/ajax.php?page=utilisateur',
       success: function(data){
            $('#votreEspaceContent').html(data);
          	FB.init("6d687fb8347eca7290542d72a21d3ad7", "/xd_receiver.htm",{"ifUserConnected" : auth_using_fb});
          }          
      });

	}
}


function dLog(){

  if(document.getElementById('votreEspaceContent'))
	{
	   if(FB.Connect)
	   {
	   		FB.Connect.logout(dLog2);	 
	   }
	   else
	   {
	   		dLog2();
	   }
	}
}

function dLog2(){
		$.ajax({
       type: "GET",
       url: '/ajax.php?page=utilisateur&sc=dlog',
       success: function(data){

          			$.ajax({
                 type: "GET",
                 url: '/ajax.php?page=utilisateur',
                 success: function(data){
                      $('#votreEspaceContent').html(data);
                      FB.init("6d687fb8347eca7290542d72a21d3ad7", "/xd_receiver.htm",{"ifUserConnected" : auth_using_fb});
                      //FB.Connect.ifUserConnected(auth_using_fb)
                    }          
                });
                
                
          }          
      });
	
}

/*
// MOOTOOLS

function showUsrDiv() {
	var myRequest = new Request({
		url: './_mod/usr/usr_header.div.php',
		method: 'get'	
  	});
  	myRequest.onSuccess= function(html){
	  	$('formLogin').set('html',html);
  	};
    	myRequest.send();
}	


function showUsrBox() {
	var myRequest_2 = new Request({
		url: './_mod/usr/usr.300.box.php',
		method: 'get'
  	});
  	myRequest_2.onSuccess= function(html){
	  	$('moncompte').set('html',html);
  	};
  	myRequest_2.send();
}
	

function updateUsrStatus() {
        //alert('tomm');
  var myRequest = new Request({
  		url: './ajax.usr-up.php',
  		method: 'get'	
  	});
		  	
		  	
  myRequest.onSuccess= function(html){
	//$('boxe_votes').set('html',html);

	if(html == 'LOGGED'){
		$('banniereIssy').setStyle('background',"white url('./_themes/default/header_logged.jpg') no-repeat");
		//findObj('formulaireLoginIssy_msg').innerHTML = '';
		//showUsrDiv();
		//showUsrBox();
		//showPollsIssy365(1);
		//$('boxe_votes').set('html',html);
			
	}
	else {
		$('banniereIssy').setStyle('background',"white url('./_themes/default/header_home.jpg') no-repeat");
		//findObj('formulaireLoginIssy_msg').innerHTML = '';
		showUsrDiv();
	}
};
myRequest.send();
        

}
*/

// Script usr
////////////////////////////////////////////////////////////////////////////////////////