function writeConsole(content)
	{
	top.consoleRef=window.open('','_blank','width=800,height=600'+',menubar=0'+',toolbar=0'+',status=0'+',scrollbars=1'+',resizable=1')
	top.consoleRef.document.writeln('<html><head><title>Console</title></head>'+'<body bgcolor=white onLoad="self.focus()">'+content+'</body></html>')
	top.consoleRef.document.close()
	}

function OldMSIE()
	{
	var $reg = /\bMSIE (\d)\b/;
	$result = navigator.appVersion.match($reg);
	if($result && $result[1] < 7) { return true; }
	return false;
	}

function numberXpercent($value, $size) // obsahuje-li $value symbol %, pak funkce vraci ciselnou hodnotu, ktera odpovida tomuto procentu ze $size
	{
	if($value.toString().indexOf("%") > -1) // souradnice je uvedena v procentech "%"
		{ $dimension = ($size * parseInt($value) / 100); }
	else // souradnice neni uvedena v procentech "%"
		{ $dimension = parseInt($value); }
	return($dimension);
	}

function setOpacity($element, $value) // funkce nastavi pruhlednost pro specifikovany objekt, pruhlednost se udava jako hodnota od 0 do 10, 10 = normalni, 0 = neviditelne
	{
	$element.style.opacity = $value/10;
	$element.style.filter = 'alpha(opacity=' + $value*10 + ')';
	}

function ArraySearch($array, $value)
	{
	if(!$array) return -1;
	if($array.length < 1) return -1;
	for(var $i = 0; $i < $array.length; ++$i)
		{
		if($array[$i] == $value) return $i;
		}
	return -1;
	}

function NowUTS() // funkce vraci casove razitko s milisekundami pro aktualni cas
	{
	var d = new Date();
	return Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
	}

/* VVV - focus and blur input in logon form - VVV */
	function OnFocusInput($id, $password)
		{
		$inputOldValue = document.getElementById($id).value;
		document.getElementById($id).value = '';
		//if($password) document.getElementById($id).type = 'password';
		}
	
	function OnBlurInput($id, $password)
		{
		if(document.getElementById($id).value == '')
			{
			document.getElementById($id).value = $inputOldValue;
			}
		//if($password && document.getElementById($id).value == 'Heslo') document.getElementById($id).type = 'text';
		}
/* AAA - focus and blur input in logon form  - AAA */

/* VVV - Zobrazovani / Skryvani vsech SELECT menu - VVV */
	function Set_Select_Menu()
		{
		var $forms_length = document.forms.length;
		
		for (var $i = 0; $i < $forms_length; $i++)
			{
			// prochazeni vsech formularu na strance
			var $elements_length = document.forms[$i].elements.length
			
			for (var $j = 0; $j < $elements_length; $j++)
				{
				// prochazeni vsech elementu ve formulari
				var $element = document.forms[$i].elements[$j];
				
				if ($element.tagName == "SELECT")
					{
					// elementem je SELECT menu
					$select_style = $element.style;
						
						// nastaveni viditelnosti SELECT menu
						if (($select_style.visibility == "visible") || (!$select_style.visibility))
							{
							$select_style.visibility = "hidden";
							}
						else
							{
							$select_style.visibility = "visible";
							}
					}
				}
			}
		}
/* AAA - Zobrazovani / Skryvani vsech SELECT menu - AAA */

/* VVV - New Window - VVV */
	// kontrola vsech odkazu na strance
	function Check_Links()
		{
		$number_links = document.links.length;
		for (var $i = 0; $i < $number_links; $i++)
			{
			// prochazeni vsech odkazu
			if (document.links[$i].onclick)
				{
				// u odkazu je uvedena udalost onClick
				document.links[$i].href = '#';
				}
			}
		}
/* AAA - New Window - AAA */

function CheckDocumentBody() // kontrola nacteni obsahu HTML
	{
	var $html_page = document.documentElement.innerHTML.toLowerCase();
	if($html_page.indexOf("</body>") > -1) {
			// uzaviraci tag </body> je soucasti obsahu dokumentu
			jsLoad();
		} else {
			// uzaviraci tag </body> neni soucasti obsahu dokumentu
			// -> kontrola dokumentu po pul vterine 
			window.setTimeout("CheckDocumentBody()",500);
		}
	}

function FindNodeInTRee($parent, $tree, $level) // funkce vraci ukazatel na konkretni element uvnitr prvku s ID = $idParent, ktery je urcen stromovou strukturou. V pripade, ze odpovidajicich elementu je vic, vraci pole s jejich ukazateli.
	{
	if(!$level) var $level = 0;
	var $result = new Array(); // navratova hodnota obsahujici ukazatele na elementy odpovidajici specifikaci
	
	/* VVV - tvorba podminek pro identifikaci specifikovaneho elementu - VVV */
		var $desiredChild = $tree[$level]; // specifikace zadaneho elementu pomoci CSS selektoru
		
		var $cSelector = new Array(); // typ selektoru pro jednotlive podminky
		var $cString = new Array(''); // testovany retezec pro jednotlive podminky
		var $cOrder = -1; // poradi podminky
		
		for(var $i = 0; $i < $desiredChild.length; ++$i) // rozparsovani jednotlivych slozek specifikace
			{
			$_thisLetter = $desiredChild.substring($i, ($i +1));
			switch($_thisLetter) // precteni jednoho znaku
				{
				case '#': // znak uvozuje id elementu
					$cSelector[++$cOrder] = 'id';
					$cString[$cOrder] = '';
					break;
				case '.': // znak uvozuje tridu elmentu
					$cSelector[++$cOrder] = 'class';
					$cString[$cOrder] = '';
					break;
				default: // znak je soucasti nazvu id/class
					if(!$cSelector[$cOrder]) $cSelector[++$cOrder] = 'tag'; // typ selektoru nebyl v prvni iteraci urcen
					$cString[$cOrder] = $cString[$cOrder] + $_thisLetter;
				}
			}
	/* AAA - tvorba podminek - AAA */
	
	/* VVV - prochazeni potomku - VVV */
		var $children = $parent.childNodes; // seznam potomku
		
		for(var $i = 0; $i < $children.length; ++$i) // prochzeni vsech potomku
			{
			var $child = $children[$i]; // aktualne zpracovavany potomek
			///alert('$child = ' + $child + "\n" + 'nodeType = ' + $child.nodeType + "\n" + 'ID = ' + $child.id);
			if($child.nodeType == 1) // potomek je HTML element
				{
				/* VVV - overeni platnosti definovanych podminek - VVV */
					var $success = true;
					for(var $j = 0; $j < $cString.length && $success; ++$j)
						{
						///alert('$cSelector[$j] = ' + $cSelector[$j])
						switch($cSelector[$j])
							{
							case 'id':
								if($child.id != $cString[$j]) { $success = false; } // id nenalezeno
								break;
							case 'class':
								var $classes = $child.className.split(' '); // vytvoreni pole ze seznamu trid oddelenych mezerou
								var $found = false; // identifikator nalezeni
								for(var $ci = 0; $ci < $classes.length; ++$ci) // prochazeni vsech trid
									{
									if($classes[$ci] == $cString[$j]) { $found = true; } // trida nalezena
									}
								if(!$found) { $success = false; } // trida nebyla v seznamu nalezena
								break;
							default: // selektorem je nazev tagu
								if($child.tagName.toLowerCase() != $cString[$j]) { $success = false; } // tag nenalezen
							}
						}
				/* AAA - overeni platnosti - AAA */
				
				///alert("tag: " + $child.tagName + "\nID: " + $child.id + "\nclass: " + $child.className + "\n\nhledano: " + $desiredChild + "\nnalezeno: " + $success);
				if($success) // element nalezen
					{
					///alert($child.id + '	' + $level + ' < ' + ($tree.length - 1) + "\n" + $tree);
					if($level < ($tree.length - 1))
						{
						var $subResult = FindNodeInTRee($child, $tree, ($level + 1));
						for(var $j = 0; $j < $subResult.length; ++$j)
							{
							$result.push($subResult[$j]);
							}
						}
					else
						{
						$result.push($child);
						}
					}
				}
			}
	/* AAA - prochazeni potomku - AAA */
	
	return($result);
	}

function HideXDisplayChildren($parent, $childrenDef)
	{
	if(!$childrenDef) var $childrenDef = new Array();
	var $foundElements = FindNodeInTRee($parent, $childrenDef);
	
	for(var $i = 0; $i < $foundElements.length; ++$i) // prochzeni vsech potomku
		{
		var $child = $foundElements[$i]; // aktualne zpracovavany potomek
		if($child.style.display == 'none') { $child.style.display = 'block'; }
		if($child.style.display == 'block' || !$child.style.display) { $child.style.display = 'none'; }
		}
	}

function AddXRemoveClass($ref, $class, $action)
	{
	var $found = false;
	var $classList = $ref.className.split(' ');
	for(var $i = 0; $i < $classList.length; ++$i)
		{
		if($classList[$i] == $class && $action != 'add')
			{
			$classList.splice($i, 1);
			$found = true;
			}
		}
	if(!$found && $action != 'remove') $classList.push($class);
	var $newClassString = $classList.join(' ');
	$ref.className = $newClassString;
	return $newClassString;
	}

/* VVV - LeftCol - VVV */
	function LeftCol_Hide($ref)
		{
		$ref.style.width = '10px';
		$ref.style.height = $ref.offsetHeight+'px';
		AddXRemoveClass($ref, 'close', 'add');
		AddXRemoveClass($ref, 'hover', 'remove');
		AddXRemoveClass(document.getElementById('center'), 'without-leftcol', 'add');
		}
	
	function LeftCol_Display($ref)
		{
		$ref.style.width = 'auto';
		$ref.style.height = 'auto';
		AddXRemoveClass($ref, 'close', 'remove');
		AddXRemoveClass($ref, 'hover', 'remove');
		AddXRemoveClass(document.getElementById('center'), 'without-leftcol', 'remove');
		}
/* AAA - LeftCol - AAA */

/* VVV - Calendar - VVV */
	function HideAllDelItems($idParent) // skryt vsechny denni listy kalendare
		{
		var $parent = document.getElementById($idParent);
		var $children = $parent.childNodes;
		for(var $i = 0; $i < $children.length; ++$i)
			{
			var $child = $children[$i];
			if($child.className == 'DEL-item')
				{
				document.getElementById($child.id).style.display = 'none';
				}
			}
		}
	
	function DefineEventsFromCalendar($idParent, $activeStyle)
		{
		var $foundElements = FindNodeInTRee(document.getElementById($idParent), Array('.boxcont', 'table', 'tbody', 'tr', 'td.activeDay'));
		///alert('nalezene elementy:' + "\n" + $foundElements);
		if($foundElements)
			{
			for(var $i = 0; $i < $foundElements.length; ++$i)
				{
				///$foundElements[$i].style.border = '2px solid red';
				var $_thisId = $foundElements[$i].id;
				///alert('document.getElementById("dayEventList-' + $_thisId.substring(4) + '").style.display = "block";');
				$reAction.push(new Array(('#' + $_thisId), 'onmouseover', 'document.getElementById("dayEventList-' + $_thisId.substring(4) + '").style.cssText = "' + $activeStyle + '";'));
				$reAction.push(new Array(('#' + $_thisId), 'onmouseout',	'document.getElementById("dayEventList-' + $_thisId.substring(4) + '").style.display = "none";'));
				}
			}
		}
/* AAA - Calendar - AAA */

