/* utf8 marker ö */



// ----------------------------------------------------------------
// create the Input class
// ----------------------------------------------------------------
mlvi.Input = function(){
};


mlvi.Input.prototype = {

	// ----------------------------------------------------------------
	// set the events to handle the label
	// ----------------------------------------------------------------
	mlviSaveInputValue: function(){
		//get the input 
		var input = $(this.id);
		//define the actions
		if(input!=null){
			//set the label 
			this.VIcontainer.mlviSetElementLabelText(this.VIelement.mlviIndex, input.value);
			var elem = this.VIcontainer.mlviShowElement(this.VIelement.mlviIndex);
			elem.mlviSelect();
			elem.mlviEditElement();
		}
	},
	
	// ----------------------------------------------------------------
	// set the events to handle the label
	// ----------------------------------------------------------------
	mlviSelectText: function(){
		this.select();
		this.VIcontainer.mlviSetEntryMode(1);
	},


	// ----------------------------------------------------------------
	// set the events to handle the label
	// ----------------------------------------------------------------
	mlviSetEvents: function(){
		if(this.VIcontainer.mlviGetMode()){
			Event.observe(this, 'mousedown', 	this.mlviEventMouseDown.bindAsEventListener(this));
			Event.observe(this, 'focus', 		this.mlviEventFocus.bindAsEventListener(this));
			Event.observe(this, 'change', 		this.mlviEventChange.bindAsEventListener(this));
			Event.observe(this, 'blur', 		this.mlviEventBlur.bindAsEventListener(this));
			Event.observe(this, 'keypress',		this.mlviEventKeyPress.bindAsEventListener(this));
		}
	},	

	// ================================================================
	// EVENT HANDLERS
	// ================================================================

	// ----------------------------------------------------------------
	// mark an element like selected
	// ----------------------------------------------------------------
	mlviEventMouseDown: function(event){
		this.mlviSelectText();
	}, 

	// ----------------------------------------------------------------
	// mark an element like selected
	// ----------------------------------------------------------------
	mlviEventFocus: function(event){
		this.mlviSelectText();
	}, 
	
	// ----------------------------------------------------------------
	// mark an element like selected
	// ----------------------------------------------------------------
	mlviEventChange: function(event){
		this.mlviSaveInputValue();
		this.VIcontainer.mlviSetEntryMode(0);
	}, 
	
	// ----------------------------------------------------------------
	// mark an element like selected
	// ----------------------------------------------------------------
	mlviEventBlur: function(event){
		this.mlviSaveInputValue();
		this.VIcontainer.mlviSetEntryMode(0);
	}, 
	
	// ----------------------------------------------------------------
	// mark an element like selected
	// ----------------------------------------------------------------
	mlviEventKeyPress: function(event){
		if(event.keyCode == Event.KEY_RETURN){
			this.mlviSaveInputValue();
			this.VIcontainer.mlviSetEntryMode(0);
		}
	}, 


	
	NADA: ''

};

