function connexion()
{
	var mail = document.getElementById('EMAIL').value;
	var mdp  = document.getElementById('MOTDEPASSE').value;
	var newElem = document.getElementById("BLOC_LOGIN");
	
	newElem.innerHTML="<div class='load_login'/>";
	
	try{
		new AJAXRequest('POST','/Site/identification.php','EMAIL='+mail+'&MOTDEPASSE='+mdp,connexionCB);		
	}catch(err){alert('pb connexion');}
	
	
}

function connexionCB(ajaxRequest)
{
	if (ajaxRequest.readyState == 4) {
		if (ajaxRequest.status == 200) {
			var newElem = document.getElementById("BLOC_LOGIN");
			
			newElem.innerHTML = '';
		  newElem.innerHTML = ajaxRequest.responseText;
		  
		  if(jQuery('#LOG_SUCCESS').val()=="OUI") 
		  {
		  	jQuery("#PLAN_SITE").load("/Site/templates/PlanSiteAjax.php?AJAX=OUI");
		  	//jQuery("#HEADER_HTML").load("/Site/templates/HeaderAjax.php?AJAX=OUI");
		  	
		  	if(jQuery('#IS_TC').val()=="OUI") window.location.href="/Site/TC/accueil_tc.php";
		  }
		  
		}
	}
}

function deconnexionCB(ajaxRequest)
{
	if (ajaxRequest.readyState == 4) {
		if (ajaxRequest.status == 200) {
			
			/*
			var newElem = document.getElementById("BLOC_LOGIN");
			
			newElem.innerHTML = '';
		  newElem.innerHTML = ajaxRequest.responseText;
		  
		  if(jQuery('#LOG_SUCCESS').val()=="OUI") 
		  {
		  	jQuery("#PLAN_SITE").load("/Site/templates/PlanSiteAjax.php?AJAX=OUI");
		  	jQuery("#HEADER_HTML").load("/Site/templates/HeaderAjax.php?AJAX=OUI");
		  }
		  */
		  
		  window.location.href="/Site/accueil.php";
		  
		  
		}
	}
}


function deconnexion(connexion_ajax)
{
	var newElem = document.getElementById("BLOC_LOGIN");
	newElem.innerHTML="<div class='load_login'/>";			
	
	try{
		if(connexion_ajax=='OUI')
		{
			new AJAXRequest('POST','/Site/deconnexion.php','',deconnexionCB);					
		}
		else	
		{
			new AJAXRequest('POST','/Site/deconnexion.php','');		
		}
	}catch(err){alert('pb deconnexion');}
}

function connexion2()
{
	document.form_login.submit();
}

