var oLMSAPI = null;

if (document.readyState)
{	
	if (document.readyState == "complete") onLoad();	
	else if (document.readyState == "interactive") setTimeout('onLoad()',100); // Opera 9.5	
	else if (document.readyState == "loading") setTimeout('onLoad()',100); // Chrome		
	else document.onreadystatechange = evt_OnReadyStateChange;
} else window.onload = onLoad; // Init pro Mozillu

function evt_OnReadyStateChange()
{
  if (document.readyState != 'complete') return;
  onLoad();
}

function onLoad()
{
	// Nastavení NADPISU
	if ((pom=document.getElementById('title_text'))!=null) pom.innerHTML = parent.cnt_currentTitle;;
	
	// Změna barevného schématu
	try {
		ChangeCScheme(parent.cscheme);
	}	catch (err) {}
	
	// Při zmene velikosti prováděj různé grafické kejkle k dosažení pěkného vzhledu
	document.body.onresize = onResizeMethod;
	window.onresize = onResizeMethod; // Pro mozillu	
	onResizeMethod(); // Prvotní zavolání je rovněž důležité
}

function onResizeMethod()
{
	obj = document.getElementById('mnuHome');
	if (obj!=null)
	if (document.body.clientWidth < 750) obj.style.display = "none"; else obj.style.display = "inline";
		
	obj = document.getElementById('mnuHelp');
	if (obj!=null)
	if (document.body.clientWidth < 700) obj.style.display = "none"; else obj.style.display = "inline";

	obj = document.getElementById('mnuReport');
	if (obj!=null)
	if (document.body.clientWidth < 600) obj.style.display = "none"; else obj.style.display = "inline";

	obj = document.getElementById('inp_search');
	if (obj!=null)
	if (document.body.clientWidth < 500) obj.style.width = "50px"; else obj.style.width = "";
}


function RegisterEvents()
{
	if (oLMSAPI == null) oLMSAPI = FindLMSAPI();
	//if (oLMSAPI != null) oLMSAPI.LRNListenForEvents(EventHandler); // Ztim neni potreba chytat udalosti od LMS
}

function ChangeCScheme(hodnota)
{
	try
	{
		document.getElementById('ss').href = "themes/"+hodnota+"/"+hodnota+".css";
  } catch(err)
	{
		return;
	}

  if ((pom=document.getElementById('logo_gopas'))!=null) pom.src=String('themes/'+hodnota+'/logo_gopas.png');
}

function changeBtn(strBtnName, strFileName)
{
	if ((pom=document.getElementById(strBtnName))!= null) pom.src = String('themes/'+parent.cscheme+'/'+strFileName);
}

function onSearch()
{
	if ((pom=document.getElementById('frmSearch'))!=null) pom.submit();
	return false;
}

function onReport()
{
	if ((pom=document.getElementById('frmReport'))!=null) pom.submit();
	return false;
}

function onHelp()
{
	if ((pom=document.getElementById('frmHelp'))!=null) pom.submit();
	return false;
}

function onHome()
{
	if ((pom=document.getElementById('frmHome'))!=null) pom.submit();
	return false;
}
