function rendermenu(id)
{
	var menu = document.getElementById(id);
	
	if (menu.className.indexOf("on") != -1)
	{
		menu.className = menu.className.substring(0, menu.className.length - 2);
	}
	else
	{
		menu.className = menu.className + "on";
	}
	
	return false;
}

function rendertab(id)
{
	recentdivs = document.getElementById("recent").getElementsByTagName("div");

	for (var i = 0; i < recentdivs.length; i++)
	{
		if (recentdivs[i].className.indexOf("active") != -1)
		{
			recentdivs[i].className = recentdivs[i].className.replace("active", "");
		}

		if (recentdivs[i].className == "show")
		{
			recentdivs[i].className = "hide";
		}
	}

	currentdate = new Date();
	currentdate.setDate(currentdate.getDate() + 365);
	document.getElementById(id).className = "active";
	document.getElementById(id + "body").className = "show";
	document.cookie = "customtab="+escape(id)+";expires="+currentdate.toGMTString();

	return false;
}

function openwindow(location, width, height)
{
	windowleft = (width < screen.width)?(screen.width - width) / 2:0;
	windowtop = (height < screen.height)?(screen.height - height) / 2:0;
	
	window.open(location, "", "left="+windowleft+", top="+windowtop+", width="+width+", height="+height+", location=yes, menubar=no, resizable=yes, scrollbars=no, status=no, toolbar=no");
	
	return false;
}

function showherosearchdropdown()
{
	//document.getElementById("herosearchformdropdown").className = "show";

	if (document.getElementById("herosearchtext").value == "Search")
	{
		document.getElementById("herosearchtext").value = "";
	}
}

function hideherosearchdropdown()
{
	document.getElementById("herosearchformdropdown").className = "hide";
	
	return false;
}

function resetherosearchdropdown()
{
	document.getElementById("herosearchtype").selectedIndex = 0;
	document.getElementById("herosearchstate").selectedIndex = 0;
	
	saveherosearch("herosearchtype");
	saveherosearch("herosearchstate");
	
	return false;
}

function saveherosearch(id)
{
	currentdate = new Date();
	currentdate.setDate(currentdate.getDate() + 365);
	document.cookie = "custom"+id+"="+escape(document.getElementById(id).value)+";expires="+currentdate.toGMTString();
}

function submitherosearch()
{
	var herosearchtext = document.getElementById("herosearchtext").value;
	//var herosearchtype = document.getElementById("herosearchtype").value;
	//var herosearchstate = document.getElementById("herosearchstate").value;
	
	window.location = "searchresults.php?searchtext="+herosearchtext;//+"&type="+herosearchtype+"&state="+herosearchstate;
	return false;
}

function deleteparam(name)
{
	var url = window.location.href;
	
	if (url.indexOf(name) != -1)
	{
		var start = url.indexOf(name);
		
		if (url.indexOf("&", start) != -1)
		{
			url = url.substring(0, start - 1) + url.substring(url.indexOf("&", start));
			
			if (url.indexOf("?") == -1)
			{
				url = url.replace("&", "?");
			}
		}
		else
		{
			url = url.substring(0, start - 1);
		}
	}
	
	return url;
}

function returnstate(id)
{
	var url = deleteparam("state=");
	
	if (id == "")
	{
		var id = document.getElementById("statesearchselect");
		var id = id.options[id.selectedIndex].value;
	}
	
	if (id != "")
	{
		if (url.indexOf("?") != -1)
		{
			return url + "&state=" + id;
		}
		else
		{
			return url + "?state=" + id;
		}
	}
	else
	{
		return url;
	}
}

function loadfunction(load)
{
	var oldonload = window.onload;
	if (typeof window.onload != "function")
	{
		window.onload = load;
	}
	else
	{
		window.onload = function()
		{
			if (oldonload)
			{
				oldonload();
			}
			load();
		}
	}
}

var sc_project = 2787999;
var sc_invisible = 0;
var sc_partition = 28;
var sc_security = "21ebf804";
var sc_text = 1;

function rendercounter()
{
	include = document.getElementById("statcounterxhtml").innerHTML;
	counter = document.getElementById("statcounter");
	
	counter.innerHTML = include.substring(include.lastIndexOf(">") + 1).replace(/\s+/g,"");
}

loadfunction(rendercounter);
