
/* LiClick, used in TopMenu to make whole LI area clickable. */
function LiClick(li) {
    var liObj = getObj(li);
    if (liObj && liObj.click) // Firefox doesn't have click().
    {
        getObj(liObj.getElementsByTagName('a')[0]).click();
    }
}


/* General functions for showing and hiding popups */

var controlTimerID = 0;
var shownControl = null;
var popupReady = true;

function ShowControl(control, left, top, time) {
    controlObj = getObj(control);
    if (left) {
        controlObj.setLeft(left);
    }
    if (top) {
        controlObj.setTop(top);
    }
    if (shownControl && shownControl != control) {
        HideControl(shownControl);
    }
    controlObj.show();
    shownControl = control;
    controlTimerID = setTimeout('HideControl(\'' + control + '\')', (time ? time : 1000));
}

function SetHideTimeout(event, control, time) {
    if (shownControl == control) {
        ClearHideTimeout();
        offsetX = event.offsetX ? event.offsetX : event.pageX;
        offsetY = event.offsetY ? event.offsetY : event.pageY;
        controlObj = getObj(control);
        if (offsetX < controlObj.getPageLeft() || offsetX > (controlObj.getPageLeft() + controlObj.getWidth()) || offsetY < controlObj.getPageTop() || offsetY > (controlObj.getPageTop() + controlObj.getHeight())) {
            controlTimerID = setTimeout('HideControl(\'' + control + '\')', (time ? time : 1000));
        }
    }
}

function ClearHideTimeout() {
    if (controlTimerID != 0) {
        clearTimeout(controlTimerID);
        controlTimerID = 0;
    }
}

function HideControl(control) {
    if (controlTimerID != 0) {
        clearTimeout(controlTimerID);
        controlTimerID = 0;
    }
    if (shownControl == control) {
        clearTimeout(controlTimerID);
        controlTimerID = 0;
    }
    getObj(control).hide();
}


/* Top popups */

function ShowTopPopup(popupControl, callerControl) {
    ShowControl(popupControl, getObj(callerControl).getPageLeft(), getObj(callerControl).getPageTop() + 20, 1000);
}


/* OurServicesConcept.aspx */

function ShowInfoPopup(popupControl, callerControl) {
    popupControlObj = getObj(popupControl);
    callerControlObj = getObj(callerControl);

    // A control only has a height when it's shown.
    popupControlObj.show();
    height = popupControlObj.getHeight();
    popupControlObj.hide();

    ShowControl(popupControl, callerControlObj.getPageLeft() + 100, callerControlObj.getPageTop() + 15 - height, 2000);
}

function SetPopupHTML(popupContentControl, contentControl) {
    getObj(popupContentControl).setInnerHTML(getObj(contentControl).getInnerHTML());
}