window.onload = initialize;
function initialize() {
	window.onresize();
	dhtmlHistory.initialize();	
	dhtmlHistory.addListener(handleHistoryChange);
	var initialLocation = dhtmlHistory.getCurrentLocation();
	if (initialLocation == ""){
		initialLocation = "Home";
		var historyData = {message:"Gold Meister - "+initialLocation};
		updateUI(initialLocation, historyData);
		callExternalInterface();
	}else{
		var historyData = {message:"Gold Meister - "+initialLocation};	
		 updateUI(initialLocation, historyData);
		 callExternalInterface();
	}
}
function updateUI(newLocation, historyData) {
	var historyMessage;
	if (historyData != null){
	historyMessage = historyData.message;
		document.title = historyData.message;
	} else {
		historyMessage = "Gold Meister";
		var historyData = {message:historyMessage};
		document.title = historyData.message
	}    
	var message = "<b>Location:</b> " + newLocation + "<br /><b>History Data Storage:</b> " + historyMessage;                
}
function handleHistoryChange(newLocation, historyData) {
	updateUI(newLocation, historyData);
	callExternalInterface();	
}
function callExternalInterface() {
	if(getMoviePath("mainWin").updateFlashHistory){
		getMoviePath("mainWin").updateFlashHistory(dhtmlHistory.getCurrentLocation());
	} else {
		return true;
	}
}
function getMoviePath(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }else {
        return document[movieName]
    }
}
function setDeepLink(newLocation, historyMessage){	
	var historyData = {message:historyMessage};
	updateUI(newLocation, historyData);
	dhtmlHistory.add(newLocation, historyData);
	urchinTracker('/' + newLocation);
}
function getDeepLink(){
	return dhtmlHistory.getCurrentLocation();
}

function getPageTitle(){
	return document.title;
}

function setPageTitle(windowTitle){
	document.title = windowTitle;
}
