var gPopupMask = null;var gPopupContainer = null;var gPopFrame = null;var gReturnFunc;var gPopupIsShown = false;
var gHideSelects = false;var CanRedirect=true;var Xminus=0;
var gTabIndexes = new Array();
// Pre-defined list of tags we want to disable/enable tabbing into
var gTabbableTags = new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME");	
// If using Mozilla or Firefox, use Tab-key trap.
if (!document.all) {document.onkeypress = keyDownHandler;}

/**
 * Initializes popup code on load.	
 */
function initPopUp(_Xminus) {if (_Xminus && _Xminus!=null  && _Xminus!='undefined' && _Xminus!="NaN") Xminus=_Xminus; else Xminus=0;
gPopupMask = document.getElementById("popupMask");gPopupContainer = document.getElementById("popupContainer");gPopFrame = document.getElementById("popupFrame");
var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {gHideSelects = true;}}

var CalculatePOPUPx=false;var CalculatePOPUPy=false;

function showPopWin(url, width, height, returnFunc,redirectable) {gPopupIsShown = true;disableTabIndexes();
try {gPopupMask.style.display = "block";gPopupContainer.style.display = "block";} catch (e) {initPopUp();gPopupMask.style.display = "block";	gPopupContainer.style.display = "block";}
var _x=0;var _y=0;if (redirectable!=null && redirectable!='undefined') CanRedirect=redirectable; else CanRedirect=false;
if (self.innerHeight){_x = removePX(self.innerWidth);_y = removePX(self.innerHeight);}
else if (document.documentElement && document.documentElement.clientHeight){_x = removePX(document.documentElement.clientWidth);
_y = removePX(document.documentElement.clientHeight);}	else if (document.body)
{_x = removePX(document.body.clientWidth);	_y = removePX(document.body.clientHeight);}
if (width==null || width==0) {width=parseInt(_x-55);CalculatePOPUPx=true;} else CalculatePOPUPx=false;if (height==null || height==0) {height=parseInt(_y-55);CalculatePOPUPy=true;} else CalculatePOPUPy=false;
centerPopWin(width, height);var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);
gPopupContainer.style.width = width + "px";	gPopupContainer.style.height = (height+titleBarHeight) + "px";
gPopFrame.style.width = parseInt(document.getElementById("popupTitleBar").offsetWidth, 10) + "px";gPopFrame.style.height = (height) + "px";
gPopFrame.src = url; gReturnFunc = returnFunc;if (gHideSelects == true) {hideSelectBoxes();}
window.setTimeout("setPopTitle();", 600);centerPopWin();centerPopWin();}

var gi = 0;

function cccppp (){//if (CalculatePOPUPy) return 5; else 
return 0;}


function centerPopWin(width, height) {if (gPopupIsShown == true) {if (width == null || isNaN(width)) {width = gPopupContainer.offsetWidth;}
if (height == null) {height = gPopupContainer.offsetHeight;}if (CalculatePOPUPx || CalculatePOPUPy){var _x=0;var _y=0;
if (self.innerHeight)	{_x = removePX(self.innerWidth);_y = removePX(self.innerHeight);}else if (document.documentElement && document.documentElement.clientHeight)
{_x = removePX(document.documentElement.clientWidth);_y = removePX(document.documentElement.clientHeight);}
else if (document.body)	{_x = removePX(document.body.clientWidth);_y = removePX(document.body.clientHeight);}
if (CalculatePOPUPx) width=_x-55;if (CalculatePOPUPy) height=_y-55;}var fullHeight = getViewportHeight();var fullWidth = getViewportWidth();var theBody =  document.documentElement;
var scTop = parseInt(theBody.scrollTop,10);var scLeft = parseInt(theBody.scrollLeft,10);//-Xminus;
gPopupMask.style.height = fullHeight + "px";gPopupMask.style.width = fullWidth + "px";gPopupMask.style.top = scTop + "px";gPopupMask.style.left = scLeft + "px";
var titleBarHeight = 0; if (CalculatePOPUPx || CalculatePOPUPy) {gPopupContainer.style.width = width + "px";
gPopupContainer.style.height = (height+titleBarHeight) + "px";gPopFrame.style.width = parseInt(document.getElementById("popupTitleBar").offsetWidth, 10) + "px";
gPopFrame.style.height = (height) + "px";} gPopupContainer.style.top = (scTop + ((fullHeight - (height+titleBarHeight)) / 2)+cccppp()) + "px";
gPopupContainer.style.left =  (scLeft + ((fullWidth - width) / 2)) + "px";}}
 
function hideMe(){gPopupIsShown = false;restoreTabIndexes();if (gPopupMask == null) {return;}gPopupMask.style.display = "none";gPopupContainer.style.display = "none";if (gHideSelects == true) {displaySelectBoxes();}}

function hidePopWin(callReturnFunc) {try {gPopFrame.src = '../../loading.htm';hideMe();}catch(e){}
try {if (gReturnFunc!=null ) gReturnFunc();} catch(e){}if (CanRedirect) window.parent.location='../../redir.aspx?RedirectUrl='+window.parent.location;}
function setPopTitle() {if (window.frames["popupFrame"].document.title == null) {window.setTimeout("setPopTitle();", 10);} else {document.getElementById("popupTitle").innerHTML = window.frames["popupFrame"].document.title;}}

function keyDownHandler(e) {if (gPopupIsShown && e.keyCode == 9)  return false;}

function disableTabIndexes() {if (document.all) {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++;}}}}

// For IE. Restore tab-indexes.
function restoreTabIndexes() {if (document.all) {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++;}}}}

function hideSelectBoxes() {for(var i = 0; i < document.forms.length; i++) {for(var e = 0; e < document.forms[i].length; e++){
if(document.forms[i].elements[e].tagName == "SELECT") {	document.forms[i].elements[e].style.visibility="hidden";}}}}

function displaySelectBoxes() {for(var i = 0; i < document.forms.length; i++) {for(var e = 0; e < document.forms[i].length; e++){if(document.forms[i].elements[e].tagName == "SELECT") {document.forms[i].elements[e].style.visibility="visible";}}}}

addEvent(window, "resize", centerPopWin);addEvent(window, "scroll", centerPopWin);window.onscroll = centerPopWin;window.onload=initPopUp;