/**
 * Tools for AJAX pop-ups
 *
 */


/**
 * Generic three-part request
 */
var theDiv;
var topOffSet = 40;
var leftOffSet = 160;
var ajaxObj = new XMLHTTP('/index.php');
ajaxObj.debug = 0;

function getContent(app, action, target, e) {
    if (!e) e = window.event;
    ajaxObj.format = 'TEXT';
    //
	document.getElementById('messageTxt').innerHTML = "<h2 style=\"color: red;\">Loading ...</h2>";
    showHideDiv('show', e);
    ajaxObj.call('aJaxion=' + app + '&action=' + action + '&target=' + target, showResults);
    ajaxObj.restart();
}

function showResults(resp) {
	document.getElementById('messageTxt').innerHTML = resp;
}

function showHideDiv(mode, e) {
    var x;
    var y;
    theDiv = document.getElementById('messageBox');
    if (mode == 'show') {
        x = leftOffSet;
        if (window.scrollY) {
            y = window.scrollY + topOffSet;
        } else {
            // Handle ie6 oddness
            y = (document.documentElement.scrollTop ? document.documentElement.scrollTop :  document.body.scrollTop) + topOffSet;
        }
     	theDiv.style.left = x + 'px';
	    theDiv.style.top = y + 'px';
        theDiv.style.visibility = 'visible';
    } else {
          theDiv.style.visibility = 'hidden';
    }
}


