

function replacestring(instr, finder, replacer)
{
    mystring = new String(instr);
	var tt = mystring.replace(finder, replacer);
	return tt;
}
function html_escapestring(instring)
{
	var outstr;
	outstr = replacestring(instring,'%','%25');
	outstr = replacestring(outstr,'&','%26');
	outstr = replacestring(outstr,' ','%20');
	return outstr;
}


function httpRequest(url, callback) {
    var httpObj = false;
    if (typeof XMLHttpRequest != 'undefined') {
        httpObj = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try{
            httpObj = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e) {
            try{
                httpObj = new ActiveXObject('iMicrosoft.XMLHTTP');
            } catch(e) {}
        }
    }
    if (!httpObj) return;

    httpObj.onreadystatechange = function() {
        if (httpObj.readyState == 4) { // when request is complete
            callback(httpObj.responseText);
        }
    };
	if ( url.indexOf("?")== -1 ){
			url	= url +  "?&dummy=" + new Date().getTime();
		} else {
			url	= url +  "&dummy=" + new Date().getTime();	
		}
    httpObj.open('GET', url, true);
    httpObj.send(null);
}


function containerreplace(bod){
	// new body.. that means new page load
	var bodpage = document.getElementById('container');
	bodpage.innerHTML = bod;
}

// Scripts for loading pages 

function selecthome()
{
 	httpRequest("home.php", containerreplace);
}
function selecthow()
{
 	httpRequest("how.php", containerreplace);
}
function selectbenefits()
{
 	httpRequest("benefits.php", containerreplace);
}
function selectabout()
{
 	httpRequest("about.php", containerreplace);
}
function selectcontact()
{
 	httpRequest("contact.php", containerreplace);
}
