function openWindow(nazevokna,sirka,vyska) {
	window.open("",nazevokna,'toolbar=0,location=0,menubar=0,scrollbars=0,width='+sirka+',height='+vyska+',resizable=1,top=20,left=20');
}

function obrazek(soubor){
	window.open("image.php?i="+soubor,"obrazek","toolbar=0,location=0,menubar=0,scrollbars=1,width=800,height=600,resizable=1,top=20,left=20");
}

function menu(id,akce){
	var vrch;
	var stav=document.getElementById(id).style.display;

	if(!document.getElementById(id)){
		return false;
	}else{
		if(akce=="on"){
			menu_closeall();
			document.getElementById(id).style.display="";
			document.getElementById(id).parentNode.firstChild.style.color="#0F97A2";
			document.getElementById(id).parentNode.firstChild.style.backgroundColor="#B3B3B3";

			vrch=document.getElementById(id).offsetTop+document.getElementById(id).offsetParent.offsetTop;
			vyska=document.getElementById(id).offsetHeight;
			spodek=vyska+vrch;
			if(spodek>555){
				rozdil=spodek-555;
				if((vrch-rozdil)<150){rozdil-=(150-(vrch-rozdil));}
				document.getElementById(id).style.top=(document.getElementById(id).offsetTop-rozdil)+"px";
			}
		}else{
			document.getElementById(id).style.display="none";
			document.getElementById(id).parentNode.firstChild.style.color="";
			document.getElementById(id).parentNode.firstChild.style.backgroundColor="";
		}
		return true;
	}
}

function submenu(id2,akce){
	var vrch;
	var stav=document.getElementById(id2).style.display;
	if(!document.getElementById(id2)){
		return false;
	}else{
		if(akce=="on"){
			document.getElementById(id2).style.display="";
			document.getElementById(id2).parentNode.firstChild.style.color="#0F97A2";
			document.getElementById(id2).parentNode.firstChild.style.backgroundColor="#B3B3B3";

			if(id2=="hlavnimenu8_1"){
				document.getElementById(id2).style.top="0px";
			}else if(id2=="hlavnimenu8_2"){
				document.getElementById(id2).style.top="-100px";
			}else if(id2=="hlavnimenu8_3"){
				document.getElementById(id2).style.top="-110px";
			}else if(id2=="hlavnimenu6_4"){
				document.getElementById(id2).style.top="-100px";
			}
			else if(id2=="hlavnimenu3_1"){
				document.getElementById(id2).style.top="-17px";
			}
			else{
				vrch=document.getElementById(id2).offsetTop+document.getElementById(id2).parentNode.offsetTop+document.getElementById(id2).parentNode.parentNode.offsetTop+document.getElementById(id2).parentNode.parentNode.parentNode.offsetTop;
				vyska=document.getElementById(id2).offsetHeight;
				spodek=vyska+vrch;
				if(spodek>555){
					rozdil=spodek-555;
					if((vrch-rozdil)<150){rozdil-=(150-(vrch-rozdil));}
					document.getElementById(id2).style.top=(document.getElementById(id2).offsetTop-rozdil)+"px";
				}
			}
		}else{
			document.getElementById(id2).style.display="none";
			document.getElementById(id2).parentNode.firstChild.style.color="";
			document.getElementById(id2).parentNode.firstChild.style.backgroundColor="";
		}
		return true;
	}
}

function menu_closeall(){
	var i=1;
	while(document.getElementById("hlavnimenu"+i)){
//		menu_closeall_submenu("hlavnimenu"+i);
		document.getElementById("hlavnimenu"+i).style.display="none";
		document.getElementById("hlavnimenu"+i).parentNode.firstChild.style.backgroundColor="";
		document.getElementById("hlavnimenu"+i).parentNode.firstChild.style.color="";
		i++;
	}
	return true;
}

function menu_closeall_submenu(menu){
	var a=1;
	while(document.getElementById(menu+'_'+a)){
		document.getElementById(menu+'_'+a).style.display="none";
		document.getElementById(menu+'_'+a).parentNode.firstChild.style.color="";
		document.getElementById(menu+'_'+a).parentNode.firstChild.style.backgroundColor="";
		a++;
	}
	return true;
}

function print_mainiframe(){
	window.frames.mainiframe.focus();
	window.frames.mainiframe.print();

}

function ajax_read(stranka, kam)
{

    var httpRequest;

    if(typeof window.ActiveXObject != 'undefined')
    {
        httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
        httpRequest = new XMLHttpRequest();
    }
    httpRequest.open("GET", stranka, true);
    httpRequest.onreadystatechange= function ()
    {
        ajax_stav(httpRequest, kam);
    };
    httpRequest.send(null);
}


function ajax_stav(httpRequest, kam)
{
    if (httpRequest.readyState == 4)
    {
        if(httpRequest.status == 200)
        {
            if (typeof kam == 'string')
            {
                document.getElementById(kam).innerHTML = httpRequest.responseText;
            }
            if (typeof kam == 'function')
            {
                kam(httpRequest.responseText);
            }
        }
        else
        {
            alert("Chyba pri nacitani stanky " + httpRequest.status +" : "+ httpRequest.statusText);
        }
    }
    else
    {
        if (typeof kam == 'string' && kam != '')
        {
            document.getElementById(kam).innerHTML = 'Aktualizuji...';
        }
    }
}

function prepni_aktuality(aktivni){
	
	if(aktivni=="aktuality"){
		document.getElementById("aktuality").style.background="url('img/aktuality.jpg')";		
		document.getElementById("neprehlednete").style.background="url('img/neprehlednete.jpg')";
		document.getElementById("aktuality").style.color="white";
		document.getElementById("neprehlednete").style.color="#1d7bcb";
		document.getElementById("aktuality_obsah").style.display="block";
		document.getElementById("neprehlednete_obsah").style.display="none";
	}
	else if(aktivni=="neprehlednete"){
		document.getElementById("aktuality").style.background="url('img/neprehlednete.jpg')";		
		document.getElementById("neprehlednete").style.background="url('img/aktuality.jpg')";
		document.getElementById("aktuality").style.color="#1d7bcb";
		document.getElementById("neprehlednete").style.color="white";
		document.getElementById("aktuality_obsah").style.display="none";
		document.getElementById("neprehlednete_obsah").style.display="block";		
	}
}

function formular(form_pole,akce,vychozi){
	if(!(objekt=document.getElementById(form_pole))){return false;}
	
	if(akce=="vstup"){
		if(objekt.value==vychozi){
			objekt.value="";
			objekt.style.color="black";
		}
	}else if (akce=="vystup"){
		if(objekt.value==""){
			objekt.value=vychozi;
			objekt.style.color="";
		}		
	}
}

function display_by_checkbox(checkbox_id,array_hide_id){
	if(!(checkbox_object=document.getElementById(checkbox_id))){return false;}
	
	for ( var i = 0; i < array_hide_id.length; i++) {
		
		if(checkbox_object.checked==true){
			zmen_stav(array_hide_id[i],'on');
		}else{
			zmen_stav(array_hide_id[i],'off');
		}
	}
}

function zmen_stav(polozka,akce){
	
	if(!(uchyt=document.getElementById(polozka))){return false;}
		
	if(akce=="on"){
		uchyt.style.display="";
	}	
	else if (akce=="off"){
		uchyt.style.display="none";		
	}else if(akce=="change"){
		stav=uchyt.style.display;
		window.alert(akce);
	}
	
	return true;
}

