


// Copyright (c) NimbleCat, 2008

/*
* this object implements a button
* 
* */
// make sure that the required includes are there
 if (typeof NC == 'undefined') {
       alert("button.js requires the NC JavaScript framework");
 }
 
 if (typeof NC.widget == 'undefined') {
       alert("button.js requires the NC JavaScript framework");
 }
 
 /*
  * constructor
  */
  
  NC.widget.Button = function( id) {
		var fnSuperClass = NC.widget.Button.superclass.constructor;
		fnSuperClass.call( this, id);
  }
  
  NC.lang.extend(NC.widget.Button, NC.widget.Element, 
  	{
		_mouseOver: function( event)
		{
			var target = NC.core.Event.getEventTarget(event);
			NC.util.Dom.replaceClass( target, target.className, target.className + '-focus');
		},
		
		_mouseOut:function( event)
		{
			var target = NC.core.Event.getEventTarget(event);
			var i = target.className.indexOf(  '-focus');
			if ( i != -1) {
				var baseClass = target.className.substring( 0, i);
				NC.util.Dom.replaceClass( target, target.className , baseClass);
			}
		},

	  	init: function() {
            NC.widget.Button.superclass.init.call(this);
			this.addDomEvent(NC.core.EventType.Mouseover, this._mouseOver, false);
			this.addDomEvent(NC.core.EventType.Mouseout, this._mouseOut, false);
	  		return "init button function";
	  	},


 		render:function() {
 			return "render";
 		}
	  	
  	});
