/*

DHTML SCROLLER v4.0 RC (c) 2001-2005 Angus Turnbull, http://www.twinhelix.com
Altering this notice or redistributing this file is prohibited.

*/

var isDOM=document.getElementById?1:0,isIE=document.all?1:0,isNS4=navigator.appName=='Netscape'&&!isDOM?1:0,isIE4=isIE&&!isDOM?1:0,isOp=self.opera?1:0,isDyn=isDOM||isIE||isNS4;function getRef(i,p){p=!p?document:p.navigator?p.document:p;return isIE?p.all[i]:isDOM?(p.getElementById?p:p.ownerDocument).getElementById(i):isNS4?p.layers[i]:null};function getSty(i,p){var r=getRef(i,p);return r?isNS4?r:r.style:null};if(!self.LayerObj)var LayerObj=new Function('i','p','this.ref=getRef(i,p);this.sty=getSty(i,p);return this');function getLyr(i,p){return new LayerObj(i,p)};function LyrFn(n,f){LayerObj.prototype[n]=new Function('var a=arguments,p=a[0],px=isNS4||isOp?0:"px";with(this){'+f+'}')};LyrFn('x','if(!isNaN(p))sty.left=p+px;else return parseInt(sty.left)');LyrFn('y','if(!isNaN(p))sty.top=p+px;else return parseInt(sty.top)');LyrFn('w','if(p)(isNS4?sty.clip:sty).width=p+px;else return(isNS4?ref.document.width:ref.offsetWidth)');LyrFn('h','if(p)(isNS4?sty.clip:sty).height=p+px;else return(isNS4?ref.document.height:ref.offsetHeight)');LyrFn('vis','sty.visibility=p');LyrFn('clip','if(isNS4)with(sty.clip){left=a[0];top=a[1];right=a[2];bottom=a[3]}else sty.clip="rect("+a[1]+"px "+a[2]+"px "+a[3]+"px "+a[0]+"px)" ');if(!self.page)var page={win:self,minW:0,minH:0,MS:isIE&&!isOp};page.db=function(p){with(this.win.document)return(isDOM?documentElement[p]:0)||body[p]||0};page.winW=function(){with(this)return Math.max(minW,MS?db('clientWidth'):win.innerWidth)};page.winH=function(){with(this)return Math.max(minH,MS?db('clientHeight'):win.innerHeight)};page.scrollY=function(){with(this)return MS?db('scrollTop'):win.pageYOffset};page.elmPos=function(e,p){var x=0,y=0,w=p?p:this.win;e=e?(e.substr?(isNS4?w.document.anchors[e]:getRef(e,w)):e):p;if(isNS4){if(e&&(e!=p)){x=e.x;y=e.y};if(p){x+=p.pageX;y+=p.pageY}}if(e&&this.MS&&navigator.platform.indexOf('Mac')>-1&&e.tagName=='A'){e.onfocus=new Function('with(event){self.tmpX=clientX-offsetX;self.tmpY=clientY-offsetY}');e.focus();x=tmpX;y=tmpY;e.blur()}else while(e){x+=e.offsetLeft;y+=e.offsetTop;e=e.offsetParent}return{x:x,y:y}};function addProps(obj,data,names,addNull){for(var i=0;i<names.length;i++)if(i<data.length||addNull)obj[names[i]]=data[i]};function ScrDiv(){addProps(this,arguments,['id','x','y','w','h','v','par','lyr'],true)};function DHTMLScroller(){var names=['myName','loadingFile','loadedFile','loadedHTML','bookmark','buf','div','bar','thm','loaded','timer','loadFix','noXFrame','divHeight','thmHeight','barHeight','cHeight','cWidth','dragOffset','onbeforeload','onload','onscroll','onsetup','onlayout','onthumbdown','onthumbup'];addProps(this,arguments,names,true);this.cTop=0;this.history=new Array();this.histPos=-1;this.divs=new Array();this.minThmHeight=20;this.maxThmHeight=9999;this.padTop=this.padBot=0;this.checkBounds=true;this.ySpeed=this.stepsLeft=0;this.stick=1;this.stickTop=0;DHTMLScroller.list[this.myName]=this};DHTMLScroller.list=[];var activeScr=null;var DsPt=DHTMLScroller.prototype;DsPt.load=function(fName){with(this){if(!fName||fName=='#'||!loaded||!isDyn)return;if(fName.match(/^(.*)#(.*)$/)){var r=RegExp;bookmark=r.$2;if(!r.$1||r.$1==loadedFile){fileLoaded();return}fName=r.$1}else bookmark='';loadingFile=fName;if(onbeforeload)onbeforeload();if(fName!=history[histPos]){histPos++;history[histPos]=fName;history.length=histPos+1}if(isOp&&!document.documentElement){fileLoaded();return}if(isIE||isDOM)with(isOp?getRef(myName+'Buf').contentDocument:buf.document){if(document.readyState){location.href=fName;setTimeout(myName+'.checkState()',100)}else{write('<html><body onload="setTimeout(\'parent.'+myName+'.swapContent()\',100)"><iframe name="nestBuf" src="'+fName+'"></iframe></body></html>');close();if(!buf.nestBuf){buf.location.href=fName;setTimeout(myName+'.swapContent()',5000)}}}else if(isNS4){if(window.ns4LayerLoading){setTimeout(myName+'.load("'+fName+'")',100);return}window.ns4LayerLoading=true;div.ref.onload=new Function(myName+'.fileLoaded()');div.ref.load(fName,eval(divs[0].w))}return}};DsPt.checkState=function(){with(this){var b=isOp?getRef(myName+'Buf').contentDocument:buf.document;if(b.location.href!='about:blank'&&b.readyState=='complete')swapContent();else setTimeout(myName+'.checkState()',50)}};DsPt.swapContent=function(){with(this){var bufDoc=buf.nestBuf?buf.nestBuf.document:buf.document;if(bufDoc&&bufDoc.body){loadedHTML=bufDoc.body.innerHTML;buf.location.replace('about:blank');setTimeout('with('+myName+'){div.ref.innerHTML=loadedHTML;setTimeout("'+myName+'.fileLoaded()",100)}',1)}}};DsPt.fileLoaded=function(){with(this){activeScr=null;if(isNS4){window.ns4LayerLoading=false;var tags=div.ref.document.links;for(var i in tags){tags[i].scrOC=tags[i].onclick;tags[i].onclick=new Function('return(!(this.scrOC?this.scrOC()==false:0))&&'+myName+'.checkURI(this.href)')}}loadedFile=loadingFile;var xfr='',DSL=DHTMLScroller.list;for(var s in DSL)if(!DSL[s].noXFrame&&DSL[s].loadedFile)xfr+=','+DSL[s].myName+'='+DSL[s].loadedFile;if(xfr&&isIE&&!noXFrame&&location.search.indexOf('frames(')<0)location.hash='frames('+xfr.substring(1)+')';layout();var newPos=0;if(isDOM)bookmark=document.getElementsByName(bookmark)[0];if(bookmark){newPos=page.elmPos(bookmark,div.ref).y;if(newPos)newPos-=page.elmPos(null,div.ref).y}scrollTo(newPos);if(onload)onload()}};DsPt.go=function(dir){with(this){histPos+=dir;if(histPos<0){histPos=0;return}if(histPos>=history.length){histPos=history.length-1;return}load(history[histPos])}};DsPt.checkURI=function(uri){with(this){if(uri&&(uri.indexOf(':')<0||uri.match(new RegExp(location.hostname?'^(file|http.?):\/\/[^\/]*'+location.hostname:'^file:')))){var hashPos=location.href.indexOf('#');if(hashPos==-1)hashPos=9999;var locPath=location.href.substring(0,hashPos),r=RegExp;if(uri.match(/(.*)#(.*)/)&&(!r.$1||locPath==r.$1)){if(r.$2)load('#'+r.$2)}else load(uri);return false}return true}};DsPt.scrollTo=function(pos,isStick){with(this){if(!isDyn||!loaded)return;cTop=pos;if(!isStick)stickTop=cTop;divHeight=div.h()+padTop+padBot;if(divHeight==0)divHeight=1;if(checkBounds){if(cTop+cHeight>divHeight)cTop=divHeight-cHeight;if(cTop<0)cTop=0}div.y(0-cTop+padTop);thmHeight=Math.ceil(barHeight*(cHeight/divHeight));with(Math)thmHeight=min(barHeight,min(maxThmHeight,max(thmHeight,minThmHeight)));thm.h(thmHeight);if(onscroll)onscroll();if(activeScr||isStick)return;var fracDivDown=(cTop/(divHeight-cHeight));thm.y(bar.y()+fracDivDown*(barHeight-thmHeight))}};DsPt.scrollBy=function(amount){with(this){scrollTo(cTop+amount)}};DsPt.setScroll=function(newSpeed,steps){with(this){if(!loaded)return;stepsLeft=steps;if(timer)clearInterval(timer);timer=setInterval('with('+myName+'){if(stepsLeft>0){ySpeed+='+((newSpeed-ySpeed)/steps)+';stepsLeft--}else if(parseInt(ySpeed)==0){clearInterval(timer);timer=null}scrollBy(ySpeed)}',50)}};DsPt.thumbDown=function(evt){with(this){var evt=evt?evt:window.event;activeScr=this;dragOffset=(isNS4?evt.pageY:page.scrollY()+evt.clientY)-thm.y();if(onthumbdown)onthumbdown();if(timer)clearInterval(timer);timer=null;return false}};window.scrThumbMove=function(evt){var evt=evt?evt:window.event;if(!activeScr)return true;else with(activeScr){if((cTop+cHeight>divHeight)||(thmHeight==barHeight))return true;var thmTop=(isNS4?evt.pageY:page.scrollY()+evt.clientY)-dragOffset-bar.y();if(thmTop<0)thmTop=0;if(thmTop+thmHeight>barHeight)thmTop=barHeight-thmHeight;thm.y(bar.y()+thmTop);stickTop=(divHeight-cHeight)*(thmTop/(barHeight-thmHeight));if(stick==1)scrollTo(stickTop);else if(!timer)timer=setInterval(myName+'.stickScroll()',40);return false}};window.scrThumbUp=function(evt){if(activeScr)with(activeScr)if(onthumbup)onthumbup();activeScr=null};DsPt.stickScroll=function(){with(this){if(Math.abs(cTop-stickTop)>1){cTop+=(stickTop-cTop)*stick;scrollTo(cTop,true)}else if(cTop!=stickTop){cTop=stickTop;scrollTo(cTop,true)}}};DsPt.barClick=function(evt){with(this){var evt=evt?evt:window.event;clickPos=isNS4?evt.pageY:page.scrollY()+evt.clientY;var thmY=page.elmPos(null,thm.ref).y;if(clickPos<thmY)scrollBy(0-cHeight);if(clickPos>(thmY+thmHeight))scrollBy(cHeight);if(isNS4)return document.routeEvent(evt)}};DsPt.layout=function(){with(this){if(!isDyn||!loaded)return;barHeight=eval(divs[1].h);cWidth=eval(divs[0].w);cHeight=eval(divs[0].h);divs[0].lyr.clip(0,0,cWidth,cHeight);div.vis('inherit');div.w(cWidth);var isSmall=(div.h()<cHeight);for(var i=0;i<divs.length;i++)with(divs[i].lyr){x(eval(divs[i].x));w(Math.max(0,eval(divs[i].w)));y(eval(divs[i].y));h(Math.max(0,eval(divs[i].h)));if(divs[i].v)vis(divs[i].v==1&&isSmall?'hidden':'visible')}if(onlayout)onlayout();scrollBy(0)}};DsPt.setup=function(){with(this){if(!isDyn)return;for(var i=0;i<divs.length;i++)with(divs[i]){par=eval(par);lyr=getLyr(id,par)}div=getLyr(myName+'Inner',isNS4?divs[0].lyr.ref:null);bar=divs[1].lyr;thm=divs[2].lyr;if(!isNS4)buf=eval('window.'+myName+'Buf');if(isNS4){bar.ref.captureEvents(Event.CLICK);thm.ref.captureEvents(Event.MOUSEDOWN)}bar.ref.onclick=new Function('evt','return '+myName+'.barClick(evt)');thm.ref.onmousedown=new Function('evt','return '+myName+'.thumbDown(evt)');thm.ref.ondragstart=new Function('return false');var fileName='';if(location.href.match(/frames\(([^)]+)\)/)){var files=RegExp.$1.split(',');for(var i=0;i<files.length;i++)if(files[i].match(/(\w+)\=(.+)/)&&myName==RegExp.$1)fileName=RegExp.$2}if(onsetup)onsetup();loaded=true;if(fileName)load(fileName);else if(loadingFile)load(loadingFile);else fileLoaded()}};var scrOL=window.onload,scrOR=window.onresize,nsWinW=window.innerWidth,nsWinH=window.innerHeight;document.scrMM=document.onmousemove;document.scrMU=document.onmouseup;document.scrOC=document.onclick;var DSL=DHTMLScroller.list;window.onload=function(){document.write=new Function();if(scrOL)scrOL();for(var s in DSL)DSL[s].setup()};window.onresize=function(){if(scrOR)scrOR();if(isNS4&&(nsWinW!=innerWidth||nsWinH!=innerHeight))location.reload();for(var s in DSL)DSL[s].layout()};if(isNS4)document.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP|Event.CLICK);document.onmousemove=function(evt){var ret=scrThumbMove(evt);if(document.scrMM)return document.scrMM(evt)&&ret;else return ret?isNS4?document.routeEvent(evt):true:false};document.onmouseup=function(evt){scrThumbUp(evt);return document.scrMU?document.scrMU(evt):(isNS4?document.routeEvent(evt):true)};document.onclick=function(evt){evt=evt||window.event;var e=evt.target||evt.srcElement,DSL=DHTMLScroller.list,uri='',ret=1;if(e.nodeType==3)e=e.parentNode;L:while(e){for(var s in DSL){if(e.tagName=='A'){if(!e.target)uri=e.href;if(e.target==DSL[s].myName){ret=DSL[s].checkURI(e.href);break L}}if(uri&&e==DSL[s].div.ref)ret=DSL[s].checkURI(uri)}e=e.parentNode||e.parentElement}if(!ret){evt.cancelBubble=true;evt.returnValue=false}if(document.scrOC)return document.scrOC(evt)&&ret;else return ret?isNS4?document.routeEvent(evt):true:false};document.onselectstart=document.onselect=function(){if(activeScr)return false};
