startList = function() { 
	if (document.getElementById("tnav")) {
		var tnodes = document.getElementById("tnav").getElementsByTagName("LI");
		for (var i=0; i<tnodes.length; i++) { 
			tnodes[i].onmouseover = function() { 
				this.className += " hover"; 
			} 
			tnodes[i].onmouseout = function() { 
				this.className = this.className.replace(new RegExp(" hover\\b"), ""); 
			} 
		}
	}

	if (document.getElementById("lnav")) {
		var lnodes = document.getElementById("lnav").getElementsByTagName("LI");
		for (var i=0; i<lnodes.length; i++) { 
			lnodes[i].onmouseover = function() { 
				this.className += " hover"; 
			} 
			lnodes[i].onmouseout = function() { 
				this.className = this.className.replace(new RegExp(" hover\\b"), ""); 
			} 
		} 
	}
} 

function initPage()
{
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++)
	{
		if (inputs[i].type == "text" && (inputs[i].name == "email" || inputs[i].name == "name"))
		{
			var form = getAncestor(inputs[i], "form");
			if (form)
				form.onsubmit = handleSubmit;

			inputs[i].onfocus = function () {
					if ((this.value == "Email Address") || (this.value == "Name"))
						this.value = "";
				}
			inputs[i].onblur = function () {
					if (this.value == "" && this.name == "email") this.value = "Email Address";
					if (this.value == "" && this.name == "name") this.value = "Name";
				}	
		}
	}
}

function handleSubmit()
{
	var re = new RegExp('^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$');
	var element = this.elements["email"];
	if (element)
	{
		if (element.value == "")
		{
			alert("Email address is empty!");
			return false;
		}
		else
			return element.value.match(re)
				|| (alert("You have entered incorrect email address!"), false);
	}
	return true;
}

function getAncestor(element, tagName)
{
	var node = element;
	while (node.parentNode && (!node.tagName ||
			(node.tagName.toUpperCase() != tagName.toUpperCase())))
		node = node.parentNode;
	return node;
}

if (window.addEventListener)
	window.addEventListener("load", initPage, false);
else if (window.attachEvent){
	window.attachEvent("onload", initPage);
	window.attachEvent("onload", startList)
	}