function Buttons(){}Buttons.buttons={};Buttons.initialized=false;Buttons.register=function(e,a,d,c){var b;
b=new Button(e,a,d,c);Buttons.buttons[e]=b;return b};Buttons.init=function(){var a;
if(!Buttons.initialized){for(a in Buttons.buttons){Buttons.buttons[a].init()}}Buttons.initialized=true
};Buttons.getButton=function(a){if(typeof(a)=="string"){return Buttons.buttons[a]
}else{return Buttons.buttons[a.id]}};Buttons.getToggleGroupButtons=function(c){var d,a,b;
a=[];for(d in Buttons.buttons){b=Buttons.buttons[d];if(b.getToggleGroup()==c){a.push(b)
}}return a};Buttons.exists=function(a){return Buttons.getButton(a)!==undefined};Buttons.disable=function(a){if(!a){return false
}if(!Buttons.initialized){return false}return Buttons.getButton(a).disable()};Buttons.setEnabled=function(b,a){if(!b){return false
}if(!Buttons.initialized){return false}return Buttons.getButton(b).setEnabled(a)};
Buttons.enable=function(a){if(!a){return false}if(!Buttons.initialized){return false
}return Buttons.getButton(a).enable()};if(typeof(onLoadHandler)!="undefined"){onLoadHandler.add(Buttons.init)
}function Button(d,a,c,b){this.id=d;this.states=a;this.features=c;this.toggleGroup=b;
this.clicked=this.isToggleButton()&&this.isInitiallyDown();this.enabled=!this.isInitiallyDisabled()
}Button.prototype.id=null;Button.prototype.states=0;Button.prototype.features=0;Button.prototype.images=null;
Button.prototype.clickUnlocked=false;Button.prototype.clicked=false;Button.prototype.enabled=true;
Button.prototype.onenable=null;Button.prototype.ondisable=null;Button.prototype.toggleGroup=null;
Button.prototype.type=null;Button.TYPE_INPUT="input";Button.TYPE_IMG="img";Button.prototype.init=function(){this.element=document.getElementById(this.id);
if(!this.element){throw new Error("No button with ID "+this.id+" found in document")
}this.type=(this.element.tagName=="INPUT")?Button.TYPE_INPUT:Button.TYPE_IMG;this.element.control=this;
this.images={};this.loadImages();this.setupEvents()};Button.prototype.loadImages=function(){var a,b;
b=this.element.src;a=new Image();a.src=this.getStateFilename(b,"up");this.images.up=a;
if(this.hasOffState()){a=new Image();a.src=this.getStateFilename(b,"off");this.images.off=a
}if(this.hasDownState()){a=new Image();a.src=this.getStateFilename(b,"down");this.images.down=a
}if(this.hasOverState()){a=new Image();a.src=this.getStateFilename(b,"over");this.images.over=a
}};Button.prototype.setupEvents=function(){var a;a=this.element;this.onmouseover=a.onmouseover;
this.onmouseup=a.onmouseup;this.onmousedown=a.onmousedown;this.onmouseout=a.onmouseout;
this.onclick=a.onclick;this.ondblclick=a.ondblclick;a.onmouseover=this.handleMouseOver;
a.onmousedown=this.handleMouseDown;a.onmouseup=null;a.onmouseout=null;a.onclick=this.handleClick;
a.ondblclick=this.handleDblClick};Button.prototype.handleMouseOver=function(a){if(this.control){return this.control.handleMouseOver(a?a:event)
}if(!this.enabled){return false}this.element.onmouseout=this.handleMouseOut;if(this.hasOverState()&&!this.clicked){this.element.src=this.images.over.src
}if(this.onmouseover){return this.onmouseover()}return false};Button.prototype.handleMouseDown=function(a){if(this.control){return this.control.handleMouseDown(a?a:event)
}if(!this.enabled){return false}this.clickUnlocked=true;this.element.onmouseup=this.handleMouseUp;
this.element.onmouseout=this.handleMouseOut;if(this.hasDownState()){this.element.src=this.images.down.src
}if(this.onmousedown){return this.onmousedown()}return false};Button.prototype.handleMouseOut=function(a){if(this.control){return this.control.handleMouseOut(a?a:event)
}this.clickUnlocked=false;this.element.onmouseup=null;this.element.onmouseout=null;
if(this.enabled){if(this.clicked&&this.hasDownState()){this.element.src=this.images.down.src
}else{this.element.src=this.images.up.src}}if(this.onmouseout){return this.onmouseout()
}return false};Button.prototype.handleMouseUp=function(a){if(this.control){return this.control.handleMouseUp(a?a:event)
}this.element.onmouseup=null;if(this.enabled){if(this.hasOverState()&&!this.clicked){this.element.src=this.images.over.src
}else{if(this.clicked&&this.hasDownState()){this.element.src=this.images.down.src
}else{this.element.src=this.images.up.src}}}if(this.onmouseup){return this.onmouseup()
}return false};Button.prototype.handleClick=function(a){if(this.control){return this.control.handleClick(a?a:event)
}if(!this.enabled){return false}if(!this.clickUnlocked&&this.type==Button.TYPE_IMG){return false
}if(this.isToggleButton()){this.toggle()}if(this.onclick){if(this.onclick()===false){return false
}}if(this.isOneClickButton()){this.disable()}return true};Button.prototype.handleDblClick=function(a){if(this.control){return this.control.handleDblClick(a?a:event)
}if(this.ondblclick){return this.ondblclick()}return false};Button.prototype.getStateFilename=function(d,e){var g,b,f,a,c;
f=d.lastIndexOf(".");g=d.substr(f);c=d.lastIndexOf("/");a=d.lastIndexOf("_");b=d.substr(0,(a>=0&&a>c)?a:f);
if(e!="up"&&e!=""){b+="_"+e}b+=g;return b};Button.prototype.hasDownState=function(){return(this.states&4)==4
};Button.prototype.hasOverState=function(){return(this.states&2)==2};Button.prototype.hasOffState=function(){return(this.states&1)==1
};Button.prototype.isToggleButton=function(){return(this.features&1)==1};Button.prototype.isOneClickButton=function(){return(this.features&2)==2
};Button.prototype.isInitiallyDown=function(){return(this.features&4)==4};Button.prototype.isInitiallyDisabled=function(){return(this.features&8)==8
};Button.prototype.getToggleGroup=function(){return this.toggleGroup};Button.prototype.disable=function(){if(this.ondisable){if(this.ondisable(this)===false){return false
}}this.enabled=false;if(this.hasOffState()){this.element.src=this.images.off.src}return true
};Button.prototype.setEnabled=function(a){if(a){this.enable()}else{this.disable()
}};Button.prototype.setOnEnable=function(a){this.onenable=a;return this};Button.prototype.setOnDisable=function(a){this.ondisable=a;
return this};Button.prototype.enable=function(){if(this.onenable){if(this.onenable(this)===false){return false
}}this.enabled=true;if(this.clicked&&this.hasDownState()){this.element.src=this.images.down.src
}else{this.element.src=this.images.up.src}return true};Button.prototype.down=function(){this.clicked=true;
if(this.hasDownState()){this.element.src=this.images.down.src}else{this.element.src=this.images.up.src
}};Button.prototype.up=function(){this.clicked=false;this.element.src=this.images.up.src
};Button.prototype.toggle=function(){var d,c,b,a;d=Buttons.getToggleGroupButtons(this.toggleGroup);
if(d.length>1&&this.clicked){return}if(this.clicked){this.up()}else{for(b=0,a=d.length;
b<a;b++){c=d[b];if(c!=this){c.up()}}this.down()}};Button.prototype.click=function(){if(!this.enabled){return
}if(this.isToggleButton()){this.toggle()}if(this.onclick){if(this.onclick()){if(this.isOneClickButton()){this.disable()
}location.href=this.element.parentNode.href}return}if(this.isOneClickButton()){this.disable()
}location.href=this.element.parentNode.href};