 var AX_Width=0, AX_Height=0;
 var AX_ScrOfX=0, AX_ScrOfY=0;
 var pageW=960;
 var py=0;
 var dnsp=false;//Popup will remain static on the window when scrolled
 var reloadIt=false;//Parent will not reload
 var t=".png";
 var popVisibleDivID = null;

  var browser = navigator.appName;//detecting browser IE 6 and below
    var version = navigator.appVersion;
    if ( browser== "Microsoft Internet Explorer" )
        {
        var version1 = version.substring(22,25);
        var sisop = version.substring(26,41);
		if (parseInt(version1)<7){
			t=".gif";
		}
    }
 function AX_Win_Prop() {
    AX_Width = document.documentElement.clientWidth;
    AX_Height = document.documentElement.clientHeight;
	AX_ScrOfY = document.documentElement.scrollTop;
    AX_ScrOfX = document.documentElement.scrollLeft;
}


 function AX_Pop_Create(objpop){
	var pPID="";
	py+=1;
	document.getElementById("popdiv").style.display="block";
	if (objpop.pID && typeof(objpop.pID) != "undefined") pPID = objpop.pID;
	var pBG=document.createElement("DIV");
	pBG.className="pBG";
	pBG.style.zIndex=1001+py;
	AX_Win_Prop();
	pBG.style.top=AX_ScrOfY+"px";
	pBG.style.left=AX_ScrOfX+"px";
	pBG.id="ipopbg"+pPID+py;
	popVisibleDivID = pPID+py;
	//document.body.appendChild(pBG);
	document.getElementById("popdiv").appendChild(pBG);

	var pP=document.createElement("DIV");
	var dHeight=parseInt(objpop.pHeight)+18, dWidth=parseInt(objpop.pWidth)+18;
	var iHeight=parseInt(objpop.pHeight)-22;
	var iWidth=parseInt(objpop.pWidth)-22;


	if (isNaN(objpop.pTop/objpop.pTop)){
		var dTop=((document.documentElement.clientHeight-parseInt(objpop.pHeight))/2)+AX_ScrOfY;
	}
	else {
		var dTop=parseInt(AX_ScrOfY)+parseInt(objpop.pTop);
	}
	if (isNaN(objpop.pLeft/objpop.pLeft)){
		var dLeft=((document.documentElement.clientWidth-parseInt(objpop.pWidth))/2)+AX_ScrOfX;
	}
	else {
		var dLeft=((document.documentElement.clientWidth-pageW)/2)+parseInt(objpop.pLeft);
	}
	

	
	pP.style.position="absolute";
	pP.style.zIndex=1001+py;
	pP.style.height=dHeight+"px";
	pP.style.width=dWidth+"px";
	pP.style.top=dTop+"px";
	pP.style.left=dLeft+"px";
	pP.id="ipop"+pPID+py;
	var d=new Date();
	var fID="lPopFrame"+pPID+py;
	var scrl="no";
	if(objpop.pSC)scrl=objpop.pSC;

	pP.innerHTML='<table border="0" cellspacing="0" cellpadding="0"><tr><td style="height:16px;width:17px;"><img src="'+iPop_imagePath+'local/localgraphics/ds_corner_lftop'+t+'"  height="16" width="17"></td><td style="height:16px;background:url('+iPop_imagePath+'local/localgraphics/ds_1top'+t+') transparent;"></td><td style="height:16px;width:23px;"><img src="'+iPop_imagePath+'local/localgraphics/ds_corner_rttop'+t+'" height="16" width="23"></td></tr><tr><td style="width:17px;background:url('+iPop_imagePath+'local/localgraphics/ds_1left'+t+') transparent;"></td><td style="background-color:#5C5C5C;padding-top:'+objpop.tP+';padding-right:'+objpop.rP+';padding-bottom:'+objpop.bP+';padding-left:'+objpop.lP+';"><iframe scrolling="'+scrl+'" src="" frameborder="0" height="'+iHeight+'" width="'+iWidth+'" id="'+fID+'" name="'+fID+'" style="background-color: #FFFFFF" closeP=""></iframe></td><td style="width:23px;background:url('+iPop_imagePath+'local/localgraphics/ds_1right'+t+') transparent;"></td></tr><tr><td style="height:24px;width:17px;"><img src="'+iPop_imagePath+'local/localgraphics/ds_corner_lfbottom'+t+'" height="24" width="17" ></td><td style="height:24px;background:url('+iPop_imagePath+'/local/localgraphics/ds_1bottom'+t+') transparent;"></td><td style="height:24px;width:23px;"><img src="'+iPop_imagePath+'/local/localgraphics/ds_corner_rtbottom'+t+'" height="24" width="23" ></td></tr></table>';
	pBG.pop=pP;
	
	document.getElementById("popdiv").appendChild(pP);
	document.getElementById(fID).src=objpop.source;
	document.getElementById(fID).contentWindow.pop=pBG;

	objpop.pBG=pBG;
	objpop.pF=document.getElementById(fID);
	objpop.close=function(){
		parent.document.getElementById("lPopFrame"+pPID+py).src=parent.document.location.href;
		document.getElementById("popdiv").removeChild(pBG.pop);
		document.getElementById("popdiv").removeChild(pBG);
		py-=1;
		delete objpop;
		if(!py){document.getElementById("popdiv").style.display="none";}
		if(reloadIt){document.location.reload(true);reloadIt=false;}
	}
	//pBG.onclick=objpop.close;
	document.getElementById(fID).closeP=objpop.close;
	 }

  function RGS_Pop(pH,pW,pT,pL,pS,pID,pST,pTP,pSC){
	this.pHeight=pH;
	this.pWidth=pW;
	this.pTop=pT;
	this.pLeft=pL;
	this.pType=pTP;
	this.source=pS;
	this.pID=pID;
	this.sourceType=pST;
	this.pSC=pSC;
	AX_Pop_Create(this);
 }
function wf(){
	if(py>0){
		for(i=1;i<=py;i++){
				if(dnsp){
					document.getElementById("ipopbg" + i).style.top=document.documentElement.scrollTop+"px";
					document.getElementById("ipopbg" + i).style.left=document.documentElement.scrollLeft+"px";
				}
				else{
					document.getElementById("ipopbg" + i).style.top=document.documentElement.scrollTop+"px";
					document.getElementById("ipopbg" + i).style.left=document.documentElement.scrollLeft+"px";
					document.getElementById("ipop"  + i).style.top=((document.documentElement.clientHeight-parseInt(document.getElementById("ipop" + i).style.height))/2)+document.documentElement.scrollTop+"px";
					document.getElementById("ipop" + i).style.left=((document.documentElement.clientWidth-parseInt(document.getElementById("ipop" + i).style.width))/2)+document.documentElement.scrollLeft+"px";
				}
			}
		}
}
window.onscroll=wf;
window.onresize=wf;
