//==================================================================================
// camelCase
//==================================================================================

function camelCase(str) { return str.replace(/-\D/g, function(match) { return match.charAt(1).toUpperCase(); }) }

//==================================================================================
// getStyle
//==================================================================================

function getStyle(obj, stil)
{
	if(document.getElementById(obj)) obj = document.getElementById(obj);
	
	if(window.getComputedStyle)	return window.getComputedStyle(obj,"" ).getPropertyValue(stil);
	else if (document.defaultView) return document.defaultView.getComputedStyle(obj, null).getPropertyValue(stil);
	else if(obj.currentStyle) return obj.currentStyle[camelCase(stil)];
	else if(document.ids) return document.layers[obj.id][camelCase(stil)];
	else if(document.all) return document.all[obj.id].style[camelCase(stil)];
}

//==================================================================================
// setButtonFx
//==================================================================================

function setButtonFx(bt) {
	// Initialisierung
	bt.style.cursor	= "pointer";
	var format			= ".gif";
	var status			= new Array("normal","hover","press");
	var path = (!bt.src)?getStyle(bt,"background-image"):bt.src;
	// Status Durchlauf
	for (var i=0; i < status.length; i++) { if(path.indexOf(status[i]) > -1) { var statusId = i; break; } }
	
	// Setzt events
	if(!bt.eventIsset) {
		bt.omup							= (bt.onmouseup)?bt.onmouseup:function(){};
		bt.omout						= (bt.onmouseout)?bt.onmouseout:function(){};
		bt.omdown						= (bt.onmousedown)?bt.onmousedown:function(){};
		bt.eventIsset = true;
	}
	// Zuweisung
	if (!bt.src) {
		bt.style.backgroundImage		= path.replace(status[statusId],status[1]);
		bt.onmouseover					= function() { this.style.backgroundImage = path.replace(status[statusId],status[1]); return false; }
		bt.onmouseout					= function() { this.style.backgroundImage = path.replace(status[statusId],status[0]); bt.omout(); return false; }
		bt.onmousedown					= function() { this.style.backgroundImage = path.replace(status[statusId],status[2]); bt.omdown(); return false; }
		bt.onmouseup					= function() { this.style.backgroundImage = path.replace(status[statusId],status[1]); bt.omup(); return false; }
	} else {
		bt.src							= path.replace(status[statusId],status[1]);
		bt.onmouseover					= function() { this.src = path.replace(status[statusId],status[1]); return false; }
		bt.onmouseout					= function() { this.src = path.replace(status[statusId],status[0]); bt.omout(); return false; }
		bt.onmousedown					= function() { this.src = path.replace(status[statusId],status[2]); bt.omdown(); return false; }
		bt.onmouseup					= function() { this.src = path.replace(status[statusId],status[1]); bt.omup(); return false; }
	}
}
