
// Javascript for map interaction

function context() {
  return location.pathname.substring(0, location.pathname.substring(1).indexOf("/") + 1);
}

function find(el) {
    return document.getElementById(el);
}

function defined(v) {
    return (typeof(v) != "undefined");
}

function loadIntoDiv(id, url) {
    var req = false;
    // For Safari, Firefox, and other non-MS browsers
    if (window.XMLHttpRequest) {
        try {
            req = new XMLHttpRequest();
        } catch (e) {
            req = false;
        }
    } else if (window.ActiveXObject) {
        // For Internet Explorer on Windows
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                req = false;
            }
        }
    }
    var element = find(id);
    if (!element) { // id not found. return.
        alert ("no id: " + id); // ***********************
        return;
    }
    if (req) {
        // Synchronous
        // do before
        req.open('GET', url, false);
        req.setRequestHeader( "Content-type", "text/html; charset=ISO-8859-1" );
        req.send(null);
        // do after
        element.innerHTML = req.responseText;
    } else {
        alert ("no ajax"); // ***********************
        return; // not ajax enable
    }
}
