
var gPopupMask=null;
var gPopupContainer=null;
var gPopFrame=null;
var gPopMessage=null;
var gReturnFunc;
var gPopupIsShown=false;
var gDefaultPage="/5.5.00.22180/AgentWebPage/Consumer/ModalDialog/loading.html";
var g_sModalError="Modal Dialog Error.";
var ModalDialogStyle=
{
TITLE:1,
CLOSE:2
};
var gTabIndexes=new Array();
var gTabbableTags=new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME");
var g_objBrowser=new BrowserInfo();
var g_bIsIE=(g_objBrowser.Type==BrowserType.IE);
var g_bIsOldIE=(g_bIsIE&&(g_objBrowser.Version<=8));
try
{
addEvent(document,"keypress",onKeyPress);
addEvent(document,"mousedown",onMouseClick);
if(g_bIsOldIE)
{
addEvent(document,"contextmenu",onMouseClick);
}
else
{
document.oncontextmenu=onMouseClick;
}
addEvent(window,"load",initPopUp);
addEvent(window,"resize",centerPopWin);
addEvent(window,"scroll",centerPopWin);
}
catch(e)
{
DisplayErrorDialog(g_sModalError,e,"SubModal.js","");
}
function initPopUp()
{
try
{
if(typeof(theBody)=="undefined")
{
theBody=document.getElementsByTagName('BODY')[0];
}
popmask=document.createElement('div');
popmask.id='popupMask';
popcont=document.createElement('div');
popcont.id='popupContainer';
popcont.innerHTML=''+
'<div id="popupInner">'+
'<div id="popupTitleBar" class="popupTitleBarVisible">'+
'<div id="popupTitle"></div>'+
'<div id="popupControls">'+
'<img src="/5.5.00.22180/AgentWebPage/Consumer/ModalDialog/close.gif" onclick="hidePopWin(false);" id="popCloseBox" />'+
'</div>'+
'</div>'+
'<a id="popoutCloseBtn" title="close" href="javascript:hidePopWin(false);"></a>'+
'<div id="popupMessageBar" onClick="hideMessage();">'+
'</div>'+
'<iframe src="'+gDefaultPage+'" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame"></iframe>'+
'</div>';
theBody.appendChild(popmask);
theBody.appendChild(popcont);
gPopupMask=document.getElementById("popupMask");
gPopupContainer=document.getElementById("popupContainer");
gPopFrame=document.getElementById("popupFrame");
gPopMessageBar=document.getElementById("popupMessageBar");
}
catch(e)
{
DisplayErrorDialog(g_sModalError,e,"SubModal.js","initPopUp");
}
}
function showPopWin(url,width,height,returnFunc,p_iDialogStyle)
{
try
{
var titleBarHeight=0;
if(null==p_iDialogStyle||0==p_iDialogStyle)
{
p_iDialogStyle=ModalDialogStyle.TITLE|ModalDialogStyle.CLOSE;
}
if(p_iDialogStyle&ModalDialogStyle.TITLE&&p_iDialogStyle&ModalDialogStyle.CLOSE)
{
document.getElementById("popupTitleBar").className="popupTitleBarVisible";
document.getElementById("popCloseBox").style.display="block";
document.getElementById("popoutCloseBtn").style.display="none";
titleBarHeight=parseInt(document.getElementById("popupTitleBar").offsetHeight,10);
}
else if(p_iDialogStyle&ModalDialogStyle.TITLE)
{
document.getElementById("popupTitleBar").className="popupTitleBarVisible";
document.getElementById("popCloseBox").style.display="none";
document.getElementById("popoutCloseBtn").style.display="none";
titleBarHeight=parseInt(document.getElementById("popupTitleBar").offsetHeight,10);
}
else if(p_iDialogStyle&ModalDialogStyle.CLOSE)
{
document.getElementById("popupTitleBar").className="popupTitleBarHidden";
document.getElementById("popCloseBox").style.display="none";
document.getElementById("popoutCloseBtn").style.display="inline";
titleBarHeight=0;
}
gPopupIsShown=true;
disableTabIndexes();
gPopupMask.style.display="block";
gPopupContainer.style.display="block";
hideMessage();
centerPopWin(width,height);
var messageBarHeight=parseInt(document.getElementById("popupMessageBar").offsetHeight,10);
gPopupContainer.style.width=width+"px";
gPopupContainer.style.height=(height+titleBarHeight+messageBarHeight)+"px";
setMaskSize();
gPopFrame.style.width=parseInt(document.getElementById("popupTitleBar").offsetWidth,10)+"px";
gPopFrame.style.height=(height)+"px";
gPopFrame.src=url;
gReturnFunc=returnFunc;
hideSelectBoxes();
gPopFrame.focus();
window.setTimeout("setPopTitle();",600);
}
catch(e)
{
ThrowModalError(e,"SubModal.js","showPopWin");
}
}
function centerPopWin(width,height)
{
try
{
if(gPopupIsShown==true)
{
if(width==null||isNaN(width))
{
width=gPopupContainer.offsetWidth;
}
if(height==null)
{
height=gPopupContainer.offsetHeight;
}
var theBody=document.getElementsByTagName("BODY")[0];
var scTop=parseInt(getScrollTop(),10);
var scLeft=parseInt(theBody.scrollLeft,10);
setMaskSize();
var titleBarHeight=parseInt(document.getElementById("popupTitleBar").offsetHeight,10);
var messageBarHeight=parseInt(document.getElementById("popupMessageBar").offsetHeight,10);
var fullHeight=getViewportHeight();
var fullWidth=getViewportWidth();
gPopupContainer.style.top=(scTop+((fullHeight-(height+titleBarHeight+messageBarHeight))/2))+"px";
gPopupContainer.style.left=(scLeft+((fullWidth-width)/2))+"px";
}
}
catch(e)
{
ThrowModalError(e,"SubModal.js","centerPopWin");
}
}
function setMaskSize()
{
try
{
var theBody=document.getElementsByTagName("BODY")[0];
var fullHeight=getViewportHeight();
var fullWidth=getViewportWidth();
if(fullHeight>theBody.scrollHeight)
{
popHeight=fullHeight;
}
else
{
popHeight=theBody.scrollHeight;
}
if(fullWidth>theBody.scrollWidth)
{
popWidth=fullWidth;
}
else
{
popWidth=theBody.scrollWidth;
}
gPopupMask.style.height=popHeight+"px";
gPopupMask.style.width=popWidth+"px";
}
catch(e)
{
ThrowModalError(e,"SubModal.js","setMaskSize");
}
}
function hidePopWin(callReturnFunc)
{
try
{
gPopupIsShown=false;
var theBody=document.getElementsByTagName("BODY")[0];
theBody.style.overflow="";
restoreTabIndexes();
if(gPopupMask==null)
{
return;
}
gPopupMask.style.display="none";
gPopupContainer.style.display="none";
if(callReturnFunc==true&&gReturnFunc!=null)
{
window.setTimeout('gReturnFunc();',1);
}
gPopFrame.src=gDefaultPage;
displaySelectBoxes();
}
catch(e)
{
DisplayErrorDialog(g_sModalError,e,"SubModal.js","hidePopWin");
}
}
function setPopTitle()
{
try
{
if(window.frames["popupFrame"].document.title==null)
{
window.setTimeout("setPopTitle();",10);
}
else
{
document.getElementById("popupTitle").innerHTML=window.frames["popupFrame"].document.title;
}
}
catch(e)
{
}
}
function onKeyPress(e)
{
try
{
if(gPopupIsShown&&(e.keyCode==9||e.keyCode==32))
{
return false;
}
}
catch(e)
{
ThrowModalError(e,"SubModal.js","onKeyPress");
}
}
function onMouseClick(e)
{
try
{
if(gPopupIsShown)
{
var cancelEvent=true;
var element=((e.srcElement!=null)?e.srcElement:e.target);
while(element!=null)
{
if(element.id=="popupContainer")
{
cancelEvent=false;
break;
}
element=element.parentNode;
}
if(cancelEvent)
{
return false;
}
}
}
catch(e)
{
ThrowModalError(e,"SubModal.js","onMouseClick");
}
}
function disableTabIndexes()
{
try
{
var i=0;
for(var j=0;j<gTabbableTags.length;j++)
{
var tagElements=document.getElementsByTagName(gTabbableTags[j]);
for(var k=0;k<tagElements.length;k++)
{
gTabIndexes[i]=tagElements[k].tabIndex;
tagElements[k].tabIndex="-1";
i++;
}
}
}
catch(e)
{
ThrowModalError(e,"SubModal.js","disableTabIndexes");
}
}
function restoreTabIndexes()
{
try
{
var i=0;
for(var j=0;j<gTabbableTags.length;j++)
{
var tagElements=document.getElementsByTagName(gTabbableTags[j]);
for(var k=0;k<tagElements.length;k++)
{
tagElements[k].tabIndex=gTabIndexes[i];
tagElements[k].tabEnabled=true;
i++;
}
}
}
catch(e)
{
ThrowModalError(e,"SubModal.js","restoreTabIndexes");
}
}
function hideSelectBoxes()
{
try
{
var x=document.getElementsByTagName("SELECT");
for(i=0;x&&i<x.length;i++)
{
x[i].style.visibility="hidden";
}
}
catch(e)
{
ThrowModalError(e,"SubModal.js","hideSelectBoxes");
}
}
function displaySelectBoxes()
{
try
{
var x=document.getElementsByTagName("SELECT");
for(i=0;x&&i<x.length;i++)
{
x[i].style.visibility="visible";
}
}
catch(e)
{
ThrowModalError(e,"SubModal.js","displaySelectBoxes");
}
}
function showMessage(message)
{
try
{
gPopMessageBar.innerHTML=message;
gPopMessageBar.className="popupMessageBar popupMessageBarShown";
}
catch(e)
{
ThrowModalError(e,"SubModal.js","showMessage");
}
}
function hideMessage()
{
try
{
gPopMessageBar.innerHTML="";
gPopMessageBar.className="popupMessageBar popupMessageBarHidden";
}
catch(e)
{
ThrowModalError(e,"SubModal.js","hideMessage");
}
}
function ThrowModalError(p_objError,p_sPageName,p_sFunctionName)
{
hidePopWin(false);
if(p_objError!=null)
{
if(!p_objError.description)
{
p_objError.description=p_objError.message;
}
p_objError.description=p_sPageName+" - "+p_sFunctionName+" exception: "+p_objError.description;
var sLogMsg=p_objError.description;
throw new Error(p_objError.number,sLogMsg);
}
}
function addEvent(obj,evType,fn)
{
try
{
if(obj.addEventListener)
{
obj.addEventListener(evType,fn,false);
return true;
}
else
{
if(obj.attachEvent)
{
if(evType=="load")
{
document.onreadystatechange=function(){if(document.readyState=="complete"){fn();}};
return true;
}
else
{
var r=obj.attachEvent("on"+evType,fn);
return r;
}
}
else
{
return false;
}
}
}
catch(e)
{
ThrowModalError(e,"SubModal.js","addEvent");
}
}
function removeEvent(obj,evType,fn,useCapture)
{
try
{
if(obj.removeEventListener)
{
obj.removeEventListener(evType,fn,useCapture);
return true;
}
else if(obj.detachEvent)
{
var r=obj.detachEvent("on"+evType,fn);
return r;
}
else
{
alert("Handler could not be removed");
}
}
catch(e)
{
ThrowModalError(e,"SubModal.js","removeEvent");
}
}
function getViewportHeight()
{
try
{
if(window.innerHeight!=window.undefined)return window.innerHeight;
if(document.compatMode=='CSS1Compat')return document.documentElement.clientHeight;
if(document.body)return document.body.clientHeight;
}
catch(e)
{
ThrowModalError(e,"SubModal.js","getViewportHeight");
}
return window.undefined;
}
function getViewportWidth()
{
try
{
var offset=17;
var width=null;
if(window.innerWidth!=window.undefined)return window.innerWidth;
if(document.compatMode=='CSS1Compat')return document.documentElement.clientWidth;
if(document.body)return document.body.clientWidth;
}
catch(e)
{
ThrowModalError(e,"SubModal.js","getViewportWidth");
}
}
function getScrollTop()
{
try
{
if(self.pageYOffset)
{
return self.pageYOffset;
}
else if(document.documentElement&&document.documentElement.scrollTop)
{
return document.documentElement.scrollTop;
}
else if(document.body)
{
return document.body.scrollTop;
}
}
catch(e)
{
ThrowModalError(e,"SubModal.js","getScrollTop");
}
}
function getScrollLeft()
{
try
{
if(self.pageXOffset)
{
return self.pageXOffset;
}
else if(document.documentElement&&document.documentElement.scrollLeft)
{
return document.documentElement.scrollLeft;
}
else if(document.body)
{
return document.body.scrollLeft;
}
}
catch(e)
{
ThrowModalError(e,"SubModal.js","getScrollLeft");
}
}


