/********************************************************************

Popup Windows - V 4.4
Author: Brian Gosselin
Site URL: http://scriptasylum.com
Read the "releasenotes.txt" for supported features and release notes.

************** EDIT THE LINES BELOW AT YOUR OWN RISK ****************/

var w3c=(document.getElementById)? true: false;
var ns4=(document.layers)?true:false;
var ie5=(w3c && document.all)? true : false;
var ns6=(navigator.userAgent.indexOf("Netscape/6")>0)? true: false;
currIDb=null; xoff=0; yoff=0;
currRS=null; rsxoff=0; rsyoff=0;
oldac=null; newac=null; zdx=1; mx=0; my=0;
var currFb=null; var currFs=null; var currFID=0; var currFcnt=0;
var cidlist=new Array();
var graphicDir="";
var showTitleBar = true;
var mouseTrackerInitialized = false;

//******* START OF EXPOSED FUNCTIONS. THESE CAN BE USED IN HYPERLINKS. *******\\

/**
 * Fade into view the specified popup.  
 * Popups can be faded into view only when they are already hidden.
 *	Parameter: id -- The unique ID of the popup fade in.
 */
function fadeboxin(id){
	if((currFb==null) && w3c){
		clearInterval(currFID);
		currFb=document.getElementById(id+'_b');
		currFs=document.getElementById(id+'_s');
		if(currFb.style.display=='none'){
			currFcnt=0;
			if(ie5)currFb.style.filter=currFs.style.filter="alpha(opacity=0)";
			else currFb.style.MozOpacity=currFs.style.MozOpacity=0;
			hideAllScrollbars();
			currFb.style.display=currFs.style.display='block';
			changez(currFb);
			currFID=setInterval('sub_fadein()',20);
			if (ie5) {
				currFbifrm=document.getElementById(id+'_b_ifrm');
				currFbifrm.style.display='block';
			}
		} else {
			currFb=null;
		}
	}
}

/**
 * Fade out of view the specified popup.  
 * Popups can be faded out of view only when they are visible.
 *	Parameter: id -- The unique ID of the popup fade out.
 */
function fadeboxout(id){
	if((currFb==null) && w3c){
		clearInterval(currFID);
		currFb=document.getElementById(id+'_b');
		currFs=document.getElementById(id+'_s');
		if(currFb.style.display=='block'){
			currFcnt=100;
			if(ie5){
				currFb.style.filter="alpha(opacity=100)";
				currFs.style.filter="alpha(opacity=50)";
			}else{
				currFb.style.MozOpacity=1;
				currFs.style.MozOpacity=.5;
			}
			hideAllScrollbars();
			currFb.style.display=currFs.style.display='block';

			changez(currFb);
			currFID=setInterval('sub_fadeout()',20);
			if (ie5) {
				currFbifrm=document.getElementById(id+'_b_ifrm');
				currFbifrm.style.display='none';
			}					
		} else {
			currFb=null;
		}
	}
}

/**
 * Closes the specified popup. This actually just "hides" the popup.
 *	Parameter: id -- The unique ID of the popup to close.
 */
function hidebox(id){
	setTimeout(function(){hideboxNow(id)},1);
}

function hideboxNow(id){
	if(w3c){
		document.getElementById(id+'_b').style.display='none';
		if (ie5) {
			document.getElementById(id+'_b_ifrm').style.display='none';
		}
		document.getElementById(id+'_s').style.display='none';
	}
}

/**
 * Opens the specified popup. This actually just "shows" the popup.
 *	Parameter: id -- The unique ID of the popup to open.
 */
function showbox(id){
	if(w3c){
		var bx=document.getElementById(id+'_b');		
		var sh=document.getElementById(id+'_s');
		bx.style.display='block';
		if (ie5) {
			bxi=document.getElementById(id+'_b_ifrm');
			bxi.style.display='block';
		}
		sh.style.display='block';
		changez(bx);
	}
}


/**
 * Change the content (or URL source for external types) of the specified popup
 *	Parameter: id -- The unique ID of the popup to open.
 *	Parameter: text -- The new content. If the popup is set up as an external window, then this text will be interpreted as the new URL. 
 */
function changecontent(id,text) {
	if(!document.getElementById(id+'_b').isExt){
		var d=document.getElementById(id+'_c');
		if(ns6) {
			d.style.overflow="hidden";
		}
		d.innerHTML=text;
		if(ns6) {
			d.style.overflow="block";
		}
	} else {
		document.getElementById(id+'_ifrm').src=text;
	}
}

/**
 * Change the title text.
 *	Parameter: aWindowId -- The unique ID of the popup to change the title for.
 *	Parameter: aTitle -- The new text to set the title to.
 */
function changetitle(aWindowId,aTitle){ 
    var elementToUpdate = document.getElementById(aWindowId+'_t_text');
    elementToUpdate.innerHTML = aTitle;                        
}

/**
 * Dynamically move the popup given the id of the popup and new coordinates.
 *	Parameter: ID -- The unique ID of the popup to move.
 *	Parameter: leftPos  -- Left corner pixel coordinate.
 *	Parameter: topPos -- Top corner pixel coordinate.
 */
function movePopup(ID,leftPos,topPos){
    if (leftPos < 10) {
        leftPos = 10;                   
    } 
    if (topPos < 10) {
        topPos = 10;
    }    
	if(w3c){
		var idb=document.getElementById(ID+'_b');
		var ids=document.getElementById(ID+'_s');
		idb.style.left=leftPos+'px';
		ids.style.left=leftPos+8+'px';
		idb.style.top=topPos+'px';
		ids.style.top=topPos+8+'px';
		if (ie5) {
			idbf=document.getElementById(ID+'_b_ifrm');
			idbf.style.left=leftPos+'px';
			idbf.style.top=topPos+'px';
		}
	}
}

/**
 * Dynamically resize the popup given the id of the popup and new size.
 *	Parameter: ID -- The unique ID of the popup to resize.
 *	Parameter: width -- Width in pixels
 *	Parameter: height -- Height in pixels.
 */
function resizePopup(ID,width,height){
	if(w3c){
		if(document.getElementById(ID+'_rs').rsEnable){
			document.gEl=document.getElementById;
			document.gEl(ID+"_extWA").style.display="block";
			document.gEl(ID+"_rs").style.left=Math.max(width,((ie5)?88:92))+'px';
			document.gEl(ID+"_rs").style.top=Math.max((height-((ie5)?8:0)),((ie5)?60:72))+'px';
			document.gEl(ID+"_b").style.width=Math.max(width+((ie5)?12:8),100)+'px';
			document.gEl(ID+"_b").style.height=Math.max(height+((ie5)?12:8),80)+'px';
			if (ie5) {
				document.gEl(ID+"_b_ifrm").style.width=Math.max((width+12),100)+'px';
				document.gEl(ID+"_b_ifrm").style.height=Math.max((height+12),80)+'px';
			}
			document.gEl(ID+"_t").style.width=Math.max(width+((ie5)?4:3),((ns6)?95:92))+'px';
			document.gEl(ID+"_btt").style.left=parseInt(document.gEl(ID+"_t").style.width)-48+'px';
			document.gEl(ID+"_s").style.width=Math.max(width+12,((ie5)?100:104))+'px';
			document.gEl(ID+"_s").style.height=Math.max(height+((ie5)?12:13),((ie5)?80:86))+'px';
			document.gEl(ID+"_c").style.width=Math.max(width-((ie5)?-5:5),((ie5)?92:87))+'px';
			document.gEl(ID+"_c").style.height=Math.max(height-((ie5)?24:28),44)+'px';
			if (ns6 && document.gEl(ID+'_b').isExt) {
				document.gEl(ID+"_ifrm").style.width=parseInt(document.gEl(ID+"_c").style.width)-2+'px';
				document.gEl(ID+"_ifrm").style.height=parseInt(document.gEl(ID+"_c").style.height)-2+'px';
			}
			document.gEl(ID+"_max").h=parseInt(document.gEl(ID+"_b").style.height);
		}
	}
}

//******* END OF EXPOSED FUNCTIONS *******\\

function hideAllScrollbars(){
if(document.all){
var id;
for(i=0;i<cidlist.length;i++){
id=cidlist[i];
if(!document.getElementById(id+'_b').isExt)document.getElementById(id+'_c').style.overflow="hidden";
}}}

function showAllScrollbars(){
if(document.all){
var id;
for(i=0;i<cidlist.length;i++){
id=cidlist[i];
if(!document.getElementById(id+'_b').isExt)document.getElementById(id+'_c').style.overflow="auto";
}}}

function sub_fadein(){
currFcnt+=4;
if(ie5){
currFb.style.filter="alpha(opacity="+currFcnt+")";
currFs.style.filter="alpha(opacity="+(currFcnt/2)+")";
}else{
currFb.style.MozOpacity=currFcnt/100;
currFs.style.MozOpacity=(currFcnt/2)/100;
}
if(currFcnt>=99){
currFb.style.display=currFs.style.display='block';
showAllScrollbars()
currFb=null;
clearInterval(currFID);
}}

function sub_fadeout(){
currFcnt=currFcnt-4;
if(ie5){
currFb.style.filter="alpha(opacity="+currFcnt+")";
currFs.style.filter="alpha(opacity="+(currFcnt/2)+")";
}else{
currFb.style.MozOpacity=currFcnt/100;
currFs.style.MozOpacity=(currFcnt/2)/100;
}
if(currFcnt<=0){
currFb.style.display=currFs.style.display='none';
showAllScrollbars()
currFb=null;
clearInterval(currFID);
}}

function preloadBttns(){
var btns=new Array();
btns[0]=new Image(); btns[0].src=graphicDir+"min.gif";
btns[1]=new Image(); btns[1].src=graphicDir+"max.gif";
btns[2]=new Image(); btns[2].src=graphicDir+"close.gif";
btns[3]=new Image(); btns[3].src=graphicDir+"resize.gif";
}
//Commented out since at this point the graphicDir has not yet been set
//		and to assume the gif file are in the current directory is always incorrect
//preloadBttns();

function minimize(){
if(w3c){
document.getElementById(this.cid+"_b").style.height=(ie5)? '28px':'24px';
if (ie5) {
	document.getElementById(this.cid+"_b_ifrm").style.height=(ie5)? '28px':'24px';
}
document.getElementById(this.cid+"_s").style.height='28px';
document.getElementById(this.cid+"_c").style.display='none';
document.getElementById(this.cid+"_rs").style.display='none';
ns6bugfix();
}}

function restore(){
if(w3c){
document.getElementById(this.cid+"_b").style.height=this.h+'px';
if (ie5) {
	document.getElementById(this.cid+"_b_ifrm").style.height=this.h+'px';
}
document.getElementById(this.cid+"_s").style.height=(ie5)? this.h+'px':this.h+5+'px';
document.getElementById(this.cid+"_c").style.display='block';
document.getElementById(this.cid+"_rs").style.display='block';
ns6bugfix();
}}

function ns6bugfix(){
if(navigator.userAgent.indexOf("Netscape/6")>0)setTimeout('self.resizeBy(0,1); self.resizeBy(0,-1);', 100);
}

function trackmouse(evt){
mx=(ie5)?event.clientX+document.body.scrollLeft:evt.pageX;
my=(ie5)?event.clientY+document.body.scrollTop:evt.pageY;
if(!ns6)movepopup();
if((currIDb!=null)||(currRS!=null))return false;
}

function movepopup(){
if((currIDb!=null)&&w3c)movePopup(currIDb.cid,mx+xoff,my+yoff);
if((currRS!=null)&&w3c)resizePopup(currRS.cid,mx+rsxoff,my+rsyoff);
return false;
}

function stopRS(){
document.getElementById(this.cid+"_extWA").style.display="none";
currRS=null;
}

function startRS(evt){
initializeMouseTracker();
var ex=(ie5)?event.clientX+document.body.scrollLeft:evt.pageX;
var ey=(ie5)?event.clientY+document.body.scrollTop:evt.pageY;
rsxoff=parseInt(this.style.left)-ex;
rsyoff=parseInt(this.style.top)-ey;
currRS=this;
if(ns6)document.getElementById(this.cid+"_c").style.overflow='hidden';
return false;
}

function changez(v){
    var th=(v!=null)?v:this;
    if (oldac != th) {
        if (showTitleBar) {
            if(oldac!=null) {
                var tmpElement = document.getElementById(oldac.cid+"_t");
                if (tmpElement) {
                    tmpElement.style.backgroundColor=oldac.inactivecolor;
                }
            }
        }
        if(ns6 && !document.getElementById(th.cid+'_b').isExt) {
            document.getElementById(th.cid+"_c").style.overflow='auto';
        } else {
            document.getElementById(th.cid+"_c").style.overflow='hidden';
        }
        oldac=th;
        if (showTitleBar) {
            var tmpElement = document.getElementById(th.cid+"_t");
            if (tmpElement) {
                tmpElement.style.backgroundColor=th.activecolor;
            }
        }
        document.getElementById(th.cid+"_s").style.zIndex=++zdx;
        th.style.zIndex=++zdx;
        if (showTitleBar) {
            document.getElementById(th.cid+"_rs").style.zIndex=++zdx;
        }
        if(document.getElementById(th.cid+'_b').isExt){
            document.getElementById(th.cid+"_ifrm").style.zIndex=++zdx;
        }
    }
}

function stopdrag(){
currIDb=null;
document.getElementById(this.cid+"_extWA").style.display="none";
ns6bugfix();
}

function grab_id(evt){
initializeMouseTracker();
var ex=(ie5)?event.clientX+document.body.scrollLeft:evt.pageX;
var ey=(ie5)?event.clientY+document.body.scrollTop:evt.pageY;
xoff=parseInt(document.getElementById(this.cid+"_b").style.left)-ex;
yoff=parseInt(document.getElementById(this.cid+"_b").style.top)-ey;
currIDb=document.getElementById(this.cid+"_b");
currIDs=document.getElementById(this.cid+"_s");
document.getElementById(this.cid+"_extWA").style.display="block";
return false;
}

function subBox(x,y,w,h,bgc,id){
var v=document.createElement('div');
v.setAttribute('id',id);
v.style.position='absolute';
v.style.left=x+'px';
v.style.top=y+'px';
v.style.width=w+'px';
v.style.height=h+'px';
if(bgc!='')v.style.backgroundColor=bgc;
v.style.visibility='visible';
v.style.padding='0px';
return v;
}

function titleBarSubBox(x,y,w,h,styleClass,id){
	var titleBox = subBox(x,y,w,h,'',id);
	titleBox.className=styleClass;
	return titleBox;
}

/* Disabled because we do not want to place cookies on user's machines.
function get_cookie(Name) {
var search=Name+"=";
var returnvalue="";
if(document.cookie.length>0){
offset=document.cookie.indexOf(search);
if(offset!=-1){
offset+=search.length;
end=document.cookie.indexOf(";",offset);
if(end==-1)end=document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset,end));
}}
return returnvalue;
}
*/


/**
 * Create a new popup
 *	Parameter: leftPosition - Left pixel coordinate from left edge of browser window. Number. 
 *	Parameter: topPosition - Top pixel coordinate from left edge of browser window. Number. 
 *	Parameter: width - Width of popup in pixels. Number. 
 *	Parameter: height - Height of popup in pixels. Number. 
 *	Parameter: aPopupId - Unique arbitrary ID value given to the popup. String. 
 *	Parameter: text - URL of external content (if isExt=true) -OR- HTML string inside popup (if isExt=false). Because the content is in string form, watch for quotes syntax. 
 *	Parameter: bgcolor - Content area background color. Hex color triplet or valid color name string. 
 *	Parameter: textcolor - Content text color, obviously. Hex color triplet or valid color name string. 
 *	Parameter: fontstyleset - Font style set using CSS type syntax. Hex color triplet or valid color name string. 
 *	Parameter: title - Text to appear in the titlebar. String. 
 *	Parameter: titlebgcolor - Background color of the titlebar when active. Hex color triplet or valid color name string. 
 *	Parameter: titletextcolor - Color of the titlebar text. Hex color triplet or valid color name string. 
 *	Parameter: bordercolor - Color of the popup borders. Hex color triplet or valid color name string. 
 *	Parameter: scrollcolor - Color of the scrollbar (IE5.5 only) and the color of the titlebar when not in focus. Hex color triplet or valid color name string. 
 *	Parameter: shadowcolor - Semi-transparent shadow color (IE5+, NS6+ only). Hex color triplet or valid color name string. 
 *	Parameter: showonstart - Specifies whether the popup is initially "closed". true or false. 
 *	Parameter: isdrag - Specifies whether popup is draggable. true or false. 
 *	Parameter: isresize - Specifies whether popup is resizeable. If not, resize handle and the minimize/maximize buttons will not be present. true or false. 
 *	Parameter: oldOK - Specifies whether the popup will show up in "non-standards" browsers. The popup appears as normal windows in these types of browsers if this value is enabled. true or false. 
 *	Parameter: isExt - Specifies whether the text in the content area is a link to an external website or simply text to display in the popup. If this is not set, the URL in the content area will not be loaded, it will just be displayed as text. true or false. 
 *	Parameter: popOnce - (DISABLED) Specifies whether the popups will reappear if the user returns to the page. This option uses cookies, so the user must have cookies enabled for this to work. true or false. This option is disabled because we do not want to allow cookies on user's systems
 *	Parameter: titleClass -- The name of the style sheet class to use for the title bar.  This overrides the titlebgcolor and titletextcolor parameters.
 *	Parameter: aWindowName -- The name to give the popup window.  This is used so that the window can be a target of a form.
 *	Parameter: aGraphicsDir -- The directory that contains the popup window graphics (i.e. /app/graphics/).  This must end with a slash ("/").
 *	Parameter: isCloseable -- Specifies whether popup is closeable. true or false.   If not, the exit image will not appear on the titlebar
 */
function popUp(leftPosition,topPosition,width,height,aPopupId,text,bgcolor,textcolor,fontstyleset,title,titlebgcolor,titletextcolor,bordercolor,scrollcolor,shadowcolor,showonstart,isdrag,isresize,oldOK,isExt,popOnce,titleClass,windowName,aGraphicsDir,isCloseable){
	graphicDir = aGraphicsDir;
	var okPopUp=false;
	/* Disabled because we do not want to place cookies on user's machines.
	if (popOnce){
	if (get_cookie(cid)==""){
	okPopUp=true;
	document..cookie=cid+"=yes"
	}}
	else 
	*/
	okPopUp=true;
	if(okPopUp){
		if(w3c){
			if (isCloseable == null) {
				isCloseable = true;
			}
			cidlist[cidlist.length]=aPopupId;
			width=Math.max(width,100);
			height=Math.max(height,80);
			var rdiv;
            if (showTitleBar) {
                rdiv=new subBox(width-((ie5)?12:8),height-((ie5)?20:8),7,7,'',aPopupId+'_rs');                
            } else {
                rdiv=new subBox(width,height,15,15,'',aPopupId+'_rs');
			}

            if (isresize || showTitleBar) {
                preloadBttns();
            }

            if(isresize){
                rdiv.innerHTML='<img src="'+graphicDir+'resize.gif" width="7" height="7">';
                rdiv.style.cursor='move';
            }
            
			rdiv.rsEnable=isresize;
			var tw=(ie5)?width:width+4;
			var th=(ie5)?height:height+6;
			var shadow=new subBox(leftPosition+8,topPosition+8,tw,th,shadowcolor,aPopupId+'_s');
			if(ie5)shadow.style.filter="alpha(opacity=50)";
			else shadow.style.MozOpacity=.5;
			shadow.style.zIndex=++zdx;
			var outerdiv=new subBox(leftPosition,topPosition,width,height,bordercolor,aPopupId+'_b');
			outerdiv.style.display="block";
			outerdiv.style.borderStyle="outset";
			outerdiv.style.borderWidth="2px";
			outerdiv.style.borderColor=bordercolor;
			outerdiv.style.zIndex=++zdx;
			if (ie5) {
				outerdivIFrame=new iFrame(leftPosition,topPosition,width,height,aPopupId+'_b_ifrm');
				outerdivIFrame.src="/xmlDocs/javascript/blank.html";
			}			
			tw=(ie5)?width-8:width-5;
			th=(ie5)?height+4:height-4;
            var titlebar;
            if (showTitleBar) {
                titlebar=new titleBarSubBox(2,2,tw,20,titleClass,aPopupId+'_t');
                titlebar.style.overflow="hidden";
                titlebar.style.cursor="default";
                var resizeicons=(isresize)?'<img src="'+graphicDir+'min.gif" width="16" height="16" id="'+aPopupId+'_min"><img src="'+graphicDir+'max.gif" width="16" height="16"  id="'+aPopupId+'_max">':'';
                var closeicon=(isCloseable)?'<img src="'+graphicDir+'close.gif" onclick="focus();hideboxNow(\''+aPopupId+'\');" width="16" height="16" id="'+aPopupId+'_cls">':'';
                var titletext='<span id="'+aPopupId+'_t_text" style="position:absolute; left:3px; top:1px; font:bold 10pt sans-serif; color:'+titletextcolor+'; height:18px; overflow:hidden; clip-height:16px;">'+title+'</span>';
                titlebar.innerHTML=titletext+'<div id="'+aPopupId+'_btt" style="position:absolute; width:48px; height:16px; left:'+(tw-48)+'px; top:2px; text-align:right">'+resizeicons+closeicon+'</div>';
            }
            tw=(ie5)?width-7:width-13;
            if (showTitleBar) {
                var content=new subBox(2,24,tw,height-36,bgcolor,aPopupId+'_c');
            }
            else {
                var content=new subBox(2,4,tw,height-10,bgcolor,aPopupId+'_c');
            }
			content.style.borderColor=bordercolor;
			content.style.borderWidth="2px";
			if(isExt){
				if (ns6) {
					content.innerHTML='<iframe id="'+aPopupId+'_ifrm" src="'+text+'" width="'+(tw-2)+'" height="'+(height-38)+'" name="'+windowName+'"></iframe>';
				} else {
					content.innerHTML='<iframe id="'+aPopupId+'_ifrm" src="'+text+'" width="100%" height="100%" name="'+windowName+'"></iframe>';
				}
				content.style.overflow="hidden";
			}else{
				if(ie5)content.style.scrollbarBaseColor=scrollcolor;
				content.style.borderStyle="inset";
				content.style.overflow="auto";
				content.style.padding="0px 2px 0px 4px";
				content.innerHTML=text;
				if (fontstyleset != '') {
					content.style.font=fontstyleset;
				}
				content.style.color=textcolor;
			}
			var extWA=new subBox(2,24,0,0,'',aPopupId+'_extWA');
			extWA.style.display="none";
			extWA.style.width='100%';
			extWA.style.height='100%';
            if (showTitleBar) {
                outerdiv.appendChild(titlebar);
            }
			outerdiv.appendChild(content);
			outerdiv.appendChild(extWA);
			outerdiv.appendChild(rdiv);
			document.body.appendChild(shadow);
			document.body.appendChild(outerdiv);
			if (ie5){
				document.body.appendChild(outerdivIFrame);
			}
			document.gEl=document.getElementById;
			if(!showonstart)hideboxNow(aPopupId);
			var wB=document.gEl(aPopupId+'_b');
			wB.cid=aPopupId;
			wB.isExt=(isExt)?true:false;
            var wT, wRS, wMIN, wMAX, wCLS;
            if (showTitleBar) {
                wT=document.gEl(aPopupId+'_t');
                wT.cid=aPopupId;
                if(isresize){
                    wRS=document.gEl(aPopupId+'_rs');
                    wRS.cid=aPopupId;
                    wMIN=document.gEl(aPopupId+'_min');
                    wMIN.cid=aPopupId;
                    wMAX=document.gEl(aPopupId+'_max');
                    wMAX.h=height;
                    wMAX.cid=aPopupId;
                    wMIN.onclick=minimize;
                    wMAX.onclick=restore;
                    wRS.onmousedown=startRS;
                    wRS.onmouseup=stopRS;
                }
                wCLS=document.gEl(aPopupId+'_cls');
            }
			var wEXTWA=document.gEl(aPopupId+'_extWA');
			wB.activecolor=titlebgcolor;
			wB.inactivecolor=scrollcolor;
            if (showTitleBar) {
                if(oldac!=null) {
                    var tmpElement = document.gEl(oldac.cid+"_t");
                    if (tmpElement) {
                        tmpElement.style.backgroundColor=oldac.inactivecolor;
                    }
                }
            }
			oldac=wB;
            if (showTitleBar) {
                wB.onmousedown=function(){ changez(this) }
                if(isdrag){
                    wT.onmousedown=grab_id;
                    wT.onmouseup=stopdrag;
                }
            }
		}else{
			if(oldOK){
				var t=(isExt)?text:'';
				var posn=(ns4)? 'screenX='+leftPosition+',screenY='+topPosition: 'left='+leftPosition+',top='+topPosition;
				if (text.indexOf("javascript:parent.document.") == 0) {
					//If the parent is being targeted, change to current document because that's what we are
					js= "document." + text.substr(27);
					t='';		
				}
				var win=window.open(t , windowName , "status=no,menubar=no,width="+width+",height="+height+",resizable="+((isresize)?"yes":"no")+",scrollbars=yes,"+posn);
				if (js) {
					//Execute the specified javascript function
					eval(js);
				}
				if(!isExt){
					t='<html><head><title>'+title+'</title></head><body bgcolor="'+bgcolor+'"><font style="font:'+fontstyleset+'; color:'+textcolor+'">'+text+'</font></body></html>';
					win.document.write(t);
					win.document.close();
				}
			}
		}
	}
}

function initializeMouseTracker() {        
    if (!mouseTrackerInitialized) {
        if(w3c){
            document.onmousemove=trackmouse;
            document.onmouseup=new Function("currRS=null");
        }        
        if(ns6) {
            setInterval('movepopup()',40);
        }
    } else {
        mouseTrackerInitialized = true;
    }
    
    
}   

/**
 * Loads the popup window given the specified parameters.
 *	Parameter: aWindowId -- A unique id to identify this popup window (can be used later by the showbox function to display the popup).
 *	Parameter: aTitle -- The title of the popup (displayed in the title bar of the popup).
 *	Parameter: aWidth -- The width of the popup window.	
 *	Parameter: aHeight -- The height of the popup window.	
 *	Parameter: aURL -- If the parameter "isExternalLink" is true or not passed, this parameter represents the url to use for the
 *		popup window.  If the parameter "isExternalLink" is false, this parameter represents the HTML string to display in the 
 *		popup . Because the content is in string form, watch for quotes syntax. 
 *	Parameter: aWindowName -- The name to give the popup window.  This is used so that the window can be a target of a form.
 *	Parameter: aGraphicsDir -- The directory that contains the popup window graphics (i.e. /app/graphics/).  This must end with a slash ("/").
 *	Parameter: aDisplayNowFlag -- A boolean denoting if the popup should be displayed right away.  If false, you can later use the showbox function to display the popup.
 *	Parameter: elementToPlaceBy -- (Optional) The name of the element to position by.  If this value isn't passed in, the popup will display in the center of the window.
 *	Parameter: aVerticalAlignment -- (Optional) The vertical alignment to use for positioning by the specified element.  Valid values are:
 *		TOP -- completely above the reference element (bottom margin of the calendar aligned to the top margin of the element).
 *		top -- above the element but may overlap it (bottom margin of the calendar aligned to the bottom margin of the element).
 *		center -- the calendar displays vertically centered to the reference element. It might overlap it (that depends on the horizontal alignment).
 *		below -- below the element but may overlap it (top margin of the calendar aligned to the top margin of the element).
 *		BELOW -- completely below the element (top margin of the calendar aligned to the bottom margin of the element).
 *		If this parameter is not passed, it will default to "BELOW".
 *	Parameter: aHorizontalAlignment -- (Optional) The horizontal alignment to use for positioning.  Valid values are:
 *		LEFT -- completely to the left of the reference element (right margin of the calendar aligned to the left margin of the element).
 *		left -- to the left of the element but may overlap it (left margin of the calendar aligned to the left margin of the element).
 *		center -- horizontally centered to the element. Might overlap it, depending on the vertical alignment.
 *		right -- to the right of the element but may overlap it (right margin of the calendar aligned to the right margin of the element).
 *		RIGHT -- completely to the right of the element (left margin of the calendar aligned to the right margin of the element).
 *		If this parameter is not passed, it will default to "left".
 *	Parameter: isExternalLink - Specifies whether the text in the content area is a link to an external website or simply text to 
 *		display in the popup. If this is not set, the URL in the content area will not be loaded, it will just be displayed as text.  
 *		Valid values are true or false.  If this parameter is not passed, it defaults to true.
 *	Parameter: hideTitleBar - Specifies whether popup should display the title bar. If not the title bar including the minimize/maximize buttons will not be present. true or false.  
 *	Parameter: isResizable - Specifies whether popup is resizeable. If not, resize handle and the minimize/maximize buttons will not be present. true or false. 
 *	Parameter: isCloseable -- Specifies whether popup is closeable. true or false.   If not, the exit image will not appear on the titlebar
 */
function loadPopUp(aWindowId, aTitle, aWidth, aHeight, aURL, aWindowName, aGraphicsDir, aDisplayNowFlag, elementToPlaceBy, aVerticalAlignment, aHorizontalAlignment, isExternalLink, hideTitleBar, isResizable, isMoveable, isCloseable){
		var leftPosition = 50;
		var topPosition = 50;
		if (w3c) {
			if (document.getElementById(aWindowId+'_b')) {
                if (!hideTitleBar) {
                    changetitle(aWindowId,aTitle);
                }
				changecontent(aWindowId,aURL);
				if (aDisplayNowFlag){
					return showbox(aWindowId);
				} else {
					return false;
				}
			}
			if (elementToPlaceBy && elementToPlaceBy != null) {
                if(!aVerticalAlignment || aVerticalAlignment==""){
                    aVerticalAlignment = "BELOW";
                }
                if(!aHorizontalAlignment || aHorizontalAlignment==""){
                    aHorizontalAlignment = "left";
                }
                
				tmpElement=document.getElementById(elementToPlaceBy);
				newPosition = positionByElement(tmpElement, aWidth, aHeight,aVerticalAlignment,aHorizontalAlignment);
				leftPosition = newPosition.x;
				topPosition =  newPosition.y;
			} else {
				//Default to center of screen
				leftPosition = getSize('Width')/2;
				leftPosition += getHorizontalOffset();
				leftPosition = leftPosition - (aWidth/2);
				if (leftPosition < 0) {
					leftPosition = 10;
				}
				topPosition = getSize('Height')/2;
				topPosition += getVerticalOffset();
				topPosition = topPosition - (aHeight/2);
				if (topPosition < 0) {
					topPosition = 10;
				}
			}
            if (hideTitleBar == true) {
                showTitleBar = false;
            } else {
                showTitleBar = true;
            }
		}
		if (isExternalLink == null) {
			isExternalLink = true;
		}
        if (isResizable == null) {
            isResizable = true;
        }
        if (isMoveable == null) {
        		isMoveable = true;
        }
        if (isCloseable == null) {
        		isCloseable = true;
        }        
		new popUp(leftPosition, topPosition, aWidth, aHeight, aWindowId, aURL, "white", "", "", aTitle, "", "", "lightgrey", "", "", aDisplayNowFlag, isMoveable, isResizable, true, isExternalLink, false, "popuptitle", aWindowName, aGraphicsDir, isCloseable);
}

/**
 * Calculates the absolute position of the passed in Element.
 *	Return: an object with two values:
 *		absolutePos.x -- The left offset
 *		absolutePos.y -- The top offset
 */
function getAbsolutePos(anElement) {
		var absolutePos = { x: anElement.offsetLeft, y: anElement.offsetTop };
		if (anElement.offsetParent) {
				var tmp = getAbsolutePos(anElement.offsetParent);
				absolutePos.x += tmp.x;
				absolutePos.y += tmp.y;
		}
		return absolutePos;
}


/**
 * Calulates the position for the popup based on another element on the page.
 *	Parameter: anElement -- The name of the element to position by.
 *	Parameter: aWidth -- The width of the popup window.	
 *	Parameter: aHeight -- The height of the popup window.	
 *	Parameter: aVerticalAlignment -- The vertical alignment to use for positioning.  Valid values are:
 *		TOP -- completely above the reference element (bottom margin of the calendar aligned to the top margin of the element).
 *		top -- above the element but may overlap it (bottom margin of the calendar aligned to the bottom margin of the element).
 *		center -- the calendar displays vertically centered to the reference element. It might overlap it (that depends on the horizontal alignment).
 *		below -- below the element but may overlap it (top margin of the calendar aligned to the top margin of the element).
 *		BELOW -- completely below the element (top margin of the calendar aligned to the bottom margin of the element).
		If this parameter is not passed, it will default to "BELOW".
 *	Parameter: aHorizontalAlignment -- The horizontal alignment to use for positioning.  Valid values are:
 *		LEFT -- completely to the left of the reference element (right margin of the calendar aligned to the left margin of the element).
 *		left -- to the left of the element but may overlap it (left margin of the calendar aligned to the left margin of the element).
 *		center -- horizontally centered to the element. Might overlap it, depending on the vertical alignment.
 *		right -- to the right of the element but may overlap it (right margin of the calendar aligned to the right margin of the element).
 *		RIGHT -- completely to the right of the element (left margin of the calendar aligned to the right margin of the element).
 *		If this parameter is not passed, it will default to "left".
 *	Return: an object with two values representing the position for the popup:
 *		newPosition.x -- The left offset
 *		newPosition.y -- The top offset
 */
function positionByElement(anElement, aWidth, aHeight, aVerticalAlignment, aHorizontalAlignment) {
		var newPosition = getAbsolutePos(anElement);
		if (!aVerticalAlignment) {
				newPosition.y += anElement.offsetHeight;
				return newPosition;
		}
		
		if (!aHorizontalAlignment) {
			aHorizontalAlignment = "left";
		}
		// vertical alignment
		switch (aVerticalAlignment) {
			case "TOP": newPosition.y -= aHeight; break;
			case "BELOW": newPosition.y += anElement.offsetHeight; break;
			case "center": newPosition.y += (anElement.offsetHeight - aHeight) / 2; break;
			case "top": newPosition.y += anElement.offsetHeight - aHeight; break;
			case "below": break; // already there
		}
		// horizontal alignment
		switch (aHorizontalAlignment) {
			case "LEFT": newPosition.x -= aWidth; break;
			case "RIGHT": newPosition.x += anElement.offsetWidth; break;
			case "center": newPosition.x += (anElement.offsetWidth - aWidth) / 2; break;
			case "right": newPosition.x += anElement.offsetWidth - aWidth; break;
			case "left": break; // already there
		}
		if((newPosition.y - getVerticalOffset()) < 0){
		    newPosition.y = 10 + getVerticalOffset();
		} else if (((newPosition.y + aHeight) - getVerticalOffset()) > getSize('Height')) {
		    newPosition.y = (getSize('Height') + getVerticalOffset()) - (aHeight + 10);
		}        
		if((newPosition.x - getHorizontalOffset()) < 0){
		    newPosition.x = 10 + getHorizontalOffset();
		} else if (((newPosition.x + aWidth) - getHorizontalOffset()) > getSize('Width')) {
		    newPosition.x = (getSize('Width') + getHorizontalOffset()) - (aWidth + 10);
		}
		return newPosition;
}

function getSize(sizeType){
    return eval('window.inner'+sizeType) ||
            eval('document.body.client'+sizeType) ||
            eval('document.documentElement.client'+sizeType);
}

function getHorizontalOffset(){
   var w = window.pageXOffset ||
           document.body.scrollLeft ||
           document.documentElement.scrollLeft;           
   return w ? w : 0;
}

function getVerticalOffset() {
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;           
   return h ? h : 0;
}

/**
 * Creates an iframe.  This is used to create an iframe to make the popup display over drop downs.
 */
function iFrame(aLeftPosition,aTopPosition,aWidth,aHeight,anId) {
	var v=document.createElement('iframe');
	v.setAttribute('id',anId);
	v.setAttribute('scrolling','no');
	v.style.position='absolute';
	v.style.left=aLeftPosition+'px';
	v.style.top=aTopPosition+'px';
	v.style.width=aWidth+'px';
	v.style.height=aHeight+'px';
	v.style.visibility='visible';
	return v;
}
