/*readyState values:

    * 0 (uninitialized)
    * 1 (loading)
    * 2 (loaded)
    * 3 (interactive)
    * 4 (complete)
*/


var str;
var dropid;
var pgnm;
var level;
var pgtitle;

function getSubMenu(pgnm,pgtitle){
var Http;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            Http = new XMLHttpRequest();
            if (Http.overrideMimeType) {
                Http.overrideMimeType('text/xml');
                }
        }
        else if (window.ActiveXObject) { // IE
            try {
                Http = new ActiveXObject("Msxml2.XMLHTTP");
            } 
            catch (e) {
                try {
                    Http = new ActiveXObject("Microsoft.XMLHTTP");
                } 
                catch (e) {}
            }
        }

var url="http://www.deutmedia.com/getsubmenu.php/";
url=url+"?pgnm="+pgnm+"&title="+pgtitle;
//document.write(url);
Http.onreadystatechange=function() { getSubMenuContent(Http); };
Http.open("GET",url,true);
Http.send(null);
}

//Get the main content from db

function callpage(pgnm,pgtitle,level){
var xmlHttp;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            xmlHttp = new XMLHttpRequest();
            if (xmlHttp.overrideMimeType) {
               xmlHttp.overrideMimeType('text/xml');
              }
        }
        else if (window.ActiveXObject) { // IE
            try {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } 
            catch (e) {
                try {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                } 
                catch (e) {}
            }
        }

if(level=="&x=m"){
var url="http://www.deutmedia.com/getcontent_main_ajax.php/";
url=url+"?"+pgnm+"="+pgnm+"&pgnm="+pgnm+"&title="+pgtitle+level;
xmlHttp.onreadystatechange = function() { getContent(xmlHttp,pgtitle); };
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
getSubMenu(pgnm,pgtitle);
}

if(level=="&x=s"){
var url="http://www.deutmedia.com/getcontent_main_ajax.php/";
url=url+"?"+pgnm+"="+pgnm+"&pgnm="+pgnm+"&title="+pgtitle+level;
xmlHttp.onreadystatechange=function() { getContent(xmlHttp,pgtitle); };
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
}

function getContent(xmlHttp,pgtitle){
//alert(pgtitle);
  if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200) {
             document.getElementById("wrapper").innerHTML=xmlHttp.responseText;
            } else {
                alert('System error 1: Request status problem.');
            }
      }else{
        document.getElementById("wrapper").innerHTML= pgtitle+" loading ...";
      }
 }

function getSubMenuContent(Http){
  if (Http.readyState == 4) {
            if (Http.status == 200) {
             document.getElementById("nav").innerHTML=Http.responseText;
             } else {
                alert('System error 2: Request status problem.');
            }
      }else{
        document.getElementById("nav").innerHTML= "Sub menu loading ...";
      }
     }

function showdropdown(){
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="dropmenu_ajax.php";
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

