window.onload = function ()
{
	setHash(getHash(), true);
}
	
var OPERA = Boolean(window["opera"]);
var MSIE = !OPERA && (navigator.appName.indexOf("Microsoft") != -1);
var WIN = (navigator.userAgent.toLowerCase().indexOf("win") != -1);
var SAFARI = !WIN && (navigator.appName.indexOf("safari") != -1);

var isReady = false;

switch(true) {
  case OPERA: browser = "opera"; break;
  case SAFARI: browser = "safari"; break;
  case MSIE: browser = "ie"; break;
  default: browser = "other"; break;
}

// function getElement (id) {
// return MSIE ? window[id] : document[id];
// }

var _title = document.title
if (_title.indexOf("#") != -1) {
  _title = _title.split("#");
  _title.pop();
  _title = _title.join("");
}

fixTitle = function() 
{
  if (document.title.charAt(0) == "#") {
	  document.title = _title+": "+document.title.substr(1);
  }
}
getHash = function()
{
	return location.hash || "";
}
setHash = function(value, isFirst) 
{
  if (value != null) {
	  value = String(value);
	  value = value.split("#").join("");
	  
	  if (isFirst) {
		if (!value.length) {
			return;
		}
	  } else {
		  location.hash = "#"+value;
	  }
	  
	  if (value.length) {
		  document.title = _title+": "+value;
	  } else {
		  document.title = _title;
	  }
  }
}

function showAlternateContent()
{
  if (isReady == null || !isReady) {
	  var content = document.getElementById("alternate_content");
	  content.style.display = "block";
	  
	  document.body.style.backgroundImage = "url(img/background-flash.gif)";
  }
}

function showContent()
{
	var content = document.getElementById("flash_version_container");
	content.style.display = "block";
}
function hideContent()
{
	var content = document.getElementById("flash_version_container");
	content.style.display = "none";
}

var startFlash = function (swfName) 
{
	if (isReady) {
		return isReady;
	}
	var flash = new SWFObject(swfName, "site", "100%", "100%", "8", "#453F35");
	flash.addParam("allowScriptAccess", "always");
	flash.addVariable("flashvars_hash", location.hash);
	flash.addVariable("flashvars_browser", browser);

	// *** xml path ***
	flash.addVariable("flashvars_xml", "menu.xml");

	isReady = flash.write("flash_version_container");
	if (isReady) {
		document.body.style.backgroundImage = "";
		var main = document.getElementById("flash_version_container");
		main.style.backgroundImage = "url(img/background-flash.gif)";
	}

	setTimeout(showAlternateContent, 300);
	return isReady;
}





