var currentURL = document.location.href;
var displayFlash = false;

/* Check if this is a Flash URL (#) */
var isFlashURL = false;
if (currentURL.indexOf('#') > -1) {
	isFlashURL = true;
}

/* Check if the user has the correct flash version */
var flashVersionOk = DetectFlashVer(8,0,0);
if(!isFlashURL) { // We're not on a flash URL - so go there
	// Split root from rest and add #, then redirect
	var urlSplit = currentURL.split(rootPath);
	var newURL = '';
	
	if(urlSplit[1] == '') {	// If nothing after htdocs goto homepage
		newURL = rootPath+'home';
	}else{
		newURL = rootPath+'#/'+urlSplit[1];
		// Remove trailing slash if any
		if(newURL.lastIndexOf('/') == (newURL.length-1)) {
			newURL = newURL.slice(0,(newURL.length)-1);
		}
	}
	top.document.location.replace(newURL);
}

if(isFlashURL && !flashVersionOk) {	// Is Flash-URL but user hasn't got the right version
	document.location.replace(rootPath + 'pages/update_flash.php');
}

if(isFlashURL && flashVersionOk) {	// Everything OK, display Flash
	displayFlash = true;
}
