// ddl-utils
window.onload = initialize;

function initialize() {
	dhtmlHistory.initialize();	
	dhtmlHistory.addListener(handleHistoryChange);
	if(window.location.hash == "") window.location.hash = "home/";
}

// call from flash
function getDeepLink() {
	return dhtmlHistory.getCurrentLocation();
}

// flashmovie reference
function thisMovie(movieName) {
    if(navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    } else {
        return document[movieName]
    }
}

// call flash when history changes [BACK-button || FORWARD-button || DDL-direct call]
function handleHistoryChange(newLocation, historyData) {
	// alert(historyData.message);
	if(historyData != null) {
		
		//alert(historyData.message);
		
		thisMovie("index").goTo(historyData.message);
		
		if(historyData.sub_title != null) document.title = "Hauska & Partner Croatia - " + historyData.main_title + " - " + historyData.sub_title;
		else document.title = "Hauska & Partner Croatia - " + historyData.main_title;
	}

}



// call from flash when nav_button is clicked
function setDeepLink(newLocation, flash_url, mainTitle, subTitle) {	

	var historyData = {
		message:flash_url, 
		main_title:mainTitle,
		sub_title:subTitle
	}

	document.title = "";
	
	if(historyData.sub_title != null) document.title = "Hauska & Partner Croatia - " + historyData.main_title + " - " + historyData.sub_title;
	else document.title = "Hauska & Partner Croatia - " + historyData.main_title;
	
	// add history data to dhtmlHistory object
	dhtmlHistory.add(newLocation, historyData);

}