/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Written by Terry Friesen, tfriesen@mts.net  copyright 1998-2001
http://www.mts.net/~tfriesen/

last update: Sept 24, 2001

This script may be used freely on non-commercial web pages
It is not to be sold or profit made from it without the consent of the author
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

function cbSetup(a2,a1){
var w=self,t=true,f=false;
if(a1){w=a1.self?a1:a1.hostElement.frames[a1.name]||a1}
var d=w.document,c=w.Client=navigator;
c.opera5=w.opera?t:f;
c.style=d.styleSheets?t:f;
c.nodes=d.createTextNode?t:f;
c.ns=d.watch?t:f;
c.ns4=c.ns&&!c.nodes;
c.ns5=c.ns&&!c.ns4;
c.ie=w.execScript?t:f;
c.ie4=c.ie&&!c.nodes;
c.ie5=c.ie&&!c.ie4;
var e=a1||w;
var wa=w.Array;
e.frameWindow=w.frameWindow=d.window=w;
w.page=d;
e.cssLayers=d.cssLayers=w.cssLayers=new Array();
w.getParent=getParent;
w.setupEvent=setupEvent;
w.setEventHandler=d.setEventHandler=setEventHandler;
w.sendEvent=d.sendEvent=sendEvent;
w.createEvent=createEvent;
w.doNothing=doNothing;
w.insertElement=insertElement;
w.selectedText=selectedText;
w.setupFrame=setupFrame;
w.setupCollection=setup_Col;
if(wa){
wa.prototype.addMethod=addMethod;
wa.prototype.add_nam=new Array();
wa.prototype.add_func=new Array();
}
if(w.Element){w.Element.prototype.document=d}
if(!w.pxWidth){
w.pxWidth=pxWidth;
w.pxHeight=pxHeight;
w.h_sBar=h_sBar;
w.v_sBar=v_sBar;
}
if(!d.pxWidth){
d.pxWidth=doc_Width;
d.pxHeight=doc_Height;
}
if(!d.self&&!d.Index){d.hostElement=e}
if(!w.offsetTop){
w.offsetTop=offsetTop;
w.offsetLeft=offsetLeft;
}
if(!w.allLayers){w.allLayers=e.allLayers=allLayers}
if(this.runBatch){
if(wa){wa.prototype.runBatch=runBatch}
w.insertCoverLayer=insertCoverLayer
}
if(c.ns4){
if(w.self){
w.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP|Event.MOUSEMOVE|Event.CLICK|Event.DBLCLICK|Event.KEYDOWN|Event.KEYUP|Event.KEYPRESS);
w.onmousedown=w.onmouseup=w.onmousemove=w.onclick=w.ondblclick=w.onkeydown=w.onkeyup=w.onkeypress=ns4_Evt;
}
var lay=d.layers.length?d.layers[0]:false;
while(lay){
var ls=lay.src;
cb_index(lay,ls?t:f,w,e);
lay=ls?lay.siblingAbove:lay.above;
if(lay&&lay.Index){break}
}
orig_Width=innerWidth;
orig_Height=innerHeight;
setEventHandler("resize",ns4_reSize);
}
if(!d.all&&c.style){d.all=d.getElementsByTagName("*")}
if(d.body){
var va=a2||"DIV";
var we=c.ie?d.all.tags(va):d.body.getElementsByTagName(va);
for(var i=0;i<we.length;i++){cb_index(we[i],f,w,e)}
}}

function setupFrame(a1,a2){
var p=this.page;
var f=a1.self?a1:Client.ns4?p.layers[a1]||allLayers[a1]:p.all[a1];
if(!f.self)cb_index(f,true,this,this);
cbSetup(a2,f);
return f;
}

function setup_Col(a1){
for(var ab=0;ab<a1.length;ab++){basicMethods(a1[ab])}
a1.addMethod=addMethod;
}

allLayers=new Array();

function cb_index(lay,noadd,w,e){
var wl=w.cssLayers,al=allLayers;
var ln=lay.layerName=lay.layerName||lay.id||lay.name||("cb_layer"+al.length);
var lw=lay.frameWindow=w.Index?lay:w.frames[ln]||lay;
lay.page=lw.document||document;
lay.hostElement=e;
lay.nextLayer=lay.previousLayer=lay.previous=lay.next=null;
var winl=wl.length,alay=lay.arrayIndex=al.length;
wl[ln]=al[ln]=al[al.length]=lay;
lay.cssLayers=new Array();
if(!noadd){
if(alay>0){lay.previous=al[alay-1];lay.previous.next=lay}
var par=getParent(lay);
lay.isNested=par.Index?true:false;
if(lay.isNested){
var pl=par.cssLayers,parl=pl.length;
pl[ln]=pl[parl]=lay;
if(parl>0){
lay.previousLayer=pl[parl-1];
lay.previousLayer.nextLayer=lay;
}
}
else{
if(winl>0){
lay.previousLayer=wl[winl-1];
lay.previousLayer.nextLayer=lay;
}
}
if(!lay.isNested){wl[winl]=lay;}
}
cb_addon(lay,wl,al);
}

function cb_addon(lay,wl,al){
basicMethods(lay);
if(self.runPath){pathMethods(lay)}
if(self.runBatch){utilityMethods(lay)}
if(self.clipTo){clipMethods(lay)}
if(self.make3d){lay.make3d=make3d}
if(!lay.src){
for(var a=0;a<wl.add_nam.length;a++){lay[wl.add_nam[a]]=wl.add_func[a]}
for(var a=0;a<al.add_nam.length;a++){lay[al.add_nam[a]]=al.add_func[a]}
}
}

function basicMethods(lay){
var lp=lay.page=lay.page||lay;
if(Client.ns4){
lp.pxHeight=doc_Height;
lp.pxWidth=doc_Width;
lay.images=lp.images;
lay.forms=lp.forms;
lay.links=lp.links;
lay.pxHeight=ns_height;
lay.pxWidth=ns_width;
lay.pxLeft=ns_left;
lay.pxTop=ns_top;
lay.Index=ns_index;
lay.Visibility=ns_visible;
lay.innerHTML="";
}
else{
lay.pxHeight=ie_height;
lay.pxWidth=ie_width;
lay.pxLeft=ie_left;
lay.pxTop=ie_top;
lay.page=lay.page==lay.document?lay:lay.page;
lay.Index=ie_index;
lay.Visibility=ie_visible;
lay.load=ie_load;
lay.tags=lay.getElementsByTagName||lay.all.tags;
lay.images=lay.tags("IMG");
lay.forms=lay.tags("FORM");
lay.links=lay.tags("A");
if(Client.ie4){ie4_Width(lay)}
}
lay.moveTo=move_To;
lay.moveBy=move_By;
lay.pxRight=pxRight;
lay.pxBottom=pxBottom;
lay.absLeft=absLeft;
lay.absTop=absTop;
lay.absRight=absRight;
lay.absBottom=absBottom;
lay.resizeTo=resize_To;
lay.resizeBy=resize_By;
lay.setBgColor=setBgColor;
lay.setBgImage=setBgImage;
lay.isNewLayer=false;
lay.percentX=percentX;
lay.percentY=percentY;
lay.posX=posX;
lay.posY=posY;
lay.setEventHandler=lay.page.setEventHandler=setEventHandler;
lay.setContent=setContent;
lay.insertElement=insertElement;
lay.sendEvent=sendEvent;
}

function ns_height(a1){
var c=this.clip;
if(!isNaN(parseInt(a1))){
c.height=String(a1).search('%')>0?this.percentY(a1):a1;
return this;
}
return Math.max(c.height,this.page.height);
}
function ie_height(a1){
var s=this.style;
if(!isNaN(parseInt(a1))){
s.height=(String(a1).search('%')>0?this.percentY(a1):a1)+"px";
return this;
}
return this.offsetHeight||s.pixelHeight;
}

function ns_width(a1){
var c=this.clip;
if(!isNaN(parseInt(a1))){
c.width=String(a1).search('%')>0?this.percentX(a1):a1;
return this;
}
return Math.max(c.width,this.page.width);
}
function ie_width(a1){
var s=this.style;
if(!isNaN(parseInt(a1))){
s.width=(String(a1).search('%')>0?this.percentX(a1):a1)+"px";
return this;
}
return this.offsetWidth||s.pixelWidth;
}

function resize_To(a1,a2){
this.pxWidth(a1);
this.pxHeight(a2);
return this;
}
function resize_By(a1,a2){
this.pxWidth(this.pxWidth()+a1);
this.pxHeight(this.pxHeight()+a2);
return this;
}

function ns_left(a1,a2){
if(!isNaN(parseInt(a1))){
if(!isNaN(a1)){this.x=a1}
else{
this.x=(a1.search('%')>0?this.percentX(a1):this.posX(a1))+(a2||0);
}
return this;
}
return this.x;
}
function ie_left(a1,a2){
var p=self.opera?"":"px",s=this.style;
if(!isNaN(parseInt(a1))){
if(!isNaN(a1)){s.left=a1+p;}
else{
s.left=((a1.search('%')>0?this.percentX(a1):this.posX(a1))+(a2||0))+p;
}
return this;
}
return this.offsetLeft-((this.isNested&&!this.offsetParent)?getParent(this).offsetLeft:0);
}

function ns_top(a1,a2){
if(!isNaN(parseInt(a1))){
if(!isNaN(a1)){this.y=a1}
else{
this.y=(a1.search('%')>0?this.percentY(a1):this.posY(a1))+(a2||0);
}
return this;
}
return this.y;
}
function ie_top(a1,a2){
var p=self.opera?"":"px",s=this.style;
if(!isNaN(parseInt(a1))){
if(!isNaN(a1)){s.top=a1+p}
else{
s.top=((a1.search('%')>0?this.percentY(a1):this.posY(a1))+(a2||0))+p;
}
return this;
}
return this.offsetTop-((this.isNested&&!this.offsetParent)?getParent(this).offsetTop:0);
}

function pxRight(){return this.pxLeft()+this.pxWidth()}
function pxBottom(){return this.pxTop()+this.pxHeight()}

function absLeft(){
var left=this.pageX||this.offsetLeft,p=this.offsetParent;
if(Client.ns4){return this.hostElement.src?left-this.hostElement.pageX:left}
if(p){
while(p){
left+=p.offsetLeft;
p=p.offsetParent;
}
}
return left;
}
function absTop(){
var t=this.pageY||this.offsetTop,p=this.offsetParent;
if(Client.ns4){return this.hostElement.src?t-this.hostElement.pageY:t}
if(p){
while(p){
t+=p.offsetTop;
p=p.offsetParent;
}
}
return t;
}

function absRight(){return this.absLeft()+this.pxWidth()}
function absBottom(){return this.absTop()+this.pxHeight()}

function move_To(a1,a2){
this.pxLeft(a1);
this.pxTop(a2);
return this;
}
function move_By(a1,a2){
this.pxLeft(this.pxLeft()+a1);
this.pxTop(this.pxTop()+a2);
return this;
}

function ns_index(a1){
if(!isNaN(a1)){this.zIndex=a1;return this}
return this.zIndex;
}
function ie_index(a1){
if(!isNaN(a1)){this.style.zIndex=a1;return this}
return this.style.zIndex||0;
}

function ns_visible(a1){
var v=this.visibility;
if(a1){this.visibility=a1;return this}
if(v=='hide')return 'hidden';
if(v=='show')return 'visible';
return 'inherit';
}
function ie_visible(a1){
if(a1){this.style.visibility=a1;return this}
return this.style.visibility||'inherit';
}

function setBgColor(a1){
if(this.style){this.style.backgroundColor=a1||"transparent"}
this.bgColor=a1||null;
return this;
}
function setBgImage(a1){
if(this.style){this.style.backgroundImage="url("+a1+")"}
else{this.background.src=a1||null}
this.bgImage=a1;
return this;
}

function setContent(a1){
if(Client.ns4){with(this.page){write(a1||'');close();}}
this.innerHTML=a1||'';
return this;
}

function insertElement(a1,a2,a3,a4){
if(a1&&allLayers[a1]){
alert("insertElement() failed\nID '"+a1+"' is already in use");
return true;
}
var ln=a1||("cb_layer"+allLayers.length),t=a3||"DIV",p=this,d;
if(Client.style){
if(p.self){p=p.page.body}
if(p.src){p=p.frameWindow.page.body}
if(Client.ie){
var iediv="<"+t+" ID="+ln+" frameBorder=0 style='position:absolute;height:0;top:0;left:0;visibility:hidden;'></"+t+">";
p.insertAdjacentHTML("BeforeEnd",iediv);
d=p.document.all[ln];
}
else{
d=p.document.createElement(t);
with(d.style){position="absolute";top=0;left=0;visibility="hidden"}
d.id=d.name=ln;
d.frameBorder=0;
p.appendChild(d);
}
}
else{
d=new Layer(a2||screen.width,p);
d.zIndex=0;
}
var dh=this.allLayers?this:this.hostElement;
d.layerName=ln;
cb_index(d,a4,dh,dh);
d.isNewLayer=true;
d.pxWidth(a2||0);
return d; 
}

function selectedText(){
var d=this.page;
return d.selection?d.selection.createRange().text:d.getSelection();
}

function ie_load(a1,a2){this.pxWidth(a2);this.src=a1}

function pxWidth(){
return this.v_sBar()?this.innerWidth-16:this.innerWidth||this.page.body.clientWidth;
}
function pxHeight(){
return this.h_sBar()?this.innerHeight-16:this.innerHeight||this.page.body.clientHeight;
}

function offsetTop(){
var w=this.document.body||this;
if(w.clip){return w.clip.top}
return w.scrollTop||this.pageYOffset||0;
}
function offsetLeft(){
var w=this.document.body||this;
if(w.clip){return w.clip.left}
return w.scrollLeft||this.pageXOffset||0;
}

function doc_Height(a1){
var d=this.body||this;
if(Client.ns4&&a1){this.height=a1}
return this.height||d.scrollHeight||0;
}
function doc_Width(a1){
var d=this.body||this;
if(Client.ns4&&a1){this.width=a1}
return this.width||d.scrollWidth||0;
}

function createEvent(a1){
var o=new Object();
o.type=a1;
o.cbEvent=true;
return o
}

function setEventHandler(a1,a2,a3,a4){
var an=a1.toLowerCase(),ae=this["cb"+an];
if(!ae){ae=this["cb"+an]=new Array()}
ae[a3||0]=a2;
ae[0]=ae[0]||0;
if(this.self&&an.search(new RegExp("mouse?|click?|key?","g"))!=-1){alert("mouse/click/key events not allowed on window");return}
this["on"+an]=a4?a2:sendEvent;
}

function ns4_Evt(e){sendEvent.apply(getTarget.apply(e),e)}

function setupEvent(a1){
var h=this,e=a1||h.event,d=new Date(),s;
if(Client.ie4){
var eo=new Object();
for(s in e){eo[s]=e[s]}
e=eo
}
if(Client.ie||h.opera){
var eb=e.button,bd=h.document.body;
if(eb==2){e.click=3}
if(eb==4){e.click=2}
e.pageX=e.clientX+(bd.scrollLeft||0);
e.pageY=e.clientY+(bd.scrollTop||0);
}
e.time=d.getTime();
e.window=h;
e.getTarget=getTarget;
e.getLayer=get_Layer;
var r=!h.opera?e.relatedTarget:null;
e.relatedElement=r?r.splitText?r.parentNode:r:e.type=="mouseover"?e.fromElement||e.relatedTarget:e.type=="mouseout"?e.toElement||e.relatedTarget:null;
e.key=e.keyCode||e.which||e.charCode;
e.click=e.which||e.click||1;
if(Client.ns4){
e.clientX=(h.src?e.pageX-h.pageX:e.pageX)-h.offsetLeft();
e.clientY=(h.src?e.pageY-h.pageY:e.pageY)-h.offsetTop();
var m=e.modifiers;
e.altKey=m==1||m==3||m==5||m==7;
e.ctrlKey=m==2||m==3||m==6||m==7;
e.shiftKey=m==4||m==5||m==6||m==7;
}
return e
}

function sendEvent(a1){
var h=(this.hostElement||this).frameWindow||self;
var e=a1||h.event,t=e.type||e;ae=this["cb"+t];
if(this['on'+t]){
e=h.setupEvent(e);
e.caller=this;
if(ae){
e.previous=ae.last||e;
ae.last=e;
this.tmp_m=ae["cb"];
if(this.tmp_m){this.tmp_m(e)}
for(var b=0;b<ae.length;b++){if(ae[b]){this.tmp_m=ae[b];this.tmp_m(e)}}
}
else{this['on'+t](e)}
}
if((Client.ns4||e.cbEvent)&&!e.cancelBubble&&!this.open){getParent(this,1).sendEvent(e)}
}

function get_Layer(a1){
var e=this,et=e.getTarget("lay");
if(a1=="x"){return e.layerX+1||e.pageX-(et.Index?et.absLeft()+1:0)}
if(a1=="y"){return e.layerY+1||e.pageY-(et.Index?et.absTop()+1:0)}
return et;
}

function getTarget(a){
var t=this.target||this.srcElement;
if(a==2){return t.splitText?t:null}
if(t.splitText){t=t.parentNode}
if(a==1){return t.tagName?t:null}
var p=getParent(t);
if(Client.ns4&&t.links&&p&&!p.setupFrame){t=t.__parent__}
if(t.tagName){if(!t.type&&!t.href&&!t.src&&!t.Index)p.tags?t=p:t=t.document;}
return a=="lay"?t.Index?t:p:t
}

function addMethod(a1,a2){
for(var i=0;i<this.length;i++){if(this[i])this[i][a1]=a2}
var n=this.add_nam,f=this.add_func;
n[n.length]=a1;
f[f.length]=a2;
}

function posX(a1){
var num=parseInt(a1)/100,p=getParent(this);
var v=p.pxWidth()*num-this.pxWidth()*num;
return p.layerName?v:v+p.offsetLeft()
}
function posY(a1){
var num=parseInt(a1)/100,p=getParent(this);
var v=p.pxHeight()*num-this.pxHeight()*num;
return p.layerName?v:v+p.offsetTop()
}

function percentX(a1){
var p=getParent(this);
return parseInt(a1)*(Math.max(p.pxWidth(),p.page.pxWidth())/100)
}
function percentY(a1){
var p=getParent(this);
return parseInt(a1)*(Math.max(p.pxHeight(),p.page.pxHeight())/100)
}

function getParent(a1,a2){
var p=a1,w;
if(p){
p=p.form||p;
if(Client.ns4){w=p.parentLayer||p.window||p.__parent__.__parent__}
else{
p=p.parentElement||p.parentNode;
while(p&&!p.layerName){p=p.parentElement||p.parentNode}
if(p){if(p.layerName)return p}
w=a1.window||a1.document.window
}}
return a2&&w.setupFrame?a1.open?w:w.page:w
}

function ie4_Width(a1){if(a1.getAttribute('wrap'))a1.style.width=a1.scrollWidth||a1.offsetWidth}

function h_sBar(){return this.page.width>this.innerWidth}
function v_sBar(){return this.page.height>this.innerHeight}

function ns4_reSize(){if(innerWidth!=orig_Width||innerHeight!=orig_Height)location.reload()}
function doNothing(){}
cbSetup()
