
function initGreenMan() {
	// alert("The Green Man");
	var elem = document.createElement("div");
	elem.style.position = "absolute";
	elem.style.top = "0px";
	elem.style.right = "1px";
	elem.style.width = "120px";
	elem.style.height = "100px";
	var html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="120" height="100" id="greenman" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/lib/greenman/greenman.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="/lib/greenman/greenman.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="120" height="100" name="greenman" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	var oldHtml = "<a href='javascript:showTip();'><img src='/lib/greenman/greenman.gif' alt='Green Man' width='100' height='100' border='0' /></a>";
	elem.innerHTML = html;
	document.body.appendChild(elem);
}

var tipElem = null;
var tipWidth = 0;
var currTimeout = null;
var firstTime = 1;

function showTip() {
	if (!tipElem) {
		tipElem = document.createElement("div");
		tipElem.style.position = "absolute";
		tipElem.style.top = "100px";
		tipElem.style.right = "0px";
		tipElem.style.width = "0px";
		tipElem.style.height = "300px";
		tipElem.style.overflow = "hidden";
	}
	if (firstTime) {
		firstTime = 0;
		setTip("Coming soon", "<p>Tip coming up...</p>");
	}
	fetchTip();
	tipElem.style.display = "block";
	document.body.appendChild(tipElem);
	document.body.onclick = function() {
		currTimeout = window.setTimeout("hideTip();", 50);
	}
	if (currTimeout)
		window.clearTimeout(currTimeout);
	currTimeout = window.setTimeout("displayTip();", 50);
}

function displayTip() {
	if (tipWidth < 200) {
		tipWidth+= 10;
		tipElem.style.width = tipWidth + "px";
		currTimeout = window.setTimeout("displayTip();", 50);
	} else {
		currTimeout = null;
	}
}

function hideTip() {
	document.body.onclick = null;
	if (tipWidth > 0) {
		tipWidth-= 10;
		tipElem.style.width = tipWidth + "px";
		currTimeout = window.setTimeout("hideTip();", 50);
	} else {
		tipElem.style.display = "none";	
	}
}

var xmlhttp = null;
function fetchTip() {
	var url = "/lib/gettip.php";
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
		xmlhttp.onreadystatechange = xmlhttpChange;
		xmlhttp.open("GET", url, true);
		xmlhttp.send(null);
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		if (xmlhttp) {
			xmlhttp.onreadystatechange = xmlhttpChange;
			xmlhttp.open("GET", url, true);
			xmlhttp.send();
		}
	}
}

function xmlhttpChange() {
	if (xmlhttp.readyState == 4) {
		if (xmlhttp.status == 200) {
			var title = xmlhttp.responseXML.getElementsByTagName("title");
			var body = xmlhttp.responseXML.getElementsByTagName("body");
			if (title && body) {
				var title_html = title[0].firstChild.data;
				var body_html = body[0].firstChild.data;
				setTip(title_html, body_html);
			}
		}
	}
}

function setTip(title, body) {
	if (tipElem) {
		var html = '<table width="200" height="300" border="0" cellpadding="0" cellspacing="0"><tr><td width="8" align="left"><img src="/lib/greenman/float1.gif" width="8" height="8" alt=""></td><td style="background-position: top left;background-image: url(\'/lib/greenman/floatt.gif\');background-repat:x-repeat;" align="left"><img src="/lib/greenman/floatt.gif" width="8" height="8" alt=""></td></tr><tr><td style="background-position: top left;background-image: url(\'/lib/greenman/floatl.gif\');background-repat:y-repeat;" align="left"><img src="/lib/greenman/floatl.gif" width="8" height="8" alt=""></td><td valign="top" style="background-color:#E4F0E0;">';
		html+= "<div style=\"width: 190px; height: 280px; overflow: auto;\"><b>" + title + "</b><br />" + body + "</div>";
		html+= '</td></tr><tr><td width="8" align="left"><img src="/lib/greenman/float2.gif" width="8" height="8" alt=""></td><td style="background-position: top left;background-image: url(\'/lib/greenman/floatb.gif\');background-repat:x-repeat;" align="left"><img src="/lib/greenman/floatb.gif" width="8" height="8" alt=""></td></tr></table>';
		tipElem.innerHTML = "<div onclick=\"event.cancelBubble=true;\" style='width: 200px'>" + html + "</div>"
	}
}

