function BubbleMessage(title, message) {
	this.title = title;
	this.message = message;
};

BubbleMessage.prototype.bind = function(target) {

	var pos = BubbleMessage.getElementPosition(target);
	var container = document.createElement("div");

	container.style.backgroundImage = "url('/res/popup-bg.png')";
	container.style.backgroundRepeat = "no-repeat";
	container.style.width = "302px";
	container.style.height = "194px";

	var header = document.createElement("div");
	header.style.verticalAlign = "middle";
	header.innerHTML = "<span style=\"font-size: 14px; text-transform: uppercase;\">"+this.title+"</span>";
	var main = document.createElement("div");
	main.innerHTML = this.message;
	var button = document.createElement("img");
	button.src = "/res/close.gif";
	button.style.position = "absolute";
	button.style.right = "16px";
	button.style.top = "16px";
	header.appendChild(button);

	var icon = document.createElement("img");
	icon.src = "/res/bulb.gif";
	icon.style.verticalAlign = "bottom";
	icon.style.paddingRight = "8px";
	icon.style.display = "inline";

	header.insertBefore(icon, header.firstChild);

	container.appendChild(header);
	container.appendChild(main);

	header.style.paddingTop = "12px";
	header.style.paddingLeft = "16px";
	header.style.paddingRight = "8px";
	header.style.textAlign = "left";

	main.style.paddingLeft = "35px";
	main.style.paddingRight = "40px";
	main.style.paddingTop = "16px";
	main.style.paddingBottom = "16px";
	main.style.textAlign = "left";
	main.style.color = "#666666";

	container.style.position = "absolute";
	container.style.left = (pos.x - 380) + "px";

	document.body.appendChild(container);
	container.style.top = (pos.y + 40) + "px";

	container.onclick = function() {
		container.parentNode.removeChild(container);
	};
};
BubbleMessage.getElementPosition = function(elm) {
	var el = elm;
	var ol = el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }

	var el = elm;
	var ot = el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }

	return {
		x : ol,
		y : ot
	}
};