var xmlHttpReq = null;
var changeDiv = "";
var basePath = this.location + "subpages/";
var previousPage = 'homePage';

function loadPage()
{
    changeContent('centerContent', 'homePage')
}

function xmlHttpPost(strURL)
{
    
    if(createObject() != false)
    {   
        xmlHttpReq.open('GET' , strURL);              
        xmlHttpReq.setRequestHeader('Content-Type', 'text/html');
        xmlHttpReq.onreadystatechange = callback; 
        xmlHttpReq.send('');                      
    }    
}

function createObject()
{
    var returnValue = false;
    if(window.XMLHttpRequest)
    {   
        // Mozilla/Safari        
        xmlHttpReq = new XMLHttpRequest();
        returnValue = true;
    }
    else if(window.ActiveXObject)
    {
        // Internet Explorer
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        returnValue = true;
    }
    
    return returnValue;    
}

function callback()
{
    if(xmlHttpReq.readyState == 4)
    {   
        updateContent(xmlHttpReq.responseText);
    }
}

function updateContent(inputText)
{
    if(changeDiv != "")
    {       
        document.getElementById(changeDiv).innerHTML = inputText;
    }
}

function changeContent(divID, strURL)
{
    document.getElementById(previousPage).className = "navbar_li";
    document.getElementById(strURL).className = "navbar_li_clicked"
    previousPage = strURL;
    changeDiv = divID;
    strURL = basePath + strURL + '.html';    
    xmlHttpPost(strURL);    
}

function getChangeDiv()
{
    return changeDiv;
}