// BPLib.js: minimal of BPLib_complete.js. (c) 2010 Bear Peak Software, LLC.

var isIE = Boolean(window.attachEvent && !window.opera);

function registerEvent(element, event, fun, capture) {
	if (element.addEventListener) {
		element.addEventListener(event, fun, (capture || false));
	} else if (element.attachEvent) {
		element.attachEvent("on" + event, fun);
	} else {
		element["on" + event] = fun;
	}
}

function setOpacity(element, value) {
	element.style.opacity = String(value);
	if (isIE)
		element.style.filter = "alpha(opacity=" + Math.round(value * 100) + ")";
}

function fadeoutElement(e, amount) {
	var opc = parseFloat(e.style.opacity);
	opc -= amount;
	setOpacity(e, opc);
	return (opc <= 0.0);
}

function fadeinElement(e, amount) {
	var opc = parseFloat(e.style.opacity);
	opc += amount;
	setOpacity(e, opc);
	return (opc >= 1.0);
}

function log(s) {
	if (window.console && window.console.log) {
		console.log(s);
	} else {
		var logElement = document.getElementById("logElement");
		if (logElement != null) {
			logElement.appendChild(document.createTextNode(s));
			logElement.appendChild(document.createElement("br"))
		}
	}
}

