//general //for example: instead of each module writing out script found in modulemaxmin_onclick have the functionality cached // var zhd_col_delimiter = string.fromcharcode(16); var zhd_row_delimiter = string.fromcharcode(15); var __zhd_m_bpageloaded = false; window.onload = __zhd_page_onload; function __zhd_clientapienabled() { return typeof(zhd) != 'undefined'; } function __zhd_page_onload() { if (__zhd_clientapienabled()) { var sloadhandlers = zhd.getvar('__zhd_pageload'); if (sloadhandlers != null) eval(sloadhandlers); zhd.dom.attachevent(window, 'onscroll', __zhd_bodyscroll); } __zhd_m_bpageloaded = true; } function __zhd_keydown(ikeycode, sfunc, e) { if (e == null) e = window.event; if (e.keycode == ikeycode) { eval(unescape(sfunc)); return false; } } function __zhd_bodyscroll() { var of=document.forms[0]; if (__zhd_clientapienabled() && __zhd_m_bpageloaded) of.scrolltop.value=document.documentelement.scrolltop ? document.documentelement.scrolltop : zhd.dom.getbytagname("body")[0].scrolltop; } function __zhd_setscrolltop(itop) { if (__zhd_clientapienabled()) { if (itop == null) itop = document.forms[0].scrolltop.value; var sid = zhd.getvar('scrolltocontrol'); if (sid != null && sid.length > 0) { var octl = zhd.dom.getbyid(sid); if (octl != null) { itop = zhd.dom.positioning.elementtop(octl); zhd.setvar('scrolltocontrol', ''); } } window.scrollto(0, itop); } } //focus logic function __zhd_setinitialfocus(sid) { var octl = zhd.dom.getbyid(sid); if (octl != null && __zhd_canreceivefocus(octl)) octl.focus(); } function __zhd_canreceivefocus(e) { //probably should call getcomputedstyle for classes that cause item to be hidden if (e.style.display != 'none' && e.tabindex > -1 && e.disabled == false && e.style.visible != 'hidden') { var eparent = e.parentelement; while (eparent != null && eparent.tagname != 'body') { if (eparent.style.display == 'none' || eparent.disabled || eparent.style.visible == 'hidden') return false; eparent = eparent.parentelement; } return true; } else return false; } //max/min script function __zhd_containermaxmin_onclick(olnk, scontentid) { var ocontent = zhd.dom.getbyid(scontentid); if (ocontent != null) { var obtn = olnk.childnodes[0]; var scontainerid = olnk.getattribute('containerid'); var scookieid = olnk.getattribute('cookieid'); var scurrentfile = obtn.src.tolowercase().substr(obtn.src.lastindexof('/')); var smaxfile; var smaxicon; var sminicon; if (zhd.getvar('min_icon_' + scontainerid)) sminicon = zhd.getvar('min_icon_' + scontainerid); else sminicon = zhd.getvar('min_icon'); if (zhd.getvar('max_icon_' + scontainerid)) smaxicon = zhd.getvar('max_icon_' + scontainerid); else smaxicon = zhd.getvar('max_icon'); smaxfile = smaxicon.tolowercase().substr(smaxicon.lastindexof('/')); var inum = 5; if (olnk.getattribute('animf') != null) inum = new number(olnk.getattribute('animf')); if (scurrentfile == smaxfile) { obtn.src = sminicon; //ocontent.style.display = ''; zhd.dom.expandelement(ocontent, inum); obtn.title = zhd.getvar('min_text'); if (scookieid != null) { if (zhd.getvar('__zhd_' + scontainerid + ':defminimized') == 'true') zhd.dom.setcookie(scookieid, 'true', 365); else zhd.dom.deletecookie(scookieid); } else zhd.setvar('__zhd_' + scontainerid + '_visible', 'true'); } else { obtn.src = smaxicon; //ocontent.style.display = 'none'; zhd.dom.collapseelement(ocontent, inum); obtn.title = zhd.getvar('max_text'); if (scookieid != null) { if (zhd.getvar('__zhd_' + scontainerid + ':defminimized') == 'true') zhd.dom.deletecookie(scookieid); else zhd.dom.setcookie(scookieid, 'false', 365); } else zhd.setvar('__zhd_' + scontainerid + '_visible', 'false'); } return true; //cancel postback } return false; //failed so do postback } function __zhd_help_onclick(shelpid) { var ohelp = zhd.dom.getbyid(shelpid); if (ohelp != null) { if (ohelp.style.display == 'none') ohelp.style.display = ''; else ohelp.style.display = 'none'; return true; //cancel postback } return false; //failed so do postback } function __zhd_sectionmaxmin(obtn, scontentid) { var ocontent = zhd.dom.getbyid(scontentid); if (ocontent != null) { var smaxicon = obtn.getattribute('max_icon'); var sminicon = obtn.getattribute('min_icon'); var bcallback = obtn.getattribute('userctr') != null; var sval; if (ocontent.style.display == 'none') { obtn.src = sminicon; ocontent.style.display = ''; if (bcallback) sval = 'true'; else zhd.setvar(obtn.id + ':exp', 1); } else { obtn.src = smaxicon; ocontent.style.display = 'none'; if (bcallback) sval = 'false'; else zhd.setvar(obtn.id + ':exp', 0); } if (bcallback) zhdcore.setuserprop(obtn.getattribute('userctr'), obtn.getattribute('userkey'), sval, null); return true; //cancel postback } return false; //failed so do postback } //drag n drop function __zhd_enabledragdrop() { var aryconts = zhd.getvar('__zhd_dragdrop').split(";"); var arytitles; for (var i=0; i < aryconts.length; i++) { arytitles = aryconts[i].split(" "); if (arytitles[0].length > 0) { var octr = zhd.dom.getbyid(arytitles[0]); var otitle = zhd.dom.getbyid(arytitles[1]); if (octr != null && otitle != null) { octr.setattribute('moduleid', arytitles[2]); zhd.dom.positioning.enabledraganddrop(octr, otitle, '__zhd_dragcomplete()', '__zhd_dragover()'); } } } } var __zhd_oprevselpane; var __zhd_oprevselmodule; var __zhd_drageventcount=0; function __zhd_dragover() { __zhd_drageventcount++; if (__zhd_drageventcount % 75 != 0) //only calculate position every 75 events return; var ocont = zhd.dom.getbyid(zhd.dom.positioning.dragctr.contid); var opane = __zhd_getmostselectedpane(zhd.dom.positioning.dragctr); if (__zhd_oprevselpane != null) //reset previous pane's border __zhd_oprevselpane.pane.style.border = __zhd_oprevselpane.origborder; if (opane != null) { __zhd_oprevselpane = opane; opane.pane.style.border = '4px double ' + zhd_highlight_color; var iindex = __zhd_getpanecontrolindex(ocont, opane); var oprevctl; var onextctl; for (var i=0; i i && opane.controls[i].id != ocont.id) oprevctl = opane.controls[i]; if (iindex <= i && opane.controls[i].id != ocont.id) { onextctl = opane.controls[i]; break; } } if (__zhd_oprevselmodule != null) zhd.dom.getnontextnode(__zhd_oprevselmodule.control).style.border = __zhd_oprevselmodule.origborder; if (onextctl != null) { __zhd_oprevselmodule = onextctl; zhd.dom.getnontextnode(onextctl.control).style.bordertop = '5px groove ' + zhd_highlight_color; } else if (oprevctl != null) { __zhd_oprevselmodule = oprevctl; zhd.dom.getnontextnode(oprevctl.control).style.borderbottom = '5px groove ' + zhd_highlight_color; } } } function __zhd_dragcomplete() { var octl = zhd.dom.getbyid(zhd.dom.positioning.dragctr.contid); var smoduleid = octl.getattribute('moduleid'); if (__zhd_oprevselpane != null) __zhd_oprevselpane.pane.style.border = __zhd_oprevselpane.origborder; if (__zhd_oprevselmodule != null) zhd.dom.getnontextnode(__zhd_oprevselmodule.control).style.border = __zhd_oprevselmodule.origborder; var opane = __zhd_getmostselectedpane(zhd.dom.positioning.dragctr); var iindex; if (opane == null) { var opanes = __zhd_panes(); for (var i=0; i 0) __zhd_m_arypanes[__zhd_m_arypanes.length] = new __zhd_pane(zhd.dom.getbyid(arypanes[i]), arypanenames[i]); } } var __zhd_m_arypanes; var __zhd_m_arymodules; function __zhd_panes() { if (__zhd_m_arypanes == null) { __zhd_m_arypanes = new array(); __zhd_refreshpanes(); } return __zhd_m_arypanes; } function __zhd_modules(smoduleid) { if (__zhd_m_arymodules == null) __zhd_refreshpanes(); return __zhd_m_arymodules[smoduleid]; } function __zhd_getmostselectedpane(ocontent) { var ocdims = new zhd.dom.positioning.dims(ocontent); var itopscore=0; var iscore; var otoppane; for (var i=0; i<__zhd_panes().length; i++) { var opane = __zhd_panes()[i]; var opdims = new zhd.dom.positioning.dims(opane.pane); iscore = zhd.dom.positioning.elementoverlapscore(opdims, ocdims); if (iscore > itopscore) { itopscore = iscore; otoppane = opane; } } return otoppane; } function __zhd_getpanecontrolindex(ocontent, opane) { if (opane == null) return; var ocdims = new zhd.dom.positioning.dims(ocontent); var octl; if (opane.controls.length == 0) return 0; for (var i=0; i 0) // onode = onode.childnodes[0]; //zhd now embeds anchor tag var smoduleid = onode.getattribute('moduleid'); if (smoduleid != null && smoduleid.length > 0) { strmoduleorder += smoduleid + '~'; this.controls[this.controls.length] = new __zhd_panecontrol(onode, iindex); __zhd_m_arymodules[smoduleid] = onode.id; iindex+=1; } } } this.moduleorder = strmoduleorder; } function __zhd_panecontrol(ctl, iindex) { this.control = ctl; this.id = ctl.id; this.index = iindex; this.origborder = ctl.style.border; } //move towards zhdcore ns. right now only for personalization function __zhdcore() { this.getuserval = 0; this.setuserval = 1; } __zhdcore.prototype = { getuserprop: function(snamectr, skey, pfunc) { this._dousercallback(zhdcore.getuserval, snamectr, skey, null, new zhdcore.userpropargs(snamectr, skey, pfunc)); }, setuserprop: function(snamectr, skey, sval, pfunc) { this._dousercallback(zhdcore.setuserval, snamectr, skey, sval, new zhdcore.userpropargs(snamectr, skey, pfunc)); }, _dousercallback: function(itype, snamectr, skey, sval, pfunc) { if (zhd && zhd.xmlhttp) { var spack = itype + col_delimiter + snamectr + col_delimiter + skey + col_delimiter + sval; zhd.xmlhttp.docallback('__page',spack,zhdcore._callbacksuccess,pfunc,zhdcore._callbackfail,null,true,null,0); } else alert('client personalization not enabled'); }, _callbacksuccess: function (result, ctx, req) { if (ctx.pfunc) ctx.pfunc(ctx.namingctr, ctx.key, result); }, _callbackfail: function (result, ctx) { window.status = result; } } __zhdcore.prototype.userpropargs = function(snamectr, skey, pfunc) { this.namingctr = snamectr; this.key = skey; this.pfunc = pfunc; } var zhdcore = new __zhdcore();