if (typeof unFocus == "undefined") var unFocus = {};
if (!unFocus.Flash) unFocus.Flash = {};

unFocus.Flash.HistoryBridge = function($communicator) {
	with (unFocus) {
		// add the initial state to the movie
		$communicator.getHTML().addFlashvar("unFocusHistoryUpdate",History.getCurrent());
		
		// subscribe to the Communicator
		$communicator.addEventListener("FSCommand", function($data) {
			switch($data[0]) {
				case "History.setTitle":
					document.title = $data[1];
				break;
				case "History.addHistory":
					History.addHistory($data[1]);
			}
		});
		
		// subscribe to the History Keeper
		History.addEventListener("historyChange", function($hash) {
			$communicator.setVariable("unFocusHistoryUpdate",$hash);
		});
	}
};

