/**
 * sections.js
 * Copyright 2007 David Lindquist (DavidEzek@gmail.com)
 *
 * Fri Apr 11 18:40:54 PDT 2008
**/

function initDhtml(secs)
{
	window.dhtmlHistory.create();
	window.onload = function() {
		dhtmlHistory.initialize();
		dhtmlHistory.addListener(loadSection);
	};
	sections = secs;
}

function setVisible(section)
{
	for (key in sections){
		var container = document.getElementById(sections[key] + 'Container');
		if (section == sections[key]){
			container.style.height = 'auto';
			container.style.visibility = 'visible';
			container.style.overflow = 'visible';
		}
		else{
			if(container){
				container.style.height = '0px';
				container.style.visibility = 'hidden';
				container.style.overflow = 'hidden';
			}
		}
	}
}

function setLink(section)
{
	for (key in sections){
		var link = document.getElementById(sections[key] + 'Link');
		if (section == sections[key]){
			link.style.color = 'white';
		}
		else{
			if(link){
				link.style.color = 'black';
			}
		}
	}
}

function loadSection(section, historyData)
{
	if(section == ''){
		section = 'index';
	}
	setVisible(section);
	setLink(section);
}

function goToSection(section){
	// Add to history
	dhtmlHistory.add(section);
	// Load section
	loadSection(section);
}

function handlePageLoad(locationHash)
{
	if(locationHash != '')
	{
		var section = locationHash.substring(1);
		if (section = ''){
			loadSection('index');
		}
		else {
			loadSection(section);
		}
	}
	else {
		setLink('index');
	}
}
