// construct base urls based on live link object path (here: path to folder containing getfile.jsp and merklisten_controller.jsp)
// contructs absolute path for httpurlconnection's url and a relative path to getfile.jsp for javascript
url_rel = "/web/js/vmportal.js";
xend_rel = url_rel.lastIndexOf("/") + 1;
var base_url_rel = url_rel.substring(0, xend_rel);

url_abs = "http://cmsextp2-max/web/js/vmportal.js";
xend_abs = url_abs.lastIndexOf("/") + 1;
var base_url_abs = url_abs.substring(0, xend_abs);

function ajax_do (url) {

        // Does URL begin with http?
        url = base_url_rel + url;
	
	//debug url
	//alert("url:" + url);
	
        // Create new JS element
        var jsel = document.createElement('SCRIPT');
        jsel.type = 'text/javascript';
        jsel.src = url;

        // Append JS element (therefore executing the 'AJAX' call)
        document.body.appendChild (jsel);
}

function ajax_get (url, el) {
        // Has element been passed as object or id-string?
        if (typeof(el) == 'string') {
                el = document.getElementById(el);
        }

        // Valid el?
        if (el == null) { return false; }

        // Does URL begin with http?
        url = base_url_abs + url;
        //}
        

        // Create getfile URL
        getfile_url = 'getfile.jsp?url=' + escape(url) + '&el=' + escape(el.id);
        
        //debug getfile url
        //alert("getfile_url: " + getfile_url);
		
		
        // Do Ajax
        ajax_do (getfile_url);

        return true;
}
