/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    le.ui.js - core UI objects (widgets, components, etc.)

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/

/*=========================================
    
    Shows an error popup
    
    message - The message in an HTML string
    
=========================================*/
function showErrorPopup(message) {
    var errorPopup = document.getElementById("popError");
    var errorText = document.getElementById("popErrorMessage");
    var errorButton = document.getElementById("popErrorButton").getElementsByTagName("img")[0];
    errorButton.onclick = function () {
        hide(errorPopup);
        hide(document.getElementById(errorPopup.id + "Mask"));
    };
    errorText.innerHTML = message;
    show(document.getElementById(errorPopup.id + "Mask"))
    show(errorPopup);
    movePopupLayer(errorPopup);
}

/*===================================================

    Moves the error popup to the middle of the screen
    and keeps it there.

===================================================*/
function movePopupLayer(divToMove) {
    var myWidth = 0;
    var myHeight = 0;
    var myScrollY = 0;
    // the IFRAME that is used for the mask should be named somethingMask (i.e., popErrorMask)
    var maskObject = document.getElementById(divToMove.id + "Mask");
    
    if (typeof (window.innerWidth) == "number") {
		//Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else {
        if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        } else {
            if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
            //IE 4 compatible
                myWidth = document.body.clientWidth;
                myHeight = document.body.clientHeight;
            }
        }
    }
    
    // Find out how far the user has scrolled in order to position the div at the correct height
    if (window.pageYOffset) {
        myScrollY = window.pageYOffset;
    } else if (document.body.scrollTop && document.body.scrollTop > 0) {
        myScrollY = document.body.scrollTop;
    } else if (document.documentElement.scrollTop && document.documentElement.scrollTop > 0) {
        myScrollY = document.documentElement.scrollTop;
    }
    
    divToMove.style.left = Math.round(myWidth / 2 - divToMove.offsetWidth / 2) + "px";
    divToMove.style.top = Math.round((myHeight / 2 - divToMove.offsetHeight / 2) + myScrollY) + "px";
    applyLayerMask(divToMove, maskObject);
    show(maskObject);
}

/*===========================================================================

    This is a fix for MS IE 5.5+ where form elements punch through all layers
    of divs that cover them.  The applyLayerMask moves an IFRAME between the
    layers and the form elements to prevent the punch-through. Since this
    doesn't break on any other browsers, it's used for all popup layers. I
    don't like branching code based on browser quirks.

    divToMask - the layer having the problem
    maskObject - the IFRAME object used to fix the problem
    
============================================================================*/
function applyLayerMask(divToMask, maskObject) {
    maskObject.style.position = "absolute";
    maskObject.style.top = divToMask.offsetTop;
    maskObject.style.left = divToMask.offsetLeft;
    maskObject.style.height = divToMask.offsetHeight + "px";
    maskObject.style.width = divToMask.offsetWidth + "px";
}

function fixLivePerson(){
    try{
        var tempObject=document.getElementById("myLayer");
        var maskObject=document.getElementById("livePersonMask");
        
        applyLayerMask(tempObject, maskObject);
    }
    catch(exception){
        
    }
    var t=setTimeout("fixLivePerson()",60);
}