
/* ******************************************************************* */
/* ************************** ROZBALOVACI MENU *********************** */
/* ******************************************************************* */

function A(num) {
	/* IDENTIFIKUJE ELEMENT MENU S UDALOSTI onclick
		PARAMETRY:	
			num ( as integer )			- ( dale pak hodnota 'd'=<div>, 'p'=<img>)
	*/

	var x = document.getElementById('d' + num);
	var y = document.getElementById('p' + num);
	if (y==null) {var y = document.getElementById('ctl00_Lmenu1_p' + num);}
    S(x,y);
}

function S(objElement, objElement2) {
	/* ZPRACUJE POZADAVEK NA ZOBRAZENI / SCHOVANI CASTI MENU
		PARAMETRY:	
			objElement ( as <div> )			- element, ktery ma byt zobrazen / skryt
			objElement ( as <img> )			- element, kde ma byt zmenen src=  (+/-)
	*/

	var showit = GetCookie('menulevel');
	if (showit==null) {showit='a'};
	var index = showit.indexOf(objElement2.id + '!');
	if (objElement.style.display == 'block'){
		objElement.style.display = 'none';
		objElement2.src = '../P/p.gif';
		objElement2.title = 'Rozbalit';
		if (index !=-1) {
			showit = showit.replace(objElement2.id + '!', '');
			SetCookie('menulevel', showit);
		}
		ResetTree(objElement);
	} else {
			objElement.style.display = 'block';
			objElement2.src = '../P/m.gif';
			objElement2.title = 'Schovat';
			SetCookie('menulevel',showit + objElement2.id + '!');
		}
}


function ResetTree(objElement){
	/* SKRYJE CELOU VETEV MENU A ODZNACI CHECKBOXY, VCETNE PODRIZENYCH ELEMENTU
		PARAMETRY:	
			objElement ( as <div> )			- rodicovsky element vetve
	*/
	var Y; var tn;
	var showlevel = GetCookie('menulevel');
	var showchecked = GetCookie('menuchecked');
	for(var i=0; i < objElement.childNodes.length; i++) {
		Y = objElement.childNodes[i];
		if (Y){
			tn = Y.nodeName.toLowerCase();
			if (tn.length > 0) {
				if (tn == 'input') {
					if (Y.checked == true) {
						Y.checked = false;
						var index = showchecked.indexOf(Y.id + '!');
						if (index !=-1) {
							showchecked = showchecked.replace(Y.id + '!', '');
							SetCookie('menuchecked', showchecked);
						}
					}
				}
			if (tn == 'div') {
				if (Y.id != null){
					if (Y.id.substring(0,1) == 'd') {
						Y.style.display = 'none';
						var objElement2 = document.getElementById('p' + Y.id.substring(1));
						if (objElement2==null) {var objElement2 = document.getElementById('ctl00_Lmenu1_p' + Y.id.substring(1));}
						objElement2.src = '../P/p.gif';
						objElement2.title = 'Rozbalit';
						var index = showlevel.indexOf(objElement2.id + '!');
						if (index !=-1) {
							showlevel = showlevel.replace(objElement2.id + '!', '');
							SetCookie('menulevel', showlevel);}
						}
					}
					ResetTree (Y);
				}
			}
		}
	}
}


function SetCookie(name, value) {
	/* ZAPISE / VYMAZE Z COOKIE id ELEMENTU MENU, KTERY JE PREDMETEM POZADAVKU
		PARAMETRY:	
			name ( as string )					- jmeno cookie : ('menuchecked' / 'menulevel')
			value ( as <div> OR <checkbox> )	- id elementu
	*/
	
	var $expire = new Date();
	$expire.setTime($expire.getTime() + 24 * 3600 * 1000);
	document.cookie = name + '=' + encodeURI(value) + 
	'; expires=' + $expire.toGMTString() + 
	'; path=/'
}


function GetCookie(name) {
	/* PRECTE Z COOKIE id ELEMENTU MENU, KTERY MAJI BYT ZOBRAZEN
		PARAMETRY:	
			name ( as string )			- jmeno cookie, ktere ma byt precteno ('menuchecked' / 'menulevel')
	*/
	
	var docCookie = document.cookie;
	var index = docCookie.indexOf(name + '=');
	if (index == -1) {return null;}
	index = docCookie.indexOf('=',index) + 1;
	var endstr = docCookie.indexOf(';',index);
	if (endstr == -1) {endstr = docCookie.length;}
	return decodeURI(docCookie.substring(index,endstr));
}


function C(num) {
	/* ZPRACUJE onclick NA CHECKBOXu
		PARAMETRY:	
			num ( as integer )				- id elementu
	*/

	var objElement = document.getElementById('c' + num);
	var showit = GetCookie('menuchecked');
	if (objElement.checked == false) {
		var index = showit.indexOf(objElement.id + '!');
		if (index !=-1) {
			showit = showit.replace(objElement.id + '!', '');
			SetCookie('menuchecked', showit);
		}
	} else {
		if (showit==null) {
			SetCookie('menuchecked',objElement.id + '!');
		} else {
			if (showit.indexOf(objElement.id + '!') == -1) {
				SetCookie('menuchecked',showit + objElement.id + '!');
			}
		}
	}
}


function cCriteria(name) {
	/* ZPRACUJE ZMENU DAT V ELEMENTECH LEVEHO MENU
		PARAMETRY:	
			name ( as string )				- ID elementu
	*/
	
	var objElement = document.getElementById(name);
	if (objElement.tagName == 'INPUT' && objElement.type == 'checkbox') {SetCookie(name, objElement.checked);}
	if (objElement.tagName == 'INPUT' && objElement.type == 'text') {SetCookie(name, objElement.value);}
	if (objElement.tagName == 'SELECT') {
		SetCookie(name + 'i', objElement.selectedIndex);
		SetCookie(name + 'v', objElement.value);
	}
	if (objElement.tagName == 'IMG') {
		var actualValue = objElement.src.substring((objElement.src.length - 5), (objElement.src.length - 4));
		var newValue = 0
		if (actualValue == 0) {
			newValue = 1;
			objElement.src = objElement.src.replace('_0.', '_1.');
		} else {
			newValue = 0;
			objElement.src = objElement.src.replace('_1.', '_0.');
		}
		SetCookie(name, newValue);
	}
}



/* ******************************************************************* */
/* **************** INFORMACNI / CHYBOVA ZPRAVA ********************** */
/* ******************************************************************* */

function showMsg(small, alert, leftalign) {
	/* ZOBRAZI UZIVATELSKOU ZPRAVU
		PARAMETRY:	
			small ( true / false )		- zobrazit v malem okne
			alert ( true / false)		- cervene pismo, bily podklad
			leftalign ( true / false )	- text zarovnan do leva (false = centrovat na stred, resp. dle css)
	*/
	
	/* zamezi zobrazovani zprav pri kliknuti na zpet v browseru */
	if (GetCookie('showMsg') == true) {		
	/* nastavi malou ci velkou zpravu vcetne pozice na obrazovce */
	var x = screen.availWidth/2;
	var obj = document.getElementById('msg1');
	obj.style.top = '10px';
	if (small== true) {
		obj.style.left = (x-200) + 'px';
		obj.style.width = '400px';
		obj.style.height = '45px';
	} else {
		obj.style.left = (x-400) + 'px';
		obj.style.width = '800px';
		obj.style.height = '300px';
	}
	
	/* zobrazi dle css nebo jako alert s vyraznejsimi barvami */
	if (alert== true) {
		obj.style.color = 'red';
		obj.style.backgroundColor = 'white';
	}
	
	if (leftalign== true) {obj.style.textAlign = 'left';}
	obj.style.visibility = 'visible';
}
SetCookie('showMsg', false)
}

function hideMsg(name, back) {
	/* SKRYJE UZIVATELSKOU ZPRAVU
		PARAMETRY:	
			name ( as string )			- nazev DIVu ktery se ma skryt
			back ( true / false)		- jit na predchozi html stranu pri schovani zpravy
	*/
			
	var obj = document.getElementById(name);
	obj.style.visibility = 'hidden';
	if (back==true) {history.back();}
}


/* ******************************************************************* */
/* ****************  OBECNE FORMATOVACI FUNKCE  ********************** */
/* ******************************************************************* */

function r(n,v,h) {
	/* DYNAMICKY PRIRADI STYL PODLE POLOHY MYSI NAD DATALISTEM
		PARAMETRY>
			n	( this )				- identifikace aktualniho radku
			v	( integer )				- cislo pozadovaneho stylu v rozsahu (1 az 4)
			h	( height )				- cislo pozadovaneho stylu (styl musi byt v css)
	*/

	if (h == 0) {
		n.className = 'row' + v
	} else {
		n.className = 'row' + v + ' h' + h
	}
}

function ImgSetWS() {                                                          
	/* URCI MAXIMALNI SIRKU OBRAZKU - pro IE, v NN realizovano pomoci CSS 
		obrazek je zmensen na pozadovanou sirku pri zachovani pomeru stran
		pracuje ve spolupraci s nadrazenym prvkem SPAN a CSS
	*/
	
	im = event.srcElement;  
	imp = im.parentElement;
	if (imp.scrollWidth>imp.offsetWidth) {
		h = im.offsetHeight/(imp.scrollWidth/imp.offsetWidth);
		im.style.width = imp.offsetWidth;
		im.style.height = h;
	}
	imp.removeNode();
}

function fullSizeImage(url) {
	
	window.open(url,'pic','toolbar=0,location=0,status=0,resizable=1');
}

