document.observe('dom:loaded', function() {
	//add switcher
	var aSwitcherFlash = Builder.node('a', { href: '#flash', id: 'aSwitcherFlash', class: 'html' }, 'flash');
	var aSwitcherHtml = Builder.node('a', { href: '#html', id: 'aSwitcherHtml', class: 'flash' }, 'html');
	var spanSwitcherFlash = Builder.node('span', { id: 'spanSwitcherFlash', class: 'flash' }, 'flash');
	var spanSwitcherHtml = Builder.node('span', { id: 'spanSwitcherHtml', class: 'html' }, 'html');
	$(spanSwitcherFlash).hide();
	$(spanSwitcherHtml).hide();
	$('switcher').insert(aSwitcherFlash);
	$('switcher').insert(spanSwitcherFlash);
	$('switcher').insert(' | ');
	$('switcher').insert(aSwitcherHtml);
	$('switcher').insert(spanSwitcherHtml);
	
	//check if flash or html
	if (location.hash == '#html' || (location.hash != '#flash' && !checkCookie('flash'))) {
		setCookie('flash', 'off');
		doHtml();
		$$('#switcher .flash').invoke('hide');
		$$('#switcher .html').invoke('show');
	} else {
		setCookie('flash', 'on');
		doFlash();
		$$('#switcher .html').invoke('hide');
		$$('#switcher .flash').invoke('show');
	}
	
	$('aSwitcherFlash').observe('click', function(event) {
		setCookie('flash','on');
		doFlash();
		$$('#switcher .html').invoke('hide');
		$$('#switcher .flash').invoke('show');
	});
	$('aSwitcherHtml').observe('click', function(event) {
		setCookie('flash','off');
		window.location.href='#html';
		window.location.reload();
	});
});

function doFlash() {
	// Overwrite regular CSS used for alternative content to enable Full Browser Flash
	swfobject.createCSS("html", "height:100%;");
	swfobject.createCSS("body", "margin:0; padding:0; overflow:hidden; height:100%;");
	swfobject.createCSS("#altContent", "height:100%;");
	//swfobject.switchOffAutoHideShow();
	
	var flashvars = {};
	var params = {
		allowFullScreen: 'true',
		allowScriptAccess: 'sameDomain',
		wmode: 'transparent'
	};
	var attributes = {};
	swfobject.embedSWF("SoSound_Main.swf", "altContent", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}