window.onload = initialize;

var tmpLayer = "";

function initialize()
{
   dhtmlHistory.initialize();
   dhtmlHistory.addListener(handleHistoryChange);

   var currentLocation = dhtmlHistory.getCurrentLocation();

   if (currentLocation == "")
   {
      currentLocation = "section:";
   }
   currentLocation = currentLocation.replace(/section\:/, "");
   displayLocation(currentLocation, tmpLayer, null);
}

function handleHistoryChange(newLocation, historyData)
{
   if (newLocation == "")
   {
      newLocation = "section:0";
   }
   newLocation = newLocation.replace(/section\:/, "");
   displayLocation(newLocation, tmpLayer, historyData);
}

function displayLocation(newLocation, layer, sectionData)
{
	if (layer != null)
	{
	   if (sectionData == null)
	   {
			sectionData = "";  
	   }
	   else
	   {
		   if (layer != "")
				document.getElementById(layer).innerHTML = sectionData;
	   }
	}
}

function handleMouseClick(id, layer, content)
{
    var modifiedLocation = "section:" + id;   
   	var historyData = content; 
	tmpLayer = layer;
		
    dhtmlHistory.add(modifiedLocation, historyData);
    displayLocation(id, layer, historyData);
}
