var flashloaded = false;
var siteloaded = false;
var dontFire = false;

$(document).ready(function(){
	siteloaded = true;
	if(flashloaded) {
		init();
	}
});

function flashLoaded() {
	flashloaded = true;
	if(siteloaded) {
		init();
	}	
}


function init() {
	$.historyInit(pageload);
}


function pageload(hash) {
	if(dontFire) {
		dontFire = false;
		return;
	}
	if(!hash) {
		hash = "/";
	}
	
	thisMovie('hetrooster').setLocation(hash);
}

function setHistory(hash) {
	//dont fire, because flash handles the url change itself, so it's not dependent on javascript
	dontFire = true;
	$.historyLoad(hash);
	location.hash = hash;
	//google analytis
	pageTracker._trackPageview('/#' + hash);
}



function thisMovie(movieName) {
	if (document.embeds && document.embeds[movieName]){
		return document.embeds[movieName]; 
	} else if (window.document[movieName]) {
		return window.document[movieName];
	} else {
		return document.getElementById(movieName);
	}
}
