var show=true;
var ca = document.cookie.split(';');
for(var i=0;i<ca.length;i++)
{
	var tc=ca[i].split("=");
	if(trim(tc[0])=="interface" && trim(tc[1])=="html")
		show=false;
}
function trim(value){
	return value.replace(/^\s+/,'').replace(/\s+$/,'');
}
buildCookie();

function buildSite(loc)
{
	var flashVersion='9.0.115';
	if(show && swfobject.hasFlashPlayerVersion(flashVersion))//BUILD SWF
	{
		getToAnchor();
		swfobject.embedSWF(loc, 'website', '730', '650', flashVersion,'', {}, {bgcolor: '#ffffff', menu: 'true', allowscriptaccess : 'always'}, {id: 'website'});
		SWFID = "website"

	}
	else
	{
		anchorToGet();
		if(show)//BUILD ERROR
			document.getElementById('error').style.visibility = 'visible';
		else//BUILD SWITCHER
			document.getElementById('switch').style.visibility = 'visible';
		document.getElementById('content').style.visibility = 'visible';
	}
}

function switchInterface()
{
	if(show)
	{
		show=false;
		buildCookie();
		
		hashes=location.hash.split("/");
		if(hashes[1]==undefined || hashes[1]=="")
			hashes[1]="home";
		if(hashes[2]==undefined)
			hashes[2]="";
		location.href="/"+hashes[1]+"/"+hashes[2]; 
	}
	else
	{
		show=true;
		buildCookie();
		getToAnchor();
	}
}

function anchorToGet()
{
	hashes=location.hash.split("/");
	if(hashes.length>1)
		location.href="/"+hashes[1]+"/"+hashes[2];
}
function getToAnchor()
{
	if(window.getPage!=undefined && window.getPage!="")
		location.href="/#/"+getPage+"/"+getTitle;
}

function buildCookie()
{
	if(show)
		document.cookie = "interface=flash;path=/";
	else
		document.cookie = "interface=html;path=/";
}

var openedCase = -1;
function openCase(caseId)
{
	if(openedCase!=-1)
		document.getElementById("case"+openedCase).style.display = "none";
		
	if(openedCase!=caseId)
	{
		document.getElementById("case"+caseId).style.display = "block";
		openedCase=caseId;
	}
	else
		openedCase=-1;
}