
// ---------------------------------------------------------------------------------------------------------//
// TEKBUTTON
		
	function TB_Buid(){
		myTemplate = new Template(this.Template);
		$(this.Target).innerHTML = $(this.Target).innerHTML + myTemplate.evaluate(this.Obj);
		//this.inHTML = $(this.DivId);
		//trace('buikded ' + this.inHTML.className);
		if(this.Rounded){
			Nifty('#' + this.DivId,'transparent');
		}
	}
	
	function TB_ChangeState(state){
		
		//SETS THE STATE
		if(typeof(state) == "undefined"){
			state = this.StateCurrent + 1;
		}
		
		this.StateCurrent = state;
		
		//INVOKES ACTION
			
		
		//PAINT THE BUTTON
		if(this.StateCurrent >= this.States || this.StateCurrent == 0){ //2
			this.StateCurrent = 0;
			this.Paint(this.Baseclass);
		}else{
			this.Paint(this.Baseclass + '_' + this.StateCurrent);
		}
	}
	
	function TB_Click(e){
		//trace('Click ' + this.DivId);
		this.ChangeState();
	}
	
	//MouseOver: Cambia la clase a la clase + _over;
	function TB_MouseOver(e){
		//trace('MouseOver ' + this.DivId);
		this.Paint(this.Baseclass + '_over');
	}

	//MouseOut: Cambia la clase segun el estado actual del boton
	function TB_MouseOut(e){
		//trace('MouseOut ' + this.DivId);
		var newCSSClass = this.Baseclass;
		
		if(this.StateCurrent != 0){
			newCSSClass = newCSSClass + '_' + this.StateCurrent;
		}
		
		this.Paint(newCSSClass);
	}
	
	//Paint pinta el boton segun la ClassCurrent
	function TB_Paint(newCSSClass){
		this.inHTML = $(this.DivId);
		
		this.ClassCurrent = newCSSClass;
		this.inHTML.className = newCSSClass;

	}
	
	function tekButton(obj, display, baseClass, baseName, target, states){
		
		this.Rounded	= false;
		this.Obj 		= Object.clone(obj);
		this.Display	= display;
		this.Baseclass 	= baseClass;
		this.BaseName 	= baseName;
		this.Target		= target;
		this.States 	= states;
		this.Buffer 		= ''
		this.DivId 			= 'div' + baseName + '_' + this.Obj.id; //ID DEL DIV
		this.StateCurrent 	= 0;
		this.StatePrevious 	= '';
		this.inHTML 	= null;
		this.Template 	= '<DIV class="' + baseClass + '" ID="' + this.DivId + '"> \
								<label id="' + this.DivId + '_caption">' + display + '</label> \
							</DIV>';
		
		this.ClassCurrent = baseClass;
		
		//METHODS
		this.Build		= TB_Buid;
		this.ChangeState= TB_ChangeState;
		
		this.Click		= TB_Click;
		this.MouseOver	= TB_MouseOver;
		this.MouseOut	= TB_MouseOut;
		this.Paint		= TB_Paint;
	}


