//a_mid udržuje info o aktuální module id
var a_mid = '0';
//funkce rozbalí všechny rodiče až k požadovanému modulu
function findInMenu(mid) {
	mydoc = parent.menu.document;
	with(mydoc) {
		//pokud není a_mid 0 nastav css class na neaktivní dokument
		if (a_mid != '0') {
			getElementById(a_mid).className = "doc";
		}
		//pokud není požadovaný modul 0
		if (mid != '0') {
			//nastaví css class jako aktivní dokument
			getElementById(mid).className = "doc-active";
			myparent = getElementById(mid).parentNode;
			//prochází všechny rodičovské nody
			while(myparent) {
				//pokud se jedná o ul
				if (myparent.nodeName.toLowerCase() == "ul") {
					//a ul je skryté 
					if (myparent.className == "skryt") {
						myparent.className = "zobrazit";
						//prochází sourozence a mění u odkazů css class na rozbalenou 
						sib = myparent.previousSibling;
						while(sib) {
							if (sib.nodeName.toLowerCase() == "a") {
								if (sib.className == "plus") {
									sib.className = "minus";
								}
							}
							sib = sib.previousSibling;
						}
					}
				}
				myparent = myparent.parentNode;
			}
		}
	}
	a_mid = mid;
}

function a(what) {
	if (what.className == "plus") {
		what.className = "minus";
	} else {
		what.className = "plus";
	}
	sib = what.nextSibling;
	while(sib) {
		if (sib.nodeName.toLowerCase() == "ul") {
			if (sib.className == "skryt") {
				sib.className = "zobrazit";
			} else {
				sib.className = "skryt";
			}
		}
		sib = sib.nextSibling;
	}
}

function b(mid) {
	if (a_mid != '0') {
		document.getElementById(a_mid).className = "doc";
	}
	if (mid != '0') {
		document.getElementById(mid).className = "doc-active";
	}
	a_mid = mid;
}

function showImg(my_url, my_width, my_height) {
	if (window.showModalDialog) {
		my_height = my_height * 1.1;
		my_width = my_width * 1.03;
		var my_x = (screen.width - my_width) / 2;
		var my_y = (screen.height - my_height) / 2;
		var myBars = 'center=no;help=no;status=no;scroll=yes;edge=raised;dialogHeight='+ (my_height) +'px;dialogLeft=' + my_x + 'px;dialogTop=' + my_y + 'px;dialogWidth=' + my_width+ 'px;resizable=yes';
		var my_param = window;
		window.showModalDialog(my_url, my_param, myBars);
	} else {
		my_height = my_height * 1.05;
		my_width = my_width * 1.05;
		var my_x = (screen.width - my_width) / 2;
		var my_y = (screen.height - my_height) / 2;
		var myBars = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no';
		var myOptions = 'screenX=' + my_x + ',screenY=' + my_y + ',x=' + my_x + ',y=' + my_y + ',scrollbars=yes,width=' + my_width+ ',height='+my_height+',resizeable=no,dependent=yes,alwaysRaised=yes,top=' + my_y + ',left=' + my_x;
		var myFeatures = myBars + ',' + myOptions;
		var newWin = window.open(my_url, 'detail', myFeatures);
		newWin.focus();
	}
}

function resizeMenu() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  }
	//var obj = document.getElementById('panel');
	if (document.getElementById('panel')) {
  	document.getElementById('panel').style.height = (myHeight - 90) + 'px';
  }
}

function hideDictionary()
{
  var frame = document.getElementById("dict");
			  
  frame.style.visibility = "hidden";
  frame.style.display = "none";
}
			  
function winW() {
   if (window.innerWidth)
      /* NN4 a kompatibilní prohlížeče */
      return window.innerWidth;
   else if
   (document.documentElement &&
   document.documentElement.clientWidth)
      /* MSIE6 v std. režimu - Opera a Mozilla
      již uspěly s window.innerHeight */
      return document.documentElement.clientWidth;
   else if
   (document.body && document.body.clientWidth)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientWidth;
   else
      return null;
}

function winH() {
   if (window.innerHeight)
      /* NN4 a kompatibilní prohlížeče */
      return window.innerHeight;
   else if
   (document.documentElement &&
   document.documentElement.clientHeight)
      /* MSIE6 v std. režimu - Opera a Mozilla
      již uspěly s window.innerHeight */
      return document.documentElement.clientHeight;
   else if
   (document.body && document.body.clientHeight)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientHeight;
   else
      return null;
}

function showDictionary(ev, n)
{
  var frame = document.getElementById("dict");
  var pos = { x:0, y:0 };
  
  frame.src = "observ-dict.php?id="+n;
  // Nastavení okna se slovníkem
  pos.x = ev.clientX; pos.y = ev.clientY;	// Pozice myši
  frame.style.left = pos.x + 5 + 'px';
  frame.style.top = pos.y + 5 + 'px';
  frame.style.display = "block";
  frame.style.visibility = "visible";
}

function resizeDictionary(w, h) {
	var iframe = document.getElementById("dict");
	var pos = { x:parseInt(iframe.style.left), y:parseInt(iframe.style.top) };
	
	if(pos.x+w > winW())
	{
		iframe.style.left = (winW()-w - 10)+'px';
	}
	if(pos.y+h > winH())
	{
		iframe.style.top = (winH()- h - 10)+'px';
	}
	iframe.style.height = h+'px';
}

