﻿<!--// 
var isMac = false;
var isSafari = false;
var isFirefox = false;
var isMSIE = false;
var isMSIE6 = false;

if (navigator.userAgent.indexOf("Macintosh") != -1){
    isMac = true;
}

if (navigator.userAgent.indexOf("Safari") != -1){
	isSafari = true;
} else if (navigator.userAgent.indexOf("MSIE") != -1){
    isMSIE = true;
    if (navigator.userAgent.indexOf("MSIE 6.0") != -1){
	    isMSIE6 = true;
    }
} else if (navigator.userAgent.indexOf("Firefox") != -1){
	isFirefox = true;
}

function showModal(divID, showIt, hasShadow, scrollable){
    var modalDIV = document.getElementById(divID);
    if (modalDIV != null){
	    var anchorDIV = document.getElementsByTagName("BODY")[0];
	    var selectVisibility;
        if (showIt){
            modalDIV.style.display = "block";
            centerDPop(divID);
            selectVisibility = "hidden";
            if (!scrollable){
                document.documentElement.style.overflow = "hidden";
            }
	    } else {
            modalDIV.style.display = "none";
	        selectVisibility = "visible";
            if (isSafari){
				document.documentElement.style.overflow = "scroll";
			} else {
				document.documentElement.style.overflow = "auto";
			}
    	}
        if (hasShadow){
            showModalShadow(divID, showIt);
        }
        if (document.forms.length > 0){
	        for (var i = 0; i < document.forms[0].elements.length; i++){
    	        if (document.forms[0].elements[i].type == "select-one"){
	    	        //document.forms[0].elements[i].style.visibility = selectVisibility;
		        }
		    }
		}
    }
}

//Centering Functions
function getDPopIndent (popupDimension, isHeight){
	if (isHeight){
		if (window.innerHeight)
			return ((window.innerHeight - popupDimension) / 2);
		else if (window.document.documentElement && window.document.documentElement.clientHeight)
			return ((window.document.documentElement.clientHeight - popupDimension) /2 );
		else if (window.document.body.clientHeight)
			return ((window.document.body.clientHeight - popupDimension) / 2);
	} else {
		if (window.innerWidth)
			return ((window.innerWidth - popupDimension) / 2);
		else if (window.document.documentElement && window.document.documentElement.clientWidth)
			return ((window.document.documentElement.clientWidth - popupDimension) / 2);
		else if (window.document.body.clientWidth)
			return ((window.document.body.clientWidth - popupDimension) / 2);
	}
}

//Get coordinates for centering DHTML Popup
function getDPopCoords(popupWidth, popupHeight){
	var centerCoordinates = getDPopIndent(popupWidth, false) + ',' + getDPopIndent(popupHeight, true);
	return centerCoordinates;
}

function centerDPop(popID){
	var divPop = document.getElementById(popID);
	var anchorDIV = document.getElementsByTagName("BODY")[0];
	var coords = new String();
	coords = getDPopCoords(parseInt(divPop.offsetWidth), parseInt(divPop.offsetHeight)).toString().split(",");
	divPop.style.left = Math.round(parseInt(coords[0]) - (anchorDIV.offsetLeft)) + "px";
	if (!isSafari){
		divPop.style.top = Math.round((parseInt(coords[1]) - anchorDIV.offsetTop) + document.documentElement.scrollTop) + "px";
	} else {
		divPop.style.top = Math.round((parseInt(coords[1]) - anchorDIV.offsetTop) + document.body.scrollTop) + "px";
	}
}

function showModalShadow(divID, showIt){
	var anchorDIV = document.getElementsByTagName("BODY")[0];
	var divShadow = document.getElementById(divID + "Shadow");
	if (divShadow == null){
	    var writeDIV = document.createElement("div");
	    writeDIV.setAttribute("id", "" + divID + "Shadow");
	    anchorDIV.appendChild(writeDIV);
	    divShadow = document.getElementById(divID + "Shadow");
	    divShadow.className = "modalShadow";
        if (isMSIE){
            divShadow.style.width = "100%";
            divShadow.style.height = (anchorDIV.offsetHeight + 50) + "px";
	        divShadow.style.top = (0 - anchorDIV.offsetTop) + "px";
            divShadow.style.left = (0 - anchorDIV.offsetLeft) + "px";
        } 
        else {
            divShadow.style.width = "100%";
            divShadow.style.height = anchorDIV.clientHeight + "px";
	        divShadow.style.top = "0px";
            divShadow.style.left = "0px";
        }
    }
    if (showIt){
        divShadow.style.display = "block";
    } else {
        divShadow.style.display = "none";
	}
}
//-->
