//~ pcDAbase.js - DHTML base obj & utilities for pcDynAPI.
//~ COPYRIGHT PHILIP CHALMERS 2002, ALL RIGHTS RESERVED
//~ Website www.benefit-from-it.co.uk
pcDAut={setInheritance:function(c,s){c.prototype=new s;c.prototype._pcOBclass=c;c._pcOBsuper=s;},getClass:function(o){return o._pcOBclass},isInstanceOf:function(o,fSC){var c=pcDAut.getClass(o);if(c==fSC)return true;while(c._pcOBsuper){c=c._pcOBsuper;if(c==fSC){return true}}return false;},addUniqueToArray:function(array,elem){for(var i=0;i<array.length;i++)if(array[i]==elem)return;array.push(elem);},removeFromArray:function(array,index,id){var which=(typeof(index)=="object")?index:array[index];if(id)delete array[which.id];else for(var i=0;i<array.length;i++)if(array[i]==which){if(array.splice)array.splice(i,1);else{for(var x=i;x<array.length-1;x++)array[x]=array[x+1];array.length-=1;}}return array;},arrayToAssocArray:function(a){var r=[];for(var i=0;i<(a.length/2);i++)r[a[i*2]]=a[i*2+1];return r;},listToAssocArray:function(){return pcDAut.arrayToAssocArray(arguments);},getRand:function(){var x=Math.random().toString();if(x.substr(0,1)=='.')x='0'+x;return parseFloat(x);}};function pcDAobj(){this.children=[];this.parent=null;this._isChild=false;this._id="_pcDAobj"+pcDAobj._count++;var oBI=pcBrowserInfo._o;this._brModel=oBI.modelType;this._brCode=oBI.brCode;this._oBrInf=oBI;this._status='new';this._elm=null;this._body=null;this._tgt=null;this._lstnsFor=[];this._lstnsTo=[];this._cssCls='';this.announceEvent('pcDAcreate');};pcDAut.setInheritance(pcDAobj,Object);pcDAobj._count=0;pcDAobj.prototype.addChild=function(c,noevt){c.parent=this;if(this._status=='built')c._build(noevt);pcDAut.addUniqueToArray(this.children,c);if(noevt !=false)c.announceEvent('pcDAadd');return c;};pcDAobj.prototype._build=function(noevt){this._subBuild();this._status='built';if(noevt !=false)this.announceEvent('pcDAbuild');for(var i=0;i<this.children.length;i++)this.children[i]._build();};pcDAobj.prototype._reGenKids=function(){var tc=this.children;var tcl=tc.length;for(var i=0;i<tc.length;i++)if(tc[i]._status=='built'){tc[i]._subBuild(true);tc[i]._reGenKids();}};pcDAobj.prototype.removeChild=function(c,noevt){var tc=this.children;var tcl=tc.length;for(var i=0;i<tcl&&tc[i]!=c;i++);if(i !=tcl){c._subRemove();c._status='removed';c.parent=null;tc[i]=tc[tcl-1];tc.pop();if(noevt !=false)c.announceEvent('pcDAremove');return c;}else return null;};pcDAobj.prototype.removeAllChildren=function(noevt){var tc=this.children;var rmvd=[];for(var i=tc.length-1;i>-1;i--)rmvd.push(this.removeChild(tc[i]),noevt);return rmvd.reverse();};pcDAobj.prototype.removeFromParent=function(noevt){if(this.parent)this.parent.removeChild(this,noevt);};pcDAobj.prototype.deleteChild=function(c,noevt){var tc=this.children;var tcl=tc.length;for(var i=0;i<tcl&&tc[i]!=c;i++);if(i !=tcl)c.del(noevt);};pcDAobj.prototype.deleteAllChildren=function(noevt){var tc=this.children;for(var i=tc.length-1;i>-1;i--)tc[i].del(noevt);};pcDAobj.prototype.del=function(noevt){this.deleteAllChildren();this.removeFromParent(noevt);this._subDel();this._status='deleted';this.announceEvent('pcDAdelete');};pcDAobj.prototype.isInstanceOf=function(fSC){return pcDAut.isInstanceOf(this,fSC);};pcDAobj.prototype.getClass=function(){return pcDAut.getClass(this);};pcDAobj.prototype.isContainerOf=function(o,b){return o.isContainedBy(this,b);};pcDAobj.prototype.isContainedBy=function(o,b){var p=(b)?this:this.parent;while(p){if(p==o)return true;p=p.parent;}return false;};pcDAobj.prototype._badBrowser=function(s1,s2){if(typeof s1=='undefined')var s1='';if(typeof s2=='undefined')var s2='';onerror=null;if(!pcDAobj._pcDAbadBrowser)alert('Sorry, your browser cannot display this page properly.\n\nThis page needs one of:\nMS Internet Explorer version 4 or higher\nA browser which supports the W3C DOM '+s1+'\n   for example Netscape 6.1 or higher\nNetscape 4'+s2);pcDAobj._pcDAbadBrowser=true;};pcDAobj.prototype._subBuild=pcDAobj.prototype._subRemove=pcDAobj.prototype._subDel=pcDAobj.prototype.announceEvent=function(){};pcDAobj.prototype.getX=pcDAobj.prototype.getY=pcDAobj.prototype.getPageX=pcDAobj.prototype.getPageY=function(){return 0};function pcDAbase(){var oDB=pcDAbase._o;if(oDB)return oDB;this._suprCl=pcDAobj;this._suprCl();this._wRszHndlrs=[];this._wLdHndlrs=[];this._wUldHndlrs=[];this._pkgName='pcDynAPI - Philip Chalmers\' DHTML library';this._vsn='1.0';var oBI=pcBrowserInfo._o;var biMT=oBI.modelType;if(biMT !='msie'&&biMT !='w3cdom'&&biMT !='ns4')this._badBrowser();var Ap=Array.prototype;if(!Ap.pop||!Ap.push||!Ap.splice||!Ap.join)this._badBrowser('','\n\n We also need some standard array methods which your browser does not support - pop, push, splice and join');oBI._ie=(oBI.modelType=='msie');oBI._dom=(oBI.modelType=='w3cdom');oBI._ns4=(oBI.modelType=='ns4');oBI._def=(oBI._ie||oBI._dom);}pcDAut.setInheritance(pcDAbase,pcDAobj);pcDAbase.prototype.addWinOnLoad=function(tFn){this._wLdHndlrs.push(tFn);return this._wLdHndlrs.length-1;};pcDAbase.prototype.cancelWinOnLoad=function(i){this._wLdHndlrs[i]='';};pcDAbase.prototype.addWinOnResize=function(tFn){this._wRszHndlrs.push(tFn);return this._wRszHndlrs.length-1;};pcDAbase.prototype.cancelWinOnResize=function(i){this._wRszHndlrs[i]='';};pcDAbase.prototype.addWinOnUnload=function(tFn){this._wRszHndlrs.push(tFn);return this._wUldHndlrs.length-1;};pcDAbase.prototype.cancelWinOnUnload=function(i){this._wUldHndlrs[i]='';};pcDAbase.prototype._handleWinResize=function(){if(this._brModel=='ns4')this._reGenKids();if(this.onResize)this.onResize();if(this._wRszHndlrs)eval(this._wRszHndlrs.join(';'));};pcDAbase.prototype.getWidth=pcDAbase.prototype.getContentWidth=pcDAbase.prototype.getDocWidth=function(){switch(this._brModel){case "msie":return document.body.scrollWidth;break;case "ns4":case "w3cdom":return document.width;}};pcDAbase.prototype.getHeight=pcDAbase.prototype.getContentHeight=pcDAbase.prototype.getDocHeight=function(){switch(this._brModel){case "msie":return document.body.scrollHeight;break;case "w3cdom":case "ns4":return document.height;}};pcDAbase.prototype.getDocScrollX=function(){switch(this._brModel){case "msie":return document.body.scrollLeft;break;case "w3cdom":case "ns4":return window.pageXOffset;}};pcDAbase.prototype.getDocScrollY=function(){switch(this._brModel){case "msie":return document.body.scrollTop;break;case "w3cdom":case "ns4":return window.pageYOffset;}};pcDAbase.prototype.getWinInnerWidth=function(){switch(this._brModel){case "msie":return document.body.clientWidth;break;case "w3cdom":case "ns4":return window.innerWidth;}};pcDAbase.prototype.getWinInnerHeight=function(){switch(this._brModel){case "msie":return document.body.clientHeight;break;case "w3cdom":case "ns4":return window.innerHeight;}};pcDAbase.prototype.setWinSizeAbs=function(iW,iH){switch(this._brModel){case "ns4":top.outerWidth=iW;top.outerHeight=iH;break;case 'msie':case 'w3cdom':top.resizeTo(iW,iH);break;}};pcDAbase.prototype.setWinSizePct=function _setWinSizePct(iW,iH){iW=Math.ceil(iW/100);iH=Math.ceil(iH/100);switch(this._brModel){case "ns4":case 'w3cdom':this.setWinSizeAbs(iW*screen.availWidth,iH*screen.availHeight);break;case 'msie':top.resizeTo(argW*(screen.availWidth+8),argH*(screen.availHeight+8));break;}};pcDAbase.prototype.maxWin=function(){switch(this._brModel){case "ns4":top.moveTo(0,0);top.outerWidth=screen.availWidth;top.outerHeight=screen.availHeight;break;case 'w3cdom':top.moveTo(0,0);top.resizeTo(screen.availWidth,screen.availHeight);break;case 'msie':top.moveTo(-4,-4);top.resizeTo(screen.availWidth+8,screen.availHeight+8);}};pcDAbase.prototype.getImgPageX=function(oImg){switch(this._brModel){case "ns4":if(oImg.container !=null)return oImg.container.pageX+oImg.x;else return oImg.x;break;case "w3cdom":case "msie":var x,c;x=0;c=oImg;while(c.offsetParent !=null){x+=c.offsetLeft;c=c.offsetParent;}x+=c.offsetLeft;return x;}};pcDAbase.prototype.getImgPageY=function(oImg){switch(this._brModel){case "ns4":if(oImg.container !=null)return oImg.container.pageY+oImg.y;else return oImg.y;break;case "w3cdom":case "msie":var x,c;y=0;c=oImg;while(c.offsetParent !=null){y+=c.offsetTop;c=c.offsetParent;}y+=c.offsetTop;return y;}};pcDAbase.prototype.getObjByNameFromColl=function(sName,sColl){switch(this._brModel){case 'ns4':return getObjNS4(sName,sColl,document);break;case 'w3cdom':case 'msie':var i,j,c=document[sColl];if(c){for(i=0;i<c.length;i++)if(c[i].name==sName)return c[i];}return null;}function getObjNS4(sName,sColl,oDoc){var i,o;var c=oDoc[sColl];if(c){for(i=0;i<c.length;i++)if(c[i].name==sName)return c[i];}for(i=0;i<oDoc.layers.length;i++){if((o=getObjNS4(sName,sColl,oDoc.layers[i].document))!=null){o.container=oDoc.layers[i];return o;}}return null;}};pcDAbase.prototype.writeHTML=function(sHTML){document.close();if(this._brCode=='ie4'){saveX=this.getDocScrollX();saveY=this.getDocScrollY();window.scrollTo(this.getDocWidth(),this.getDocHeight());}document.open();document.writeln(sHTML);document.close();if(this._brCode=='ie4')window.scrollTo(saveX,saveY);};pcDAbase.prototype.getAttr=function(oObj,sAttr){switch(this._brModel){case 'ns4':case 'msie':return oObj[sAttr];break;case 'w3cdom':return oObj.getAttribute(sAttr);}};pcDAbase.prototype.getContainerDAobjOf=function(oEl){if(!oEl)return null;var oBI=pcBrowserInfo._o;if(oBI._def&&!oBI._ie)while(!oEl._pcDAobj&&oEl.parentNode&&oEl.parentNode !=oEl)oEl=oEl.parentNode;else if(oBI._ie)while(!oEl._pcDAobj&&oEl.parentElement&&oEl.parentElement !=oEl)oEl=oEl.parentElement;return(oEl._pcDAobj)?oEl._pcDAobj:null;};pcDAbase._o=new pcDAbase();if(window.onload)pcDAbase._o._exWonLd=window.onload;window.onload=function(){if(pcDAbase._o._exWonLd)pcDAbase._o._exWonLd();var oDB=pcDAbase._o;var doc=document;if(typeof doc.body=='undefined'&&this._brModel=='w3cdom')doc.body=doc.getElementsByTagName('body').item(0);var oBI=pcBrowserInfo._o;oDB._elm=(oBI._dom)?doc.body:((oBI._ns4)?window:doc);oDB._body=(oBI._dom)?doc.body:doc;oDB._tgt=(oBI._ie)?doc.body:doc;oDB._tgt._pcDAobj=oDB;oDB._build();if(oDB.onLoad)oDB.onLoad();if(oDB._wLdHndlrs)eval(oDB._wLdHndlrs.join(";"));if(window.onresize)oDB._exWonRsz=window.onresize;window.onresize=function(){if(oDB._exWonRsz)oDB._exWonRsz();oDB._handleWinResize();};};if(window.onunload)pcDAbase._o._exWonUld=window.onunload;window.onunload=function(){var oDB=pcDAbase._o;if(oDB._wUldHndlrs)eval(oDB._wUldHndlrs.join(";"));if(oDB.onUnload)oDB.onUnload();if(oDB._exWonUld)oDB._exWonUld();};
