function Is() {
    agent  = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns    = ((agent.indexOf('mozilla')   !=   -1) &&
		 ((agent.indexOf('spoofer')   ==   -1) &&
		 (agent.indexOf('compatible') ==   -1)));
    this.ns2   = (this.ns && (this.major      ==    3));
    this.ns3   = (this.ns && (this.major      ==    3));
    this.ns4b  = (this.ns && (this.major      ==    4) &&
		 (this.minor		      <= 4.03));
    this.ns4   = (this.ns && (this.major      >=    4));
    this.ns6   = (this.ns && (this.major     >=    5));
    this.ie    = (agent.indexOf("msie")       !=   -1);
    this.ie3   = (this.ie && (this.major      <     4));
    this.ie4   = (this.ie && (this.major      ==    4) &&
		 (agent.indexOf("msie 5.0")   ==   -1));
    this.ie5   = (this.ie && (this.major      ==    4) &&
		 (agent.indexOf("msie 5.0")   !=   -1));
    this.ie55  = (this.ie && (this.major      ==    4) &&
		 (agent.indexOf("msie 5.5")   !=   -1));
    this.ie6  = (this.ie && (this.major      ==    4) &&
		 (agent.indexOf("msie 6.0")   !=   -1));
}


var is = new Is();

if(is.ns4) {
    doc = "document";
    sty = "";
    htm = "";
	LayerShow = "show";
	bws = "ns";
} else {
    doc = "document.all";
    sty = ".style";
    htm = "";
	LayerShow = "visible";
	bws = "ie";
}

var menuarr = new Array;

function MenuShow(lay,ho) {
	if(ho == "YES") {
		for(var i = 0; i < menuarr.length; i++) {
			ly = eval(doc + "['menuD" + menuarr[i] + "']" + sty);
			ly.visibility = "hidden";
		}
	}
	if (lay==""){}
	else
	{
	ly = eval(doc + "['" + lay + "']" + sty);
	ly.visibility = LayerShow;
	}
}

function MenuHide(lay) {
	ly = eval(doc + "['" + lay + "']" + sty);
	if(is.ns4) {
		ly.visibility = "hidden";


	} else	{
		if(event.x < (parseInt(ly.left) + 2) || event.x > (parseInt(ly.left) + parseInt(ly.width) - 2)) {
			ly.visibility = "hidden";
		}
		if(event.y < (parseInt(ly.top) - 5) || event.y > (parseInt(ly.top) + parseInt(ly.height))) {
			ly.visibility = "hidden";
		}
	}

}

urlPrefix = "";
PrintSwitch = -1;

function Go (id,toid)
{

 window.location='page.php?id='+id+"&toid="+toid;
}






//Object constructor
function makeMenu(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
    if (n) this.css=eval(nest+'document.'+obj)
    else if (ns6) this.css=document.getElementById(obj).style
    else if (ie) this.css=eval(obj+'.style')						
	this.state=1
	this.go=0
        if (n) this.width=this.css.document.width
        else if (ns6) this.width=document.getElementById(obj).offsetWidth
        else if (ie) this.width=eval(obj+'.offsetWidth')
	this.left=b_getleft
    this.obj = obj + "Object"; 	eval(this.obj + "=this")	
}
//Get's the top position.
function b_getleft(){
        if (n||ns6){ gleft=parseInt(this.css.left)}
        else if (ie){ gleft=eval(this.css.pixelLeft)}
	return gleft;
}
/********************************************************************************
Deciding what way to move the menu (this is called onmouseover, onmouseout or onclick)
********************************************************************************/
function moveMenu(){
	if(!oMenu.state){
		clearTimeout(tim)
		mIn()	
	}else{
		clearTimeout(tim)
		mOut()
	}
}
//Menu in
function mIn(){
	if(oMenu.left()>-oMenu.width+lshow){
		oMenu.go=1
		oMenu.css.left=oMenu.left()-move
		tim=setTimeout("mIn()",menuSpeed)
	}else{
		oMenu.go=50
		oMenu.state=1
	}	
}
//Menu out
function mOut(){
	if(oMenu.left()<0){
		oMenu.go=1
		oMenu.css.left=oMenu.left()+move
		tim=setTimeout("mOut()",menuSpeed)
	}else{
		oMenu.go=50
		oMenu.state=0
	}	
}
/********************************************************************************
Checking if the page is scrolled, if it is move the menu after
********************************************************************************/
function checkScrolled(){
	if(!oMenu.go) oMenu.css.top=eval(scrolled)+parseInt(ltop)
	if(n||ns6) setTimeout('checkScrolled()',30)
}
/********************************************************************************
Inits the page, makes the menu object, moves it to the right place, 
show it
********************************************************************************/
function menuInit(){
	oMenu=new makeMenu('divMenu')
        if (n||ns6) scrolled="window.pageYOffset"
        else if (ie) scrolled="document.body.scrollTop"
	oMenu.css.left=-oMenu.width+lshow
        if (n||ns6) ltop=oMenu.css.top
        else if (ie) ltop=oMenu.css.pixelTop
	oMenu.css.visibility='visible'
	if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();
}

function winOpen(urlx)
{
var tposx= (screen.width- 680)/2
var tposy= (screen.height- 680)/2
var newWin1=window.open(urlx,"win","toolbar=no,width=780,height=600,directories=no,status=no,scrollbars=yes,resizable=yes, menubar=no");
  newWin1.moveTo(tposx,tposy);
  newWin1.focus();
}

/************************************* valiadace udaju z formularu ****************************/
function valForm(fieldRequired,fieldDescription,formobj)
{
//3) Enter dialog message
var alertMsg = "Tyto položky jsou povinné,\nprosim vyplòte je.\nPoložky:\n";

var l_Msg = alertMsg.length;

for (var i = 0; i < fieldRequired.length; i++){
var obj = formobj.elements[fieldRequired[i]];
if (obj){

switch(obj.type){
case "select-one":
if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "select-multiple":
if (obj.selectedIndex == -1){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "text":
case "textarea":
if (obj.value == "" || obj.value == null || obj.value=="rrrr-mm-dd" || obj.value == " "){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
default:
if (obj.value == "" || obj.value == null){
alertMsg += " - " + fieldDescription[i] + "\n";
}
}
}
}

if (alertMsg.length == l_Msg){
return true;
}else{
alert(alertMsg);
return false;};
}
