﻿/*function revealModal(divID)
{
    window.onscroll = function () { document.getElementById(divID).style.top = document.body.scrollTop; };
    document.getElementById(divID).style.display = "block";
    document.getElementById(divID).style.top = document.body.scrollTop;
	var sels = document.getElementsByTagName('select');
	for(var i = 0; i < sels.length; i++)
	{
	sels[i].disabled = true;
	}
}

function hideModal(divID)
{
    document.getElementById(divID).style.display = "none";
	var sels = document.getElementsByTagName('select');
	for(var i = 0; i < sels.length; i++)
	{
	    sels[i].disabled = false;
	}
}
*/
var Geometry = {};

if (window.screenLeft === undefined) { // IE and others
    Geometry.getWindowX = function( ) { return window.screenLeft; };
    Geometry.getWindowY = function( ) { return window.screenTop; };
}
else if (window.screenX) { // Firefox and others
    Geometry.getWindowX = function( ) { return window.screenX; };
    Geometry.getWindowY = function( ) { return window.screenY; };
}

if (window.innerWidth) { // All browsers but IE
    Geometry.getViewportWidth = function( ) { return window.innerWidth; };
    Geometry.getViewportHeight = function( ) { return window.innerHeight; };
    Geometry.getHorizontalScroll = function( ) { return window.pageXOffset; };
    Geometry.getVerticalScroll = function( ) { return window.pageYOffset; };
}
else if (document.documentElement && document.documentElement.clientWidth) {
    // These functions are for IE 6 when there is a DOCTYPE
    Geometry.getViewportWidth =
        function( ) { return document.documentElement.clientWidth; };
    Geometry.getViewportHeight =
        function( ) { return document.documentElement.clientHeight; };
    Geometry.getHorizontalScroll =
        function( ) { return document.documentElement.scrollLeft; };
    Geometry.getVerticalScroll =
        function( ) { return document.documentElement.scrollTop; };
}
else if (document.body.clientWidth) {
    // These are for IE4, IE5, and IE6 without a DOCTYPE
    Geometry.getViewportWidth =
        function( ) { return document.body.clientWidth; };
    Geometry.getViewportHeight =
        function( ) { return document.body.clientHeight; };
    Geometry.getHorizontalScroll =
        function( ) { return document.body.scrollLeft; };
    Geometry.getVerticalScroll =
        function( ) { return document.body.scrollTop; };
}

// These functions return the size of the document. They are not window
// related, but they are useful to have here anyway.
if (document.documentElement && document.documentElement.scrollWidth) {
    Geometry.getDocumentWidth =
        function( ) { return document.documentElement.scrollWidth; };
    Geometry.getDocumentHeight =
        function( ) { return document.documentElement.scrollHeight; };
}
else if (document.body.scrollWidth) {
    Geometry.getDocumentWidth =
        function( ) { return document.body.scrollWidth; };
    Geometry.getDocumentHeight =
        function( ) { return document.body.scrollHeight; };
}

var ModalWindowObj = {
    Show: function(id, width)
    {
        this.contentIDs.push(id);
        
        if($J("#modalWindow").length == 0)
        {
            $J("body").prepend("<div id='modalContent'><div id='divInnerContent'></div><!--[if lte IE 6.5]><iframe></iframe><![endif]--></div>");
            $J("body").prepend("<div id='modalWindow'></div>");
        }
        
        this.lastContentID = '#' + id;
		$J(this.lastContentID).appendTo("#divInnerContent");
        
        var top = this.getTop($J(this.lastContentID).height());
	    var left = this.getLeft($J(this.lastContentID).width());
    	
	    $J("#modalContent").css({"left":left, "top":top});
        
        $J("#modalWindow").height(Geometry.getDocumentHeight()).show();
                 
        $J(this.lastContentID).show();	    
	    
	    $J("select[DisableIgnore!='true']").attr("disabled", "true");
	    $J(this.lastContentID + " select").attr("disabled", "");
   },
    Hide: function(ModalID_arg)
    {        
        var lastID = this.contentIDs.pop();
        if(this.contentIDs.length == 0)
        {
            $J("#modalWindow").hide();
            $J("select[DisableIgnore!='true']").attr("disabled", "");
        }
        else
        {            
            var LL = this.contentIDs.pop()
            this.contentIDs.push(LL);            
            $J("#" + LL + " select").attr("disabled", "");
        }

        $J("body").append($J("#"+lastID).hide()); 
    },
    contentIDs: new Array(),
    lastContentID: null,
    getLeft: function(width)
    {
        return (Geometry.getDocumentWidth() - width) / 2;
    },
    getTop: function(height)
    {
     /*
        //calculate position
        var x,y; 
        if (self.innerHeight) // all except Explorer 
        { 
            x = self.innerWidth; 
            y = self.innerHeight; 
        } 
        else if (document.documentElement 
            && document.documentElement.clientHeight) // Explorer 6 Strict Mode 
        { 
            x = document.documentElement.clientWidth; 
            y = document.documentElement.clientHeight; 
        } 
        else if (document.body) // other Explorers 
        { 
            x = document.body.clientWidth; 
            y = document.body.clientHeight; 
        }
    */  
        return (Geometry.getViewportHeight() - height) / 2;
    }
};