var DomLoaded =
{
	onload: [],
	loaded: function()
	{
		if (arguments.callee.done) return;
		arguments.callee.done = true;
		for (i = 0;i < DomLoaded.onload.length;i++) DomLoaded.onload[i]();
	},
	load: function(fireThis)
	{
		this.onload.push(fireThis);
		if (document.addEventListener)
			document.addEventListener("DOMContentLoaded", DomLoaded.loaded, null);
		if (/KHTML|WebKit/i.test(navigator.userAgent))
		{
			var _timer = setInterval(function()
			{
				if (/loaded|complete/.test(document.readyState))
				{
					clearInterval(_timer);
					delete _timer;
					DomLoaded.loaded();
				}
			}, 10);
		}
		/*@cc_on @*/
		/*@if (@_win32)
		var proto = "src='javascript:void(0)'";
		if (location.protocol == "https:") proto = "src=https:///";
		document.write("<scr"+"ipt id=__ie_onload defer " + proto + "><\/scr"+"ipt>");
		var script = document.getElementById("__ie_onload");
		script.onreadystatechange = function() {
		    if (this.readyState == "complete") {
		        DomLoaded.loaded();
		    }
		};
		/*@end @*/
	}
};
function searchForm(id) {
	var divs = document.getElementsByTagName("form");
	for (var i=0; i<divs.length; i++ ) {
		if (divs[i].className.indexOf("searchForm") == -1) continue;
		if (divs[i].getAttribute("id") != id) {
			divs[i].style.display ="none";
		}	else {
			divs[i].style.display = "block";
		}
	}
}

// function for formNav
function prepareformNav() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById("formNav")) return false;
	var nav = document.getElementById("formNav");
	var links = nav.getElementsByTagName("a");
	for (var i=0; i<links.length; i++ ) {
		var sectionId = links[i].getAttribute("href").split("#")[1];
		if (!document.getElementById(sectionId)) continue;
		document.getElementById(sectionId).style.display = (i==0) ? "block" : "none"; //this will display the first form as default
		links[i].destination = sectionId;
		links[i].onclick = function() {
			searchForm(this.destination);
			tabs = this.parentNode.parentNode.getElementsByTagName("li");
			tabs[0].className="";
			tabs[1].className="";
			this.parentNode.className+=" on";
			return false;
		}
	}
}
DomLoaded.load(prepareformNav)