
btns={};ButtonComponent=Class.create();ButtonComponent.prototype={initialize:function(parent,target,icon,label,action,disable_behaviour,openWin){this.parent=parent;if(typeof(target)=='string'){this.id=target;this.self=$(this.id);}else{this.self=target;this.id=target.id?target.id:target.name;}
if(action){if(openWin){this.action=function(){window.open(action);};}else{this.action=function(){document.location=action;};}}
this.injectBehaviour(icon,label,action,disable_behaviour);},injectBehaviour:function(icon,label,action,disable_behaviour){this.self.className='button';if(this.self.getElementsByTagName('div').length>=4){this.self.innerHTML='';}
this.createBtnStructure(icon,label);if(!disable_behaviour){this.self.onclick=this.click.bindAsEventListener(this);this.self.onmouseover=this.over.bindAsEventListener(this);this.self.onmouseout=this.out.bindAsEventListener(this);}},createBtnStructure:function(icon,label){var lcap=document.createElement('div');lcap.className='leftcap';if(icon){var icon_div=document.createElement('div');icon_div.className='icon';var img=document.createElement('img');img.src=icon;img.border=0;icon_div.appendChild(img);}
if(label){var label_div=document.createElement('div');label_div.className='btn_labels';label_div.appendChild(document.createTextNode(label));}
var rcap=document.createElement('div');rcap.className='rightcap';this.self.appendChild(lcap);if(icon){this.self.appendChild(icon_div);this.icon=icon_div;}
if(label){this.self.appendChild(label_div);this.label=label_div;}
this.self.appendChild(rcap);},click:function(e){if(!this.disabled&&this.action){this.action();}},over:function(e){if(!this.disabled){this.self.style.cursor='pointer';}},out:function(e){if(!this.disabled){this.self.style.cursor='';}},setAction:function(func){this.action=func.bindAsEventListener(this.parent);},disable:function(){this.disabled=true;new Effect.Opacity(this.id,{duration:0.0,from:1.0,to:0.5});},enable:function(){this.disabled=false;new Effect.Opacity(this.id,{duration:0.0,from:0.5,to:1.0});}};
