// JavaScript Document

var xhr = null; 
var xhr2 = null; 
function getXhr()
{

     if(window.XMLHttpRequest)xhr = new XMLHttpRequest(); 
else if(window.ActiveXObject)
  { 
  try{
     xhr = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) 
     {
     xhr = new ActiveXObject("Microsoft.XMLHTTP");
     }
  }
else 
  {
  alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
  xhr = false; 
  } 
}


  
function resultlogin(id_div,f)
{
document.getElementById("zoneinfohead").style.height="70px";
document.getElementById("zoneinfohead").style.background="URL('http://logiciels.meteo-mc.fr/design/pics/zoneinfohead.gif') bottom left no-repeat";
document.getElementById(id_div).innerHTML= '<img style=\" margin-left:260px\" src="http://logiciels.meteo-mc.fr/design/pics/load.gif" alt=\"chargement\"/>';
var formlogin = document.getElementById("login");
var action = formlogin.action.value;
var form_sent = formlogin.form_sent.value;
var pseudo = formlogin.pseudo.value;
var mdp = formlogin.mdp.value;


getXhr();
xhr.onreadystatechange = function()
    {
     if(xhr.readyState == 4 && xhr.status == 200)
     {
     if(xhr.responseText!="<p class=\"error\">Identifiant et/ou mot de passe incorrect</p><img class=\"right\" src=\"http://logiciels.meteo-mc.fr/design/pics/anul.gif\" onclick=\"closeresult()\" alt=\"Annuler\"/>"){
     if(f==="y"){window.location.reload();}
     else{
     document.getElementById("zoneinfohead").style.height="";
     document.getElementById("zoneinfohead").style.background="URL('http://logiciels.meteo-mc.fr/design/pics/zoneinfoheads.gif') bottom left no-repeat";
     document.getElementById("zoneinfohead").innerHTML= xhr.responseText;
     }
     }
     else{
     document.getElementById("resultlog").innerHTML= xhr.responseText;
     }
     }
    }
xhr.open("GET","http://logiciels.meteo-mc.fr/forum/loginext.php?action="+action+"&form_sent="+form_sent+"&req_username="+pseudo+"&req_password="+mdp+"&f="+f,true);

xhr.send(null);

}

function resultnologin(id,f){
document.getElementById("zoneinfohead").style.height="70px";
document.getElementById("zoneinfohead").style.background="URL('http://logiciels.meteo-mc.fr/design/pics/zoneinfohead.gif') bottom left no-repeat";
document.getElementById("zoneinfohead").innerHTML= '<p class="center">déconnexion en cours...</p><img style=\" margin-left:260px\" src="http://logiciels.meteo-mc.fr/design/pics/load.gif" alt=\"chargement\"/>';
getXhr();
xhr.onreadystatechange = function()
    {
     if(xhr.readyState == 4 && xhr.status == 200)
     {
 if(xhr.responseText==="nologged"){
 if(f==="y"){window.location.reload();}
 else{
     document.getElementById("zoneinfohead").style.height="";
     document.getElementById("zoneinfohead").style.background="URL('http://logiciels.meteo-mc.fr/design/pics/zoneinfoheads.gif') bottom left no-repeat";
     document.getElementById("zoneinfohead").innerHTML= ' <div class="login"><form id="login" action=""><p><input type="hidden" name="action" value="in" /><input type="hidden" name="form_sent" value="1" />Identifiant : <input type="text" name="pseudo" size="7" maxlength=\"25\" /> Mot de passe : <input type="password" name="mdp" size="7" maxlength="16" />  </p></form></div><ul><li><a href="" onclick="resultlogin(\'resultlog\',\''+f+'\'); return false;">connexion</a></li><li><a href="http://logiciels.meteo-mc.fr/inscription.php">inscription</a></li></ul><div id="resultlog"></div>';
     }
     }
     

}
}
xhr.open("GET","http://logiciels.meteo-mc.fr/forum/loginext.php?action=out&id="+id,true);

xhr.send(null);
}

function closeresult(){
document.getElementById("resultlog").innerHTML="";
document.getElementById("zoneinfohead").style.height="";
document.getElementById("zoneinfohead").style.background="URL('http://logiciels.meteo-mc.fr/design/pics/zoneinfoheads.gif') bottom left no-repeat";
}
