// JavaScript Document
function openModalWindow(windowName) {
	
	    var verScroll=0;
		var div = $(windowName);
        var bgDiv = $('modalBackgroundDiv');
        var docDim = Element.getDimensions(document.body);
        //get the size of the window and calculate where the box should be placed
        var wDim = getBrowserWindowSize();
        var dDim = Element.getDimensions(div);
		    //modified for webapp 33
        	//var topHeight = (wDim.scroll + ((wDim.height - dDim.height) / 2));document.documentElement.clientWidth
			var topHeight = (wDim.scroll + ((document.documentElement.clientHeight - dDim.height) / 2));

			if((document.documentElement.clientHeight - dDim.height)<0 || topHeight<10){
				 topHeight =20;
                  verScroll=1;
			}
        	if(topHeight >= 0){
        		div.style.top = topHeight + 'px';
        	}else{
        		div.style.top = '0px';
        	}

         div.style.left = ((wDim.width - dDim.width) / 2) + 'px';
      
        if (docDim.height > wDim.height) {
            wDim.height = docDim.height;
        }
        
        if(navigator.appName.indexOf("Microsoft")>=0){
		  
			if(parseInt(wDim.width-document.documentElement.clientWidth)>parseInt(21)){
				 bgDiv.style.width = wDim.width + 'px';
			}else{
				bgDiv.style.width = document.documentElement.clientWidth + 'px';
			}
		}else{
			bgDiv.style.width = wDim.width-parseInt(18) + 'px';
        }
		bgDiv.style.height = (getTotalWinHeight()+20) + 'px';
        Element.show(div);
        Element.show(bgDiv);
		if(verScroll==1)
        window.scroll((screen.width-document.documentElement.clientWidth)/2, 0);
		else
			 window.scroll((screen.width-document.documentElement.clientWidth)/2, wDim.scroll);
}      

function loadNewWindow(windowName,height)
{
	var bgDiv = $(windowName);
	var wDim = getBrowserWindowSize();
	if(wDim.width == 0)
		wDim.width = 1024;
	bgDiv.style.width = wDim.width + 'px';
    bgDiv.style.height = height + 'px';


    Element.show(bgDiv);
}

function loadWindow(windowName)
{
	var bgDiv = $(windowName);
	var wDim = getBrowserWindowSize();
	//bgDiv.style.width = wDim.width + 'px';
     bgDiv.style.height = getTotalWinHeight() + 'px';
    Element.show(bgDiv);
}

function closeModalWindowB(windowName)
{
	Element.hide(windowName);
}

function closeModalWindow(windowName) {
    Element.hide(windowName);
    Element.hide('modalBackgroundDiv');
}
function closeModalWindow_1(windowName) {
	   Element.hide(windowName);
	   setTimeout("sendToHTTP('dashboard')", 0)
	  
}

function getBrowserWindowSize() {
    var winW = 630, winH = 460, winS = 0;

    if (parseInt(navigator.appVersion)>3) {
        if (navigator.appName=="Netscape") {
            winW = window.innerWidth;
            winH = window.innerHeight ;
            winS = window.pageYOffset;
        }
        if (navigator.appName.indexOf("Microsoft")!=-1) {
            winW = document.documentElement.clientWidth;
            winH = document.documentElement.clientHeight;
            winS = document.documentElement.scrollTop; 
        }
    }

    var rval = {
    //modified for overlays problem(webapp-33)
        width: screen.width,
        height: screen.height,
        scroll: winS
    };

    return rval;
}
function getTotalWinHeight() {
    var wDimHeight = getBrowserWindowSize().height;
	var docDimHeight = Element.getDimensions(document.body).height;
    if (docDimHeight > wDimHeight) {
    	wDimHeight = docDimHeight;
    }
    return wDimHeight;
}