// Helper Window: object-basedhelpclicked=false; // Builder referencedocument.onmousedown=helperDown;document.onmouseup=helperUp;document.onmousemove=helperDragMove;function helperInit(hid,top,left,wid,hgt,barbg,barfg,txtbg,txtfg,zin,temppg,pth,ttl) {    temppg=temppg || '/backoffice/helper_temp1.htm';    this.helpHist=new Array();    this.helpNum=-1;    this.helpMax=0;    this.hgt=hgt || 300;    this.top=top || 50;    this.adjtop=false;    this.wid=wid || 400;    this.left=left || -1;    this.path=pth || '';    this.minmax='min';    this.id=hid;    this.ttl=ttl || '';    this.loaderOn=false;    this.loaderGif="/backoffice/images/loading.gif";    this.blankDef=false;    this.blankOn=false;    this.blankColor="#cccccc";    this.blankOpac=90;    this.url='';    this.fincod='';    this.post='';    this.get = function (url,ttl,wid,fincod,post,loadob,blank) {        _build=false; //06/22/10: Builder - turn it off        fincod=fincod || '';        post=post || '';        this.url=url;        this.ttl=ttl;        this.fincod=fincod;        this.post=post;        if (typeof loadob=="object") { // Show loader            lnkLoadOn(loadob,this.loadGif);            this.loaderOn=true;            }        if (this.blankDef==true || (blank && blank==true)) {            if (!document.getElementById("BlankObj")) {                var ob=document.createElement('div');                ob.id='BlankObj';                ob.style.left="0px";                ob.style.width="100%";                ob.style.height="100%";                ob.style.backgroundColor=this.blankColor;                ob.style.opacity=this.blankOpac/100;                ob.style.filter="alpha(opacity="+this.blankOpac+")";                ob.style.position="absolute";                ob.style.display="none";                var hob=document.getElementById(this.id);                ob.style.zIndex=hob.style.zIndex-1;                ob.onmousedown=helperDown;                ob.onmouseup=helperUp;                ob.onmousemove=helperDragMove;                document.body.appendChild(ob);                }            else ob=document.getElementById('BlankObj');            ob.style.top=document.body.scrollTop+'px';            ob.style.display="block";            document.body.style.overflow="hidden";            this.blankOn=true;            }        this.helpNum +=1;        this.helpMax = this.helpNum+1;        this.helpHist[this.helpNum]=new Array('',fincod);        if (!post) post='';        if (fincod) {            if (fincod.indexOf('helperadj')<0) {                if (fincod.substr(fincod.length-1,1)!==';') fincod += ';';                fincod += "helperadj('"+hid+"')";                }            }        else {            fincod="helperadj('"+hid+"')";            }        if (wid) this.wid=wid;        if (url.substr(0,1)!='/') url=this.path+url;        url=url.replace(/\?/g,'%3F');        url=url.replace(/\&/g,'%26');        ttl=ttl || this.ttl;        ttl=ttl.replace(/\%/g,'%25'); // 10/07/11        ttl=ttl.replace(/\?/g,'%3F');        ttl=ttl.replace(/\&/g,'%26');        helperXML(this,temppg+'?hid='+hid+'&helpttl='+(ttl||'')+'&barbg='+(barbg||'#000000')+'&barfg='+(barfg||'#ffffff')+'&txtbg='+(txtbg||'#f0f0f0')+'&txtfg='+(txtfg||'#000000')+'&helpurl='+url,post,hid,fincod);        };    this.go = function(num,clscod) { // 10/07/11: clscod for mbf ww_fail.fnc        if (this.helpNum+num>-1 && this.helpNum+num<this.helpMax) {            this.helpNum += num;            var el=document.getElementById(this.id);            el.innerHTML='';            el.style.width=this.wid+'px';            if (el) el.innerHTML=this.helpHist[this.helpNum][0];            eval(this.helpHist[this.helpNum][1]);            helperadj(this.id);            }        else if (clscod) eval(clscod);        }    this.setwidth = function(wid) {        this.wid=wid;        var hob=document.getElementById(this.id);        if (hob) hob.style.width=wid+'px';        }    this.settop = function(top,adj) {        this.top=top;        this.adjtop=adj || false;        var hob=document.getElementById(this.id);        if (hob) hob.style.top=top+'px';        }    this.setleft = function(left) {        this.left=left;        var hob=document.getElementById(this.id);        if (hob) {            if (left==-1) {                hob.style.left='';                hob.style.right='0px';                }            else {                hob.style.right='';                hob.style.left=left+'px';                }            }        } // Create container    var hObj=document.createElement('div');    hObj.id=hid;    hObj.style.position="absolute";    if ((left || -1)==-1)        hObj.style.right='0px';    else        hObj.style.left=left+'px';    hObj.style.width=(this.wid)+'px';    hObj.style.display="none";    hObj.style.top=(this.top)+'px';    hObj.style.zIndex=zin || 9999;    document.body.appendChild(hObj);    }function helper(url,post,fincod,ttl,hid) { // Legacy-compatible    hid=hid || 'helpero';    fincod=fincod || '';    var hob=eval('pop_'+hid);    if (hob)        ttl=ttl || hob.ttl;        hob.get(url,ttl,'',fincod,post);    }function helperadj(hid) {  // Use to resize, called by Builder    hid=hid || 'helpero';    var hob=eval('pop_'+hid);    var hel=document.getElementById(hid);    var tel=document.getElementById('inner_'+hid);    if (!tel) return;  // 01/13/12: causing error in ww_objmap.htm    var testtel=tel;    hel.style.display="block";    var metrics=new helpermetrics();    var top=parseInt(hel.style.top);    var left=parseInt(hel.style.left);// 11/30/11: Always reposition at original pos//    if (top < metrics.wintop || top>=metrics.wintop+metrics.winhgt) {        top=hob.top+metrics.wintop;        hel.style.top=top+'px';//        }    if (hob.minmax=='min') {        if (left < metrics.winleft || left>=metrics.winleft+metrics.winleft) {            left=hob.left+metrics.winleft;            hel.style.left=left+'px';            }        }    else {        var im=document.getElementById('minmax_'+hid);        if (im) {            im.src='/backoffice/images/helper/helper_min_active.png';            im.title='Minimize Window';            }        }    wid=hel.clientWidth;    helperthru(hel);    hel.style.width=wid+'px';    if (hob.hgt !=-1) { // Only set if fixed height given//        tel.style.overflow = 'auto';        tel.style.height=hob.hgt+'px';        }    if (!tel) alert('Lost TEL='+testtel);    else tel.style.overflow = 'auto';//    var h=hob.hgt;//    if (h==-1) h=metrics.winhgt-top;//    tel.style.overflow = 'auto';//    tel.style.height=h+'px';    var h=hel.offsetHeight+10;    if (top-metrics.wintop+h>metrics.winhgt) {        if (hob.adjtop==true) {//Adjust top            if (h>metrics.winhgt) {                hel.style.top=metrics.wintop+'px';                tel.style.overflow = 'auto';                tel.style.height=metrics.winhgt+metrics.wintop-0+'px';                }            else             hel.style.top=metrics.wintop+metrics.winhgt-h+'px';            }        else {            tel.style.overflow = 'auto';            tel.style.height=metrics.winhgt-top+metrics.wintop-40+'px';            }        }    if (tel) {        tel.scrollTop=0;        if (tel.style.overflowX) tel.style.overflowX='hidden';        }    if (hob.loaderOn==true) {        lnkLoadOff();        hob.loaderOn==false;        }    }function helperthru(me) { // Find max width    for (var i=0;i<me.childNodes.length;i++) {        var el=me.childNodes[i];        if (el.nodeType==1) {            if (el.clientWidth>wid) {                 wid=el.clientWidth+30;                }            helperthru(el);            }        }    }function helpergo(num,hid,clscod) {    hid=hid || 'helpero';    clscod=clscod || '';    var hob=eval('pop_'+hid);    if (hob) hob.go(num,clscod);    }function helperreload(hid) { // Reload this helper    hid=hid || 'helpero';    var hob=eval('pop_'+hid);    if (hob)        hob.get(hob.url,hob.ttl,hob.wid,hob.fincod,hob.post);    }function helperclose(hid,term) {    hid=hid || 'helpero';    var el=document.getElementById(hid);    if (el) {        el.style.display="none";        el.innerHTML="";        }    var hob=eval('pop_'+hid);    hob.helpNum=-1;    hob.helpMax=0;    if (hob.blankOn==true) {        document.body.style.overflow="auto";        document.getElementById('BlankObj').style.display="none";        hob.blankOn=false;        }    if (hob.loaderOn==true) {        lnkLoadOff();        hob.loaderOn==false;        }    _build=true;    if (term) {        var hob=eval('pop_'+hid);        document.body.removeChild(hob);        }    }function helperprint(hid) {    hid=hid || 'helpero';    window.open('/backoffice/helperprint.htm?'+hid,'',            'width=800,height=600,scrollbars=1,resizable=1');    }function helperminmax(loc,hid) {    hid=hid || 'helpero';    var hel=document.getElementById(hid);    var hob=eval('pop_'+hid);    var im=document.getElementById('minmax_'+hid);    var metrics=new helpermetrics();    if (hob.minmax=='min') {        var neww=Math.round(.8*metrics.winwid);        var newh=Math.round(.8*metrics.winhgt);        hel.style.width=neww+'px';        var top=Math.round((metrics.winhgt-newh)/2);        hel.style.top=metrics.wintop+top+'px';       hel.style.left=metrics.winleft+Math.round((metrics.winwid-neww)/2)+'px';        if (im) {            im.src='/backoffice/images/helper/helper_min_active.png';            im.title='Minimize Window';            }        hob.minmax='max';        var h=metrics.winhgt;        }    else {        top=hob.top;        hel.style.top=metrics.wintop+hob.top+'px';        hel.style.left=metrics.winleft+hob.left+'px';        wid=hob.wid;        hel.style.width=wid+'px';        helperthru(hel);        hel.style.width=wid+'px';        if (im) {            im.src='/backoffice/images/helper/helper_max_active.png';            im.title='Maximize Window';            }        hob.minmax='min';        var h=hob.hgt;        if (h==-1) {            h=metrics.winhgt;            }        }    hel.style.height="";    if (top-metrics.wintop+hel.offsetHeight+30>h) {        var tel=document.getElementById('inner_'+hid);        tel.style.overflow = 'auto';        tel.style.height=h-top+metrics.wintop-30+'px';        }    }function helpermetrics() {    this.wintop=0;   // Scroll top    this.winleft=0;  // Scroll left    this.winhgt=460;    this.winwid=630;    if (document.body && document.body.offsetWidth) { // IE old        this.winhgt=document.body.offsetHeight;        this.winwid=document.body.offsetWidth;        this.wintop=document.body.scrollTop;        this.winleft=document.body.scrollLeft;        }    if (document.compatMode=='CSS1Compat') { // IE standards        this.winhgt=document.documentElement.offsetHeight;        this.winwid=document.documentElement.offsetWidth;        this.wintop=document.documentElement.scrollTop;        this.winleft=document.documentElement.scrollLeft;        }    if (window.innerHeight) { // Moz, etc        this.winhgt=window.innerHeight;        this.winwid=window.innerWidth;        this.wintop=window.pageYOffset;        this.winleft=window.pageXOffset;        }    }function helperXML(me,url,post,hid,fincod) {    url=url.replace(/#/g,'%23');    var fincode = fincod;    var helpreq=false;    try {        helpreq = new XMLHttpRequest();        }    catch (trymicrosoft) {        try {            helpreq=new ActiveXObject("Msxml2.XMLHTTP");            }        catch (othermicrosoft) {            try {                helpreq=new ActiveXObject("Microsoft.XMLHTTP");                }            catch (failed) {                helpreq=false;                }            }        }    if (helpreq) {        helpreq.onreadystatechange = function () {         if (helpreq.readyState == 4 && helpreq.status == 200) {            el=document.getElementById(hid);            hob=eval('pop_'+hid);            el.style.display="block";            el.innerHTML='';            el.style.width=hob.wid+'px';            el.innerHTML=helpreq.responseText;            if (me.helpNum>=0)                me.helpHist[me.helpNum][0]=helpreq.responseText;            if (typeof axscriptx=='function' ) {  // execute inline script                axscriptx(el);                }            if (fincode !="") {                eval(fincode);                }            }         }        if (post=='') {            helpreq.open("GET",url);            helpreq.send(null);            }        else {            helpreq.open("POST",url);            helpreq.send(post);            }        }    }function helperFlip(img,whi) {    var curSrc=img.src;    curSrc=curSrc.substring(0,curSrc.lastIndexOf('_')+1)+whi;    img.src=curSrc;    }function helperStopBub(evt) {    if (evt.stopPropagation) {        evt.stopPropagation();        evt.preventDefault();        }    else {        evt.cancelBubble = true;        evt.returnValue = false;        }    }function helperDown(evt) {    evt=evt||window.event;    var clicktarget= evt.target || evt.srcElement;    if (clicktarget.nodeType==3) clicktarget=clicktarget.parentNode; //safari    if ((evt.button==1 && window.event!=null || evt.button==0) && clicktarget.className=="helperdrag") {        helperStopBub(evt);        if (clicktarget.id.substr(0,3)=='ttl') {            helpBox=document.getElementById(clicktarget.id.substr(clicktarget.id.indexOf('_')+1));            }        else {            helpBox=clicktarget.parentNode;            }        helpX = evt.pageX || evt.clientX;        helpY = evt.pageY || evt.clientY;        document.body.style.cursor='move';        helpclicked=true;        }    }function helperUp(evt) {    helpclicked=false;    document.body.style.cursor='auto';    }function helperDragMove(evt) {    if (helpclicked) {        evt=evt||window.event;        helperStopBub(evt);        evtx = evt.pageX || evt.clientX;        evty = evt.pageY || evt.clientY;        helpBox.style.left = parseInt(helpBox.style.left)+(evtx-helpX)+'px';        helpBox.style.top = parseInt(helpBox.style.top)+(evty-helpY)+'px';        helpX=evtx;        helpY=evty;        }    }
