window.onload = init;
window.onresize = function () 
	{ 
	if (visSubnav)
		{ 
		placeSubNav(visSubnav);
		} 
	};
function init () 
	{
	if (document.getElementById) 
		{
		addHover("nav");
		if (visSubnav)
			{
			placeSubNav(visSubnav);
			}
		}
	if (splitLists && document.getElementById)
		{
		twoCols("prevClients", "UL");
		twoCols("currClients", "UL");
		}
	if(typeof sIFR == "function")
		{
		if (home)
			{
			sIFR.replaceElement("div#sidebar h3", named({sFlashSrc: "./fgc.swf", sColor: "#f37123", sCase: "upper", nPaddingTop: 8}));
			}
		else 
			{
			sIFR.replaceElement("div#main h3", named({sFlashSrc: "./fgc.swf", sColor: "#f37123", sCase: "upper"}));
			sIFR.replaceElement("div#main h2", named({sFlashSrc: "./fgc.swf", sColor: "#2a377e"}));
			}
		};
	if (navigator.userAgent.indexOf("Safari") > 0) 
		{
		var labels = document.getElementsByTagName("label");
		for (i = 0; i < labels.length; i++)
			{
			labels[i].addEventListener("click", addLabelFocus, false);
			}
		}
	}

function addHover(whichDiv)
	{
	for (var k = 0; k < document.getElementById(whichDiv).childNodes.length; k++)
		{
		
		if (document.getElementById(whichDiv).childNodes[k].nodeName == "UL")
			{
			var navRoot = document.getElementById(whichDiv).childNodes[k];
			}
		}
	for (var i = 0; i < navRoot.childNodes.length; i++) 
		{
		var node = navRoot.childNodes[i];
		if (node.nodeName == "LI") 
			{
			node.onmouseover = function() 
				{
				if (this.getElementsByTagName("ul")[0])
					{
					placeSubNav(this.id);
					}
				if (document.all)
					{
					this.className += " over";
					}
				}
			if (document.all)
				{
				node.onmouseout = function() 
					{
					this.className = this.className.replace (" over", "");
					}
				}
			}
		}
	}

function placeSubNav(whichSection)
	{
	var theList = document.getElementById(whichSection).getElementsByTagName("ul")[0];
	var homeLeft = Math.floor((document.body.offsetWidth - 800)/2) + 62;
	theList.style.width =  document.body.offsetWidth - homeLeft + "px";
	theList.style.paddingLeft = homeLeft + "px";
	}

function twoCols(src, type)
	{
	var origList = document.getElementById(src);

	var leftList = document.createElement(type);
	var rightList = document.createElement(type);
	var container = document.createElement('div');

	var items = origList.getElementsByTagName('LI');

	var itemsLength = items.length/2;
	for (i = 0; i < itemsLength; i++)
		{
		leftList.appendChild(items[0]);
		}

	itemsLength = items.length;
	for (i = 0; i < itemsLength; i++)
		{
		rightList.appendChild(items[0]);
		}
	container.appendChild(leftList);
	container.appendChild(rightList);

	leftList.setAttribute('class', 'left');
	rightList.setAttribute('class', 'right');
	container.setAttribute('class','twocol');
	if (document.all)
		{
		leftList.setAttribute('className', 'left');
		rightList.setAttribute('className', 'right');
		container.setAttribute('className','twocol');
		}
	if (type == 'ol')
		{
		rightList.setAttribute('start', leftList.getElementsByTagName('LI').length + 1 );
		}
	var clearer = document.createElement('p');
	container.appendChild(clearer);
	clearer.style.clear = "left";
	clearer.style.height = "1px";
	clearer.style.marginBottom = ".5em";
	
	origList.parentNode.replaceChild(container, origList);
	}

function addLabelFocus()
	{
	var item = document.getElementById(this.getAttribute("for"));
	item.focus();
	if (item.getAttribute("type") == "checkbox")
		{
		if (!item["checked"])
			{
			item["checked"] = true;
			}
		else
			{
			item["checked"] = false;
			}
		}
	else if (item.getAttribute("type") == "radio")
		{
		var allRadios = document.getElementsByTagName("input");
		var radios = new Array();
		for (i = 0; i < allRadios.length; i++)
			{
			if (allRadios[i].getAttribute("name") == item.getAttribute("name"))
				{
				radios.push(allRadios[i]);
				}
			}
		for (i = 0; i < radios.length; i++)
			{
			if (radios[i]["checked"] && 
			radios[i].getAttribute("id") != item.getAttribute("id"))
				{
				radios[i]["checked"] = false;
				}
			}
		item["checked"] = true;
		}
	}
