 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 = jQuery(window).width();
    AX_Height = jQuery(window).height();
    AX_ScrOfY = jQuery(document).scrollTop();
    AX_ScrOfX = jQuery(document).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=((AX_Height-parseInt(objpop.pHeight))/2)+AX_ScrOfY;
    }
    else {
        var dTop=parseInt(AX_ScrOfY)+parseInt(objpop.pTop);
    }
    if (isNaN(objpop.pLeft/objpop.pLeft)){
        var dLeft=((AX_Width-parseInt(objpop.pWidth))/2)+AX_ScrOfX;
    }
    else {
        var dLeft=((AX_Width-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=iPop_imagePath+'local/localbuttons/close03_btn.gif';
        document.getElementById("popdiv").removeChild(pBG.pop);
        document.getElementById("popdiv").removeChild(pBG);
        py-=1;
        delete objpop;
        if(!py){
        //  $('#popdiv').css('visibility','invisible')
        //  document.getElementById("popdiv").style.visibility="invisible";
            //if($.browser.msie && ($.browser.version < 7))$("select").css("visibility","visible");
        }
        if(reloadIt){document.location.reload(true);reloadIt=false;}
    }
    if(objpop.pTP=="close_on_outside_click"){pBG.onclick=objpop.close;}
    document.getElementById(fID).closeP=objpop.close;
    //if($.browser.msie && ($.browser.version < 7)){$("select").css("visibility","hidden");}
 }

  function NTGS_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;
    this.pTP=pTP;
    AX_Pop_Create(this);
 }
function wf(){
    AX_Win_Prop();
    if(py>0){
        for(i=1;i<=py;i++){
                if(dnsp){
                    document.getElementById("ipopbg" + i).style.top=AX_ScrOfY+"px";
                    document.getElementById("ipopbg" + i).style.left=AX_ScrOfX+"px";
                }
                else{
                    //alert (AX_ScrOfY+"px");
                    
                    document.getElementById("ipopbg" + i).style.top=AX_ScrOfY+"px";
                    document.getElementById("ipopbg" + i).style.left=AX_ScrOfX+"px";
					/*
                    document.getElementById("ipop"  + i).style.top=((AX_Height-parseInt(document.getElementById("ipop" + i).style.height))/2)+AX_ScrOfY+"px";
                    document.getElementById("ipop" + i).style.left=((AX_Width-parseInt(document.getElementById("ipop" + i).style.width))/2)+AX_ScrOfX+"px";
					*/
                }
            }
        }
}
window.onscroll=wf;
window.onresize=wf;
