function Button( name, onSource, offSource, downSource ) {
	this.name = name;

	if( onSource ) {
		this.onState = new Image();
		this.onState.src = onSource;
	}

	if( offSource ) {
		this.offState = new Image();
		this.offState.src = offSource;
	}

	if( !( downSource ) ) {
		downSource = onSource;
	}

	if( downSource ) {
		this.downState = new Image();
		this.downState.src = downSource;
	}

	this.currentDown = null;
};

Button.prototype = {

lightup:function() {
	if( this.onState ) {
		document[ this.name ].src = this.onState.src;
	}
},
turnoff:function() {
	if( this.offState ) {
		document[ this.name ].src = this.offState.src;
	}
},
turndown:function() {
	if( this.downState ) {
		document[ this.name ].src = this.downState.src;
	}
}

};

function Buttons() {
	this.elements = {};
};

Buttons.prototype = {

getButton:function( name ) {
	return( this.elements[ name ] );
},
addButton:function( button ) {
	this.elements[ button.name ] = button;
},
removeButton:function( button ) {
	delete this.elements[ button.name ];
},
pushdown:function( name ) {
	var saveCurrent = this.currentDown;
	this.currentDown = name;

	if( saveCurrent ) {
		this.turnoff( saveCurrent );
	}

	if( name ) {
		this.turndown( name );
	}
},
lightup:function( name ) {	
	if( this.currentDown != name ) {
		this.doLightup( name );
	}
},
doLightup:function( name ) {
	var button = this.getButton( name );
	if( button ) {
		button.lightup();
	}
},
turnoff:function( name ) {
	if( !( this.currentDown == name ) ) {
		this.doTurnoff( name );
	}
},
doTurnoff:function( name ) {
	var button = this.getButton( name );

	if( button ) {
		button.turnoff();
	}
},
turndown:function( name ) {
	this.doTurndown( name );
},
doTurndown:function( name ) {
	var button = this.getButton( name );

	if( button ) {
		button.turndown();
	}
}

};
