window.onload = Initialize;
	
function Initialize() {
	// initialize the DHTML History framework
	dhtmlHistory.initialize();
	
	// subscribe to DHTML history change events
	dhtmlHistory.addListener(OnHistoryChange);
	
	if (dhtmlHistory.isFirstLoad()) {
		OnHistoryChange(dhtmlHistory.getCurrentLocation(), null);
	}
}

// History callback
function OnHistoryChange(newLocation, historyData) {
	/*
	debug("A history change has occurred: "
		  + "newLocation="+newLocation
		  + ", historyData="+historyData, 
		  true);
		  */
		  
	if (GetMovie("pds")&&GetMovie("pds").UpdateLocation) {
		GetMovie("pds").UpdateLocation(newLocation);
	} else {
		//alert("Flash not ready yet");
		//debug("Flash not ready yet", false);
		//return true;
	}
}

// Flash API.
function AddHistory(newLocation)
{
	//debug("Add history: "+newLocation, false);
	if (newLocation)
		dhtmlHistory.add(newLocation, null);
	else
		dhtmlHistory.add("empty", null);
}
function GetCurrentLocation()
{
	return dhtmlHistory.getCurrentLocation();
}

// Helpers
function GetMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName]
	}
	else {
		return document[movieName]
	}
}

/**
function debug(msg, clear) {
	
	var output = 
			document.getElementById("debug");
	if (clear == true)
	  output.innerHTML = "<p>" + msg + "</p>";
	else {
	  output.innerHTML += "<p>" + msg + "</p>";
	}
}
**/
