function ShowLightbox(id, width, height) {
	var pixelsScrolled = parseInt(document.documentElement.scrollTop);
	var clientInnerHeight = 0;
	var clientInnerWidth = 0;
	var newLightBoxTop = "";
	var newLightBoxLeft = "";
	
	// Handle default values
	if (typeof id == "undefined") id = "lightbox";
	
	// Determine the inside width of the client/browser window
	if (self.innerWidth) {
		clientInnerHeight = self.innerHeight;
		clientInnerWidth = self.innerWidth;
	} else if (document.documentElement.clientHeight) {
		clientInnerHeight = document.documentElement.clientHeight;
		clientInnerWidth = document.documentElement.clientWidth;
	} else if (document.body) {
		clientInnerHeight = document.body.clientHeight;
		clientInnerWidth = document.body.clientWidth;
	}
	
	// We have to unhide the elements before we calculate their sizes
	document.getElementById(id).style.display='block';
	document.getElementById('overlay').style.display='block';
	
	if (typeof height == "undefined") {
		// Height was not defined, so use the current height of the lightbox
		height = parseInt(document.getElementById(id).offsetHeight);
	} else {
		// Width was defined, so set the specified height
		document.getElementById(id).style.height = height+"px";
		height = parseInt(height);
	}
	
	if (typeof width == "undefined") {
		// Width was not defined, so use the current width of the lightbox
		width = parseInt(document.getElementById(id).offsetWidth);
	} else {
		// Width was defined, so set the specified width
		document.getElementById(id).style.width = width+"px";
		width = parseInt(width);
	}
	
	newLightBoxTop = Math.round((clientInnerHeight/2)-(height/2)+pixelsScrolled)+"px";
	newLightBoxLeft = Math.round((clientInnerWidth/2)-(width/2))+"px";
	
	// Move the top position of the lightbox to the vertical center of the screen.
	document.getElementById(id).style.top = newLightBoxTop;
	document.getElementById(id).style.left = newLightBoxLeft;
}

function HideLightbox(id) {
	// Handle default value
	if (typeof id == "undefined") id = "lightbox";
	var lightboxObj = document.getElementById(id);
	var overlayObj = document.getElementById("overlay");
	if (lightboxObj == null) {
		alert("lightboxObj null");
	} else {
		lightboxObj.style.display = "none";
	}

	if (overlayObj == null) {
		alert("overlayObj null");
	} else {
		overlayObj.style.display = "none";
	}

}

function HideListAreaUpdate(box, selbox)
{
    var valobj = document.getElementById(box+'_Values');
    var listboxobj = document.getElementById(selbox);
    var str = "";
    var btnstr = "<img class=\"getBtn\" name=\"getBtn"+box+"\" src=\"/images/pageIcons/getBtnUp.jpg\" onMouseover=\"this.src=getBtnON.src\" onMouseout=\"this.src=getBtnOff.src\" border=\"0\">";
    
    for(var i=0; i < listboxobj.length; ++i)
    {
        if(listboxobj.options[i].selected)
        {
            if(str.length > 0)
                str = str + ', ';
            str = str + listboxobj.options[i].text;
        }
    }
    HideLightbox(box);
    str = "<a href=\"javascript:ShowLightbox('"+box+"'); SetFocus('"+selbox+"');\">"+btnstr+"</a> " + str;
    valobj.innerHTML = str;
}

function HideCheckboxAreaUpdate(box, selbox)
{
    var valobj = document.getElementById(box+'_Values');
    var listboxobj = document.getElementById(selbox);
    var chkbxCount = listboxobj.getElementsByTagName("input");
    var str = "";
    
    for(var i=0; i < chkbxCount.length; ++i)
    {
        var checkBoxRef = chkbxCount[i];
        if(checkBoxRef.checked)
        {
            var labelArr = checkBoxRef.parentNode.getElementsByTagName("label");
            if(labelArr.length > 0)
            {
                if(str.length > 0)
                    str = str + ', ';
                str = str + labelArr[0].innerHTML;
            }
        }
    }
    HideLightbox(box);
    if(str == "")
        str = "&nbsp;";
    valobj.innerHTML = str;
}

function SetFocus(selbox)
{
    var listboxobj = document.getElementById(selbox);
    listboxobj.focus();
}

closeLBBtnON = new Image();
closeLBBtnON.src="/images/CloseWin_roll.jpg";
closeLBBtnOff = new Image();
closeLBBtnOff.src="/images/CloseWin_norm.jpg";

