window.onload = initialize;
function initialize() {
	setMinSize(flashId,minWidth,minHeight);
  dhtmlHistory.initialize();	
  
  dhtmlHistory.addListener(handleHistoryChange);
  var initialLocation = dhtmlHistory.getCurrentLocation();
  if (initialLocation == ""){
    	initialLocation = "m4!";
	}
  	updateUI(initialLocation, null);
}

function updateUI(newLocation, historyData) {
  if (historyData != null){
	document.title = historyData.message;
	} else {
		document.title = "CARMEN CUBANA - A Latin Pop Opera";
	}
}

function handleHistoryChange(newLocation, historyData) {
  	updateUI(newLocation, historyData);
	callExternalInterface();
}

function callExternalInterface() {
  if(thisMovie("main").updateFlashHistory){
		thisMovie("main").updateFlashHistory(dhtmlHistory.getCurrentLocation());
	} else {
		return true;
	}
}
function thisMovie(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);
}

function getDeepLink(){
	return dhtmlHistory.getCurrentLocation();
}

function getPageTitle(){
	return document.title;
}