function xmlhttpPost(strURL) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function () {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(getquerystring());
}

function getquerystring() {
//    var form = document.forms['f1'];
//    var word = form.word.value;
//    qstr = 'w=' + escape(word);  // NOTE: no '?' before querystring
    //    return qstr;
    return '';
}

function updatepage(str) {
    document.getElementById("project").style.display = "none";
    document.getElementById("loadingPageSection").style.display = "none";
    document.getElementById("placeholder").style.display = "block";
    document.getElementById("placeholder").innerHTML = str;
}


var lastHash = '';

function pollHash() {
    if (lastHash !== location.hash) {
        lastHash = location.hash;
        // hash has changed, so do stuff:
        //alert(lastHash);
        var pageSpecifier = lastHash.substring(1);

        if (pageSpecifier == "") {
            pageSpecifier = "index";
        }
        
        xmlhttpPost(pageSpecifier + '.html?inline=true');

        //alert(pageSpecifier + '.html?inline=true');
        
        document.getElementById("project").style.display = "none";
        document.getElementById("loadingPageSection").style.display = "block";
        document.getElementById("placeholder").style.display = "none";
    }
}
setInterval(pollHash, 100);
