	window.onload = initialize;
	function initialize() {
		dhtmlHistory.initialize();	
		dhtmlHistory.addListener(handleHistoryChange);
   	// determine our current location so we can
		// initialize ourselves at startup
		var initialLocation = dhtmlHistory.getCurrentLocation();
  
		// set the default
		if (initialLocation == "")
		{
			initialLocation = "home";
		}
		// now initialize our starting UI
		// updateUI not needed for flash version
		updateUI(initialLocation, null);
	}

	/** A simple method that updates our user
		 interface using the new location. */
	function updateUI(newLocation, historyData) {
  
		// simply display the location and the data
  		var historyMessage;
  		if (historyData != null){
    		historyMessage = historyData.message;
			document.title = historyData.message;
		} else {
			historyMessage = "<i>No History Data - init history</i>";
			document.title = "";
		}    
  		var message = 	"<b>Location:</b> " + newLocation +
							"<br /><b>History Data Storage:</b> " + historyMessage;                
  		debugMsg(message);
	}


	function debugMsg(msg) {
		//alert(msg);
	}


	function handleHistoryChange(newLocation, historyData) {
		debugMsg("handleHistoryChange() called");
		// this is updating the temp html UI changes
  		updateUI(newLocation, historyData);
		//JS function to call back to flash
		callExternalInterface();
	}

	function callExternalInterface() {
  		if(thisMovie("ddlobj").updateFlashHistory){
			// Call Flash
			debugMsg("Calling Flash");
			thisMovie("ddlobj").updateFlashHistory(dhtmlHistory.getCurrentLocation());
		} else {
			// Method does not exist, Error
			debugMsg("Calling Flash - Error");
			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};
		debugMsg("setDeepLink() called");
		updateUI(newLocation, historyData);
		dhtmlHistory.add(newLocation, historyData);
	}

	function getDeepLink(){
		debugMsg("getDeepLink() called - " + dhtmlHistory.getCurrentLocation());
		return dhtmlHistory.getCurrentLocation();
	}

	function getPageTitle(){
		debugMsg("getPageTitle() called - " + document.title);
		return document.title;
	}

	function setPageTitle(windowTitle){
		debugMsg("setPageTitle() called - " + windowTitle);
		document.title = windowTitle;
	}

	function doNothing() { return true; }
	//window.onerror = doNothing;


	function allSwfsMustDIE(){
		var objects = document.getElementsByTagName("OBJECT");
		//alert('destroy all ' + (objects.length) + ' swfs');
  		for (var i=0; i < objects.length; i++) {
    		for (var x in objects[i]) {
		      if (typeof objects[i][x] == 'function') {
					//alert('destroying ' + objects[i][x]);
		        objects[i][x] = null;
      		}
			}
		}
	
		var divHolder = document.getElementById("v5wrapper");
		var divToKILL = document.getElementById("flashcontent");
		//divHolder.removeChild(divToKILL);
	}

	if (typeof window.onunload == 'function') {
 		var oldunload = window.onunload;
  		window.onunload = function() {
 	   	allSwfsMustDIE();
    		oldunload();
  		}
	} else {
		window.onunload = allSwfsMustDIE;
	}