// find the possition on the screen for given object
function findPos(_obj) {
    obj = _obj; // get a local copy of the object, thus preventing _obj getting corrupted

    // init varibles that we're going to use
    var curLeft = 0, curRight = 0, curTop = 0, curBot = 0, curWidth = _obj.width, curHeight = _obj.height;

    if (curWidth == undefined) curWidth = _obj.offsetWidth;
    if (curHeight == undefined) curHeight = _obj.offsetHeight;

    if (obj.offsetParent)
    {
        do
        {
            curLeft += obj.offsetLeft;
            curTop += obj.offsetTop;
            obj = obj.offsetParent;
        } while (obj);
    }
    else
    {
        curLeft += obj.offsetLeft;
        curTop += obj.offsetTop;
    }

    curBot = curTop + curHeight;
    curRight = curLeft + curWidth;

    return {
        left:curLeft,
        right:curRight,
        top:curTop,
        bot:curBot,
        width:curWidth,
        height:curHeight
    };
}

// ajax varibles
var ajaxHandel = null;
var ajaxStoredCallback = null;

// load to ajax data and insert into the innerHTML property of _frame
// _url the url of the page to load
// _loadTo where the data from _url is loaded into
// _callback the callback once the the url has successfully loaded
function runAjax(_url, _callback)
{
    // get an ajax handel
    ajaxHandel = getAjaxObject();
    if (ajaxHandel == null)
    {
        alert ("Your browser does not support XMLHTTP! Please check your security settings or upgrade your browzer");
        return;
    }
    // store the loadTo location and the callback function
    ajaxStoredCallback = _callback;

    // setup and send the ajax request
    ajaxHandel.onreadystatechange = ajaxCallback;
    ajaxHandel.open("GET",_url,true);
    ajaxHandel.send(null);
}
function ajaxCallback()
{
    if (ajaxHandel.readyState==4)
    {
        if (ajaxHandel.status==200)
            ajaxStoredCallback(ajaxHandel.responseText);
        else
            alert("Problem retrieving page data:" + ajaxHandel.statusText);
    }
}
function getAjaxObject()
{
    if (window.XMLHttpRequest)// code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
    if (window.ActiveXObject)// code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
    return null;
}
