//-------------------------------------------------------------------------------------
// Contains JavaScript specific to creating a "cloak" over all objects behind a  
// target object, typically and iframe or div container. Cloaking is typically used to 
// simulate a "modal" presentation of any information typical for desktop applications.
//-------------------------------------------------------------------------------------

var moCloakTarget = null;	//This points to the container to be cloaked.
var moCloak = null;			//Points to the cloaking object. 

//-------------------------------------------------------------------------------------
// Returns visibility status of this foatiframe/dialog. 
//-------------------------------------------------------------------------------------
function CloakIsVisible() {

	return (moCloak.style.visibility == "visible") ? true : false;
}

//-------------------------------------------------------------------------------------
// Hides cloak (used to prevent incidental clicks on objects/elements).
//-------------------------------------------------------------------------------------
function HideCloak(sCloakID) {

    try {
		moCloak.style.visibility = "hidden";
    }
    catch(e) {
        //Do nothing
    }
}

//-------------------------------------------------------------------------------------
// Covers ("cloaks") target area to prevent incidental clicks on objects/elements.
//-------------------------------------------------------------------------------------
function ShowCloak(sCloakTarget, zIndex, sUniqueCloakID) {

    var bIE = (navigator.appName.toString().indexOf("Explorer") > 0) ? true : false;

    //moCloakTarget = window.frameElement.document.getElementById(sCloakTarget);
    moCloakTarget = parent.window.document.getElementById(sCloakTarget);

    var iTop = moCloakTarget.offsetTop;

    var sCloakID = (sUniqueCloakID) ? sUniqueCloakID : "Cloaker";
    
    //If not already present, create the cloaking object/element.
    if (!moCloak) 
    {
        oCloak = document.createElement("DIV");
        oCloak.id = sCloakID;
		oCloak.style.position	= "absolute";
        oCloak.style.zIndex		= zIndex;
		oCloak.style.background	= "rgb(140,140,140)";
		oCloak.style.filter		= "progid:DXImageTransform.Microsoft.Alpha(opacity=60,style=0)";
		oCloak.style.opacity	= "0.6";
		oCloak.style.visibility	= "hidden";
        oCloak.style.left		= moCloakTarget.offsetLeft;
        oCloak.style.top		= iTop + "px";
        oCloak.style.width		= moCloakTarget.offsetWidth;
        oCloak.style.height		= moCloakTarget.scrollHeight;

        try 
		{
		    //IE
			moCloakTarget.insertAdjacentElement("beforeEnd",oCloak);
			moCloak = moCloakTarget.children(sCloakID);
		}
		catch(e)
		{
			//FireFox
			moCloakTarget.appendChild(oCloak);
			moCloak = oCloak;
		}
    
	}

    moCloak.style.left	 = "0px";
    moCloak.style.left	 = moCloakTarget.offsetLeft + "px";
    moCloak.style.top	 = iTop + "px";
    moCloak.style.width	 = moCloakTarget.offsetWidth + "px";
    
    if (bIE) {
        var iHeight = (moCloakTarget.scrollHeight) ? moCloakTarget.scrollHeight : parent.window.document.offsetHeight;
        iHeight += 160; //Make it a little taller to account for footer
        moCloak.style.height = iHeight + "px";
    }
    else {
        try {
            var oFooter = parent.document.getElementById("copyright");
            var iHeight = oFooter.offsetTop + oFooter.offsetHeight + 110;
        }
        catch(e) {
            var iHeight = 800;
        }
        moCloak.style.height = iHeight + "px";
    }
        
    moCloak.style.visibility = "visible";  
    
    //Return object to caller.
    return moCloak;  

}
