// get a connection object
function getghr(){

  if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
      return new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    // code for IE6, IE5
     return new ActiveXObject("Microsoft.XMLHTTP");
  } else {
    alert("Your browser does not support XMLHTTP!");
  }

  return false;
} // end function getghr

// and show the information
function getMenus(web, topic){
    var xmlhttp = getghr();

    // this is the handler (if we are completed with the ajax transmission)
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState==4)
        {
            response = xmlhttp.responseText;
            elems = response.split(/<\?sep\?>/);

           // check if there was no auth
           if (elems[0] != 'NOAUTH') {

               document.getElementById("MetaMenu").innerHTML=elems[1];
               document.getElementById("TopicMenu").innerHTML=elems[2];

               if (document.getElementById("SponsArt")) {
                   document.getElementById("SponsArt").innerHTML=elems[3];
               }

               if (elems[5] != undefined) {
                   gcount = elems[4];
                   actions = elems[5].split(/<\?xxx\?>/);
                   for (i = 0; i < gcount; i++) {
                       if (document.getElementById("TopicGroupAction" + i)) {
                           document.getElementById("TopicGroupAction" + i).innerHTML = actions[i];

                           document.getElementById("TopicGroupAction" + i).className="";
                       }
                   } // end for (...topic groups...)
               } // end if (...topic groups...)
           } else {

               // this id may be optional in the template
               if (document.getElementById("Promotion")) {
                   document.getElementById("Promotion").innerHTML="<h1 style='color:#000'>Werde Lexikonautor. Jetzt <a href='/MundipediaRegistrierung'>registrieren</a>!</h1>";
               }

           } // end if (...authenticated...)
        } // end if (...ready state...)
    } // end function

    xmlhttp.open("GET", "/bin/menus.pl/" + web + '/' + topic, true);
    xmlhttp.send(null);
} // end function getMenus


