/*
Requires..

[common.js]
event_obj()
*/
function get_height(obj){
	//returns the height (in pixels?) of the given object
	if (obj.offsetHeight){
		return parseInt(obj.offsetHeight);
	}
	else {
		debug('obj.offsetHeight not found');
		return 0;
	}
}

function set_buttons(class_name){

	var x_button_mouseover = function (e){
		if (!e){e=event};
		button = event_obj(e);
		//alert(button.offsetHeight);
		
		button.style.backgroundPosition = '0px -' + get_height(button) + 'px';
		button.style.color = '#0000FF';
	}
	var x_button_mouseout = function (e){
		if (!e){e=event};
		button = event_obj(e);
		
		button.style.backgroundPosition = '0px 0px';
		button.style.color = '#000000';
	}
	var x_button_mousedown = function (e){
		if (!e){e=event};
		button = event_obj(e);
		
		button.style.backgroundPosition = '0px -' + (get_height(button) * 2) + 'px';
		button.style.color = '#0000FF';
	}
	var x_button_mouseup = function (e){
		if (!e){e=event};
		button = event_obj(e);
		
		button.style.backgroundPosition = '0px 0px';
		button.style.color = '#0000FF';
	}



	//set up buttons
	var a_inputs = document.getElementsByTagName('INPUT');
	
	//assume it wont work
	var b_return = false;
	
	for (var i=0; i<a_inputs.length; i++){
		var input_type = a_inputs[i].type.toLowerCase();
		
		if ((a_inputs[i].className == class_name) && 
			((input_type == 'submit') ||
			(input_type == 'image') ||
			(input_type == 'reset') ||
			(input_type == 'button'))){
			
			//attach mouse events to this button
	
			if (a_inputs[i].addEventListener){
				a_inputs[i].addEventListener("mouseover", x_button_mouseover, false);
				a_inputs[i].addEventListener("mouseout", x_button_mouseout, false);
				a_inputs[i].addEventListener("mousedown", x_button_mousedown, false);
				a_inputs[i].addEventListener("mouseup", x_button_mouseup, false);
				b_return = true;
			}
			else if (a_inputs[i].attachEvent){
				a_inputs[i].attachEvent("onmouseover",x_button_mouseover);
				a_inputs[i].attachEvent("onmouseout",x_button_mouseout);
				a_inputs[i].attachEvent("onmousedown",x_button_mousedown);
				a_inputs[i].attachEvent("onmouseup",x_button_mouseup);
				b_return = true;
			}
		}
	}
	return b_return;
}


