// JavaScript Document
//File contains AJAX implementation logic 02.12.2007

var page;
var link_val;
var http = createRequestObject();


function createRequestObject() {
        var objAjax;
    var browser = navigator.appName;
        if(browser == "Microsoft Internet Explorer"){
           objAjax = new ActiveXObject("Microsoft.XMLHTTP");
       }else{
          objAjax = new XMLHttpRequest();
 }
       return objAjax;
}


//First step in AJAX execution, generate the proper left links list based on the three parameters 
function getNewContent(link_value, link_value_active, page_url){
			page = page_url;
			link_val = link_value;
		  var links_url = '../'+link_value+'/ajax_links.php?link_value='+ link_value + '&' + 'link_value_active=' + link_value_active ;
	         http.open('get',links_url);
	         http.onreadystatechange = updateNewContent;
	         http.send(null);
        return false;
}

function updateNewContent(){
	     if(http.readyState == 4){
         var contentDivtagOne = http.responseText;
		 document.getElementById('linkList').innerHTML = contentDivtagOne;
		 getNewContent2(page);
		}
}

//Second step in AJAX execution generate the proper 'maincontent' based on the 'page_url' parameter of the getNewContent function see above.
function getNewContent2(page){
//Insert the php code page to extract and insert the maincontent

       var maincontent_url = '../'+link_val+'/ajax_maincontent.php?maincontent_value='+ page  ;
	   http.open('get',maincontent_url);
	   http.onreadystatechange = updateNewContent2;
       http.send(null);
	   return false;
}

function updateNewContent2(){
      if(http.readyState == 4){
              var contentDivtagTwo = http.responseText;
			      document.getElementById('maincontent').innerHTML = contentDivtagTwo;
    }
}





