﻿// JScript File
var moduleReq;

function asynchGet(updateURL){
    if (window.XMLHttpRequest) {
        moduleReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        moduleReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    moduleReq.onreadystatechange = processReqChange;
    moduleReq.open("GET", updateURL, true);
    moduleReq.send(null);
}
function selectItem(evt,module,file) {
    evt = (evt) ? evt : ((window.event) ? window.event : null);
    if (evt) {
        var select = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
        if (select && select.options.length > 1) {
            // When invoice is selected, call underlying web-app to return
            // content.
            // For this sample, the content is hard-coded HTML, but in a real
            // deployment a call to servlet or JSP in the web-app can be
            // used to return this content instead.
            asynchGet(file+"?"+module+"=" + select.value);
        }
    }
}
function loadItem(module,file,value) {
    asynchGet(file+"?"+module+"=" + value);
}
function processReqChange() {
    if (moduleReq.readyState == 4) {
        if (moduleReq.status == 200) {
            // process response
            displayItem();
        }
    }
}
function displayItem() {
    // substitute new invoice HTML content into "modulecontent" div tag
    var div = document.getElementById("regioncontent");
    div.innerHTML = "";
    div.innerHTML = moduleReq.responseText;

}