// Controls the rollover states for input buttons and submits


/********************************************************************************/
/***** ONLOAD SCRIPTS **********************************************************/
/******************************************************************************/

window.onload = function()
{
	button_elements();
}


/********************************************************************************/
/***** GENERATE FULL BUTTON LIST ***********************************************/
/******************************************************************************/

function button_elements()
{
	var InputList = document.getElementsByTagName('input');
	
	for (var i = 0; i < InputList.length; i++)
	{ 
		var InputType = InputList[i].type; 

		if((InputType == "image" || InputType == "submit" || InputType == "button") && (InputList[i].id || InputList[i].id != ''))
		{ 
			InputType = InputList[i].getAttribute("id"); 
			var button = document.getElementById(InputList[i].id);
			var ButtonId = InputList[i].id;
			
			EventListener(button,ButtonId);
		}
	}
}


/********************************************************************************/
/***** ASSIGN EVENTS TO THE BUTTONS ********************************************/
/******************************************************************************/

function EventListener(button,ButtonId)
{
	if(button.addEventListener)
	{
		button.addEventListener('mouseover',function() { button_rollover(ButtonId); }, true);
		button.addEventListener('mouseout',function() { button_rollover(ButtonId); }, true);
		button.addEventListener('focus',function() { button_rollover(ButtonId); }, true);
		button.addEventListener('blur',function() { button_rollover(ButtonId); }, true);
	}
	else if(button.attachEvent)
	{
		button.attachEvent('onmouseover',function() { button_rollover(ButtonId); });
		button.attachEvent('onmouseout',function() { button_rollover(ButtonId); });
		button.attachEvent('onfocus',function() { button_rollover(ButtonId); });
		button.attachEvent('onblur',function() { button_rollover(ButtonId); });
	}
	else
	{
		button.onclick = button_rollover(ButtonId);
	}
}


/********************************************************************************/
/***** BUTTON ROLLOVER *********************************************************/
/******************************************************************************/

function button_rollover(ButtonId)
{
	var Button = document.getElementById(ButtonId);
	var NewClassName = Button.className.split("-");

	if(NewClassName[1] == 'active')
	{
		Button.className = NewClassName[0];
	}
	else
	{
		Button.className = NewClassName[0] + '-active';
	}
}

/* Empty input text values on click */

function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
	thisfield.value = "";
	}
}
function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
	thisfield.value = defaulttext;
	}
}
