function p_load()
{
  login_focus();
  msg_c();
  t_logout();
  //clock();
}

//function clock()
//{
//    var xhr=null;
//    
//    if (window.XMLHttpRequest) { 
//        xhr = new XMLHttpRequest();
//    }
//    else if (window.ActiveXObject) 
//    {
//        xhr = new ActiveXObject("Microsoft.XMLHTTP");
//    }
//    //on définit l'appel de la fonction au retour serveur
//    xhr.onreadystatechange = function() { alert_clock(xhr); };
//
//    //on appelle le fichier reponse.txt
//    xhr.open("GET", "/perl/date.pl", true);
//    xhr.send(null);
//}

//function alert_clock(xhr)
//{
//    if (xhr.readyState==4) 
//    {
//        var docXML= xhr.responseXML;
//        var items = docXML.getElementsByTagName("i");
//        var clock='';
//        clock=items.item(0).firstChild.data;
//        document.getElementById('date').innerHTML = clock;
//        //var t=setTimeout("clock()",1000);
//    }
//}

function login_focus()
{
  if (document.login_form) {
    document.login_form.user_email.focus();
  }
}

function msg_c()
{
    if (document.getElementById("msg_c")) {
        var xhr=null;
        
        if (window.XMLHttpRequest) { 
            xhr = new XMLHttpRequest();
        }
        else if (window.ActiveXObject) 
        {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
        //on définit l'appel de la fonction au retour serveur
        xhr.onreadystatechange = function() { alert_msg_c(xhr); };

        //on affiche le message d'attente
        //document.getElementById("w_msg_c").className="wv";
        document.getElementById('msg_c').innerHTML = "Veuillez patienter...";
        
        //on appelle le fichier reponse.txt
        xhr.open("GET", "/msg_c.pl", true);
        xhr.send(null);
    }
}

function alert_msg_c(xhr)
{
    if (xhr.readyState==4) 
    {
        var docXML= xhr.responseXML;
        var items = docXML.getElementsByTagName("i");
        var msg_c='';
        //document.getElementById("w_msg_c").className="wh";
        msg_c=items.item(0).firstChild.data;
        if (msg_c > 0) {
          document.getElementById('msg_c').innerHTML = "<blink><a href=\"/index.pl?show-threads=1\" class=\"ch\">"+msg_c+" Nouveaux messages</a></blink>";
          document.title=msg_c+" nouveau message(s) !";
          var thissound=eval("document.sound_message");
          thissound.Play();
        } else {
          document.getElementById('msg_c').innerHTML = "Pas de nouveaux messages";
          document.title="Meet-Bi.net";
        }
        var t=setTimeout("msg_c()",5000);
    }
}

function t_logout()
{
    // timeout : 1800 minutes (30 heures)
    var t=setTimeout("logout()",1800*60*1000);
}

function logout()
{
    window.location="?action_logout=1";
}

function showImg(imgSrc, H, W, Caption) {
    var newImg = window.open("","myImg",config="height="+H+",width="+W);
    newImg.document.write("<title>"+ Caption +"</title>");
    newImg.document.write("<img src='"+ imgSrc +"' height='"+ H +"' width='"+ W +"' onclick='window.close()' style='position:absolute;left:0;top:0'>");
    newImg.document.write("<script type='text/javascript'> document.oncontextmenu = new Function(\"return false\") </sc"+"ript>");
    newImg.document.close();
}
