/*
######################################################################################
######                                                                        #######
######     BUTTON SCRIPTS			                                         #######
######                                                                      #######
##################################################################################
*/

	var inputButtons	= new Object();

/********************************************************************************/
/***** BUTTON ROLLOVER *********************************************************/
/******************************************************************************/

/***** get the functions started *****/

	inputButtons.Start = function() {
		inputButtons.List();
	}
	
	
/***** GENERATE FULL BUTTON LIST *****/
	
	inputButtons.List = function() {
		var inputList = document.getElementsByTagName('input');
		
		for(var i = 0; i < inputList.length; i++) {
			var inputType	= inputList[i].type; 
			var inputButton	= inputList[i];

			if(inputType == 'image' || inputType == 'submit' || inputType == 'button' || inputType == 'reset') {
				inputButtons.Events(inputButton);
			}
		}
	}


/***** ASSIGN EVENTS TO THE BUTTONS *****/
	
	inputButtons.Events = function(inputButton) {
		Event.observe(inputButton, 'mouseover', function() { inputButtons.Rollover(inputButton); } );
		Event.observe(inputButton, 'mouseout', function() { inputButtons.Rollover(inputButton); } );
		Event.observe(inputButton, 'focus', function() { inputButtons.Rollover(inputButton); } );
		Event.observe(inputButton, 'blur', function() { inputButtons.Rollover(inputButton); } );
		Event.observe(inputButton, 'click', function() { inputButtons.HiddenTrick(inputButton); } );
	}
	
	
/***** BUTTON ROLLOVER *****/
	
	inputButtons.Rollover = function(inputButton)
	{
		var newClassName = inputButton.className.split("-");
	
		if(newClassName[1] == 'active') {
			inputButton.className = newClassName[0];
		} else {
			inputButton.className = newClassName[0] + '-active';
		}
	}
	
	
/***** BUTTON SUBMISSION TRICK *****/
	
	inputButtons.HiddenTrick = function(inputButton)
	{
		inputButton = $(inputButton);
		var inputParent = inputButton.up();
		var hidden = new Element('input', {
			type: 'hidden',
			id: inputButton.id,
			name: inputButton.name,
			value: inputButton.value
			});
		
		hidden.setStyle({
			position: 'absolute',
			width: '0',
			height: '0',
			overflow: 'hidden'
		})
		
		inputParent.appendChild(hidden);
		this.disabled = true;
	}
	
	Event.observe(window, 'load', function() { inputButtons.Start() } );