
function OpenPopupWindow(url,height,width){
    var popupWindow = document.getElementById("popupWindow");
    if(popupWindow)return;
    
    var dde = document.documentElement;
    var windowWidth; var windowHeight; var scrollLeft; var scrollTop; 
       
    if (window.innerWidth){    
        windowWidth = window.innerWidth;    
        windowHeight = window.innerHeight;    
        scrollLeft = window.pageXOffset;    
        scrollTop = window.pageYOffset;
    }else{    
        windowWidth = dde.offsetWidth;    
        windowHeight = dde.offsetHeight;    
        scrollLeft = dde.scrollLeft;    
        scrollTop = dde.scrollTop;    
    }    
	var popupWin = document.createElement("div");
	popupWin.id = "popupWindow";
	popupWin.className = "popupWindow";
	popupWin.style.width = width + "px";
	popupWin.style.height = height + "px";	
	popupWin.style.display = "";
	popupWin.style.left = (screen.width - width-20)/2 + "px";
	popupWin.style.top = scrollTop + ((windowHeight - height)/2+30) + "px";
	GenerateConsoleBar(popupWin,'');
	GenerateBodyPanel(popupWin, url);
	document.body.appendChild(popupWin);
	
}
function GenerateConsoleBar(obj,winName) {

	var html = "<div style=\"text-align:right;height:20px;background-color:#fff;\">";
	html += "<a href=\"javascript:ClosePopupWindow();HideScreenIframe();\" title=\"Close\"><img src=\"Images/close.gif\" border=\"0\"  style=\"padding:5px;\"/></a></div>";
	obj.innerHTML += html;
}
function ClosePopupWindow() {
	var popupWin = parent.document.getElementById("popupWindow");
	parent.document.body.removeChild(popupWin);
}

function GenerateBodyPanel(obj,src) {
	var html = "<IFrame name=\"bodyPanel\" id=\"bodyPanel\" src=\""+src+"\" FrameBorder=\"0\" Scrolling=\"no\" class=\"bodyPanel\"></IFrame>";
	obj.innerHTML += html;
}
//open popup in popupwindow
function OpenPopupInPopup(url,height,width){
   var popupWindow = document.getElementById("PopupInPopup");
    if(popupWindow)return;
    
    var dde = document.documentElement;
    var windowWidth; var windowHeight; var scrollLeft; var scrollTop; 
       
    if (window.innerWidth){    
        windowWidth = window.innerWidth;    
        windowHeight = window.innerHeight;    
        scrollLeft = window.pageXOffset;    
        scrollTop = window.pageYOffset;
    }else{    
        windowWidth = dde.offsetWidth;    
        windowHeight = dde.offsetHeight;    
        scrollLeft = dde.scrollLeft;    
        scrollTop = dde.scrollTop;    
    }  
	var popupWin = document.createElement("div");
	popupWin.id = "PopupInPopup";
	popupWin.className = "popupWindow";
	popupWin.style.width = width + "px";
	popupWin.style.height = height + "px";	
	popupWin.style.display = "";

	GenerateConsoleBarInPopup(popupWin,'');
	GenerateBodyPanel(popupWin, url);
	document.body.appendChild(popupWin);
	
}
function GenerateConsoleBarInPopup(obj,winName) {

	var html = "<div style=\"text-align:right;height:20px;background-color:#fff;\">";
	html += "<a href=\"javascript:ClosePopupInPopup();HideScreenIframe();\" title=\"Close\"><img src=\"Images/close.gif\" border=\"0\"  style=\"padding:5px;\"/></a></div>";
	obj.innerHTML += html;
}
function ClosePopupInPopup() {
	var popupWin = document.getElementById("PopupInPopup");
	document.body.removeChild(popupWin);
}

function ShowScreenIframe(){
    var screenIframe = document.getElementById("screenIframe");
   
    if(screenIframe){
        screenIframe.style.width = document.body.clientWidth;
        screenIframe.style.height = document.body.clientHeight;
        screenIframe.style.top = 0;
        screenIframe.style.left = 0;
    }   
 }

function HideScreenIframe(){    
    var screenIframe = document.getElementById("screenIframe");
 
    if(screenIframe){
        screenIframe.style.width = 0;
        screenIframe.style.height = 0;
        screenIframe.style.top = 0;
        screenIframe.style.left = 0;
    }
 } 

function ShowModalDialogPage(url,width,height)
{      
    var x = parseInt(screen.width / 2.0) - (width / 2.0);  
    var y = parseInt(screen.height / 2.0) - (height / 2.0); 
    var isMSIE= (navigator.appName == "Microsoft Internet Explorer");  
    if (isMSIE) {           
        retval = window.showModalDialog(url, window, "dialogWidth:"+width+"px; dialogHeight:"+height+"px; dialogLeft:"+x+"px; dialogTop:"+y+"px; status:no; directories:yes;scrollbars:no;Resizable=no; "  ); 
       } else { 
        var win = window.open(url, "Warehouse", "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,modal=yes,dependance=yes,width=" + width + ",height=" + height + ",resizable=no" ); 
        eval('try { win.resizeTo(width, height); } catch(e) { }'); 
        win.focus();             
    } 
}
function CloseWindow(){
    window.close();
} 

