var hobj;
var cid;
var tmobj;

function highlight(id, sid) 
{
	var obj;

	obj = document.getElementById(id);
	obj.style.background="transparent";
	obj.style.color="#d04040";
	if (sid) {
		popup(id,sid);
	}
	else {
		popdown();
	}
}

function unhighlight(id, sid) 
{
	var obj;

	obj = document.getElementById(id);
	obj.style.background="transparent";
	obj.style.color="rgb(36,35,80)";
	if (sid) {
		popup(id,sid);
	}
	tmobj = setTimeout(popdown, 3000);
	cid = '';
}

function popup(id, sid) 
{
	var line, obj;

	line = document.getElementById('menu-line');
	clearTimeout(tmobj);
	if (sid != 'child') {
		obj = document.getElementById(id);
		sobj = document.getElementById(sid);
		if (hobj) {
			hobj.style.visibility = "hidden";
		}
		hobj = sobj;
		
		sobj.style.top = line.offsetTop + line.offsetHeight + "px";
		sobj.style.left = line.offsetLeft + obj.offsetLeft + "px"; 
		sobj.style.visibility="visible";
	}
	else {
		cid = id;
	}
}

function fixup()
{
	var frm, logo, menu;

	frm = document.getElementById('main-frame');
	logo = document.getElementById('logo-frame');
	menu = document.getElementById('menu-line');
	// menu.style.top = logo.offsetTop + logo.offsetHeight + "px";
	// menu.style.left = logo.offsetLeft + 4 + "px";
	// logo.style.left = (document.width - logo.offsetWidth) / 2 + "px";
	// frm.style.left = logo.offsetLeft + "px";
	// frm.style.top = menu.offsetTop + menu.offsetHeight + "px";
}

function popdown()
{
	if (hobj && !cid) {
		hobj.style.visibility="hidden";
		hobj = '';
	}
}


function obfuscate(showtext, domain, name, extension) {
	var showtext, domain, name, extension, obs;

	if (showtext != "") {
		obs = "<a href=" + "ma" + "ilto" + ":" + name + "@" + domain + "." + extension + ">" + showtext + "</a>";
	}
	else {
		obs = "<a href=" + "ma" + "ilto" + ":" + name + "@" + domain + "." + extension + ">" 
			+ name + "@" + domain + "." + extension
			+ "</a>";
	}
	return obs;
}

function mouse_hover(id, url)
{
	obj = document.getElementById(id);
	obj.src=url;
}

function makeRequest(url)
{
        var httpRequest;

	popdown();
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		httpRequest = new XMLHttpRequest();
		if (httpRequest.overrideMimeType) {
			httpRequest.overrideMimeType('text/xml');
			// See note below about this line
		}
        } 
        else if (window.ActiveXObject) { // IE
		try {
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
			try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) {}
		}
	}

        if (!httpRequest) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
        }
        httpRequest.onreadystatechange = function() { changeContent(httpRequest); };
        httpRequest.open('GET', url, true);
        httpRequest.send(null);

}

function changeContent(httpRequest) 
{
	var text, obj;

        if (httpRequest.readyState == 4) {
		if (httpRequest.status == 200) {
			text = httpRequest.responseText
			obj = document.getElementById("main-frame");
			if (obj) 
			{
				obj.innerHTML = text;
			}
		} else {
			alert('There was a problem with the request.');
		}
        }
	return true;
}
