var hide_time = 300;
var tik_tak1;
var tik_tak2;
var akt_menu;
var akt_submenu;

function menu_on(mid) {
  // zrusime prave zobrazene
  if (mid!=akt_menu) {
    do_menu_off(akt_menu);
    do_submenu_off(akt_submenu);
    }
  // ulozime si, co jsme zobrazili
  akt_menu = mid;                 
  // zrusime timeout
  zrus_timeout();   
  // zvyraznime
  x = document.getElementById("mnuimg_"+mid);
  if (x) {
    if (x.src!='layout/mnu/'+mid+'_a.gif') {
      x.src = 'layout/mnu/'+mid+'_a.gif';
      }
    }
  }        
function menu_off(mid) {
  tik_tak1 = setTimeout("do_menu_off('"+mid+"');", hide_time)
  }
  
function do_menu_off(mid) {
  akt_menu = null;
  x = document.getElementById(mid);
  // zrusime zvyrazneni
  x = document.getElementById("mnuimg_"+mid);
  if (x) {
    if (x.src!='layout/mnu/'+mid+'.gif') {
      x.src = 'layout/mnu/'+mid+'.gif';
      }
    }
  }
  
function submenu_on(mid) {
  akt_submenu = mid;                 
  zrus_timeout();
  x = document.getElementById(mid);
  if (x) {
    x.style.display = 'block';
    }
  }

function submenu_off(mid) {
  tik_tak2 = setTimeout("do_submenu_off('"+mid+"');", hide_time)
  }
  
function do_submenu_off(mid) {
  x = document.getElementById(mid);
  if (x) {
    x.style.display = 'none';
    }
  }
      
function zrus_timeout() {
  if (tik_tak1) {
    clearTimeout(tik_tak1)
    }
  if (tik_tak2) {
    clearTimeout(tik_tak2)
    }
  }  
      
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function open_win(url, winWidth, winHeight, winRes) {
  if (winRes==1) { stat="resizable=1,scrollbars=1"; }
            else { stat="resizable=0,scrollbars=0"; };
  // calculate centered window position
  winLeft = Math.round((screen.width-winWidth)/2);
  winTop  = Math.round((screen.availHeight-winHeight)/2);
  winDef = "left="+winLeft+",top="+winTop+",height="+winHeight+",width="+winWidth+",directories=no,location=no,menubar=no,status=no,toolbar=no,"+stat;
  window.open(url, "", winDef);
  return true;
  }
  
var poc = 0;
var iwinTitle = document.title;
var lineCount = 1;
var lineHeight = 20;

function in_ff() {
  var agt=navigator.userAgent.toLowerCase();
  var firefox = (agt.indexOf("firefox") != -1);
  return firefox;
  }

function showImage(imgName, imWidth, imHeight, iTitle, iLines) { 
      if (poc!==0) { iwin.close(); }; 

      url = imgName;
      resStr = "resizable=0,scrollbars=0";
                                                             
      if (iLines) { 
        lineNum = iLines;
        } else {
        lineNum = lineCount;
        } 

      // define window oversize
      if (in_ff()) {
        winPlusWidth = 15;
        winPlusHeight = 35+(iLines-1)*lineHeight;
        } 
      else {
        winPlusWidth = 0;
        winPlusHeight = 20+(iLines-1)*lineHeight;
        }
      // calculate window size
      winHeight = imHeight + winPlusHeight;
      winWidth = imWidth + winPlusWidth;
      // test if the window is not too large
			heightOK = true;
      if (winHeight>screen.availHeight)
        { winHeight = screen.availHeight-80;
      	  resStr=",resizable=1,scrollbars=1";
    			heightOK = false;
      	}
      if (heightOK==false)
        { winWidth = winWidth+22;
      	}								 
      if (winWidth>screen.width)
        { winWidth = screen.width-80;
      	  resStr=",resizable=1,scrollbars=1";
      	}								 

      // calculate centered window position
      winLeft = Math.round((screen.width-winWidth)/2);
      winTop  = Math.round((screen.availHeight-winHeight)/2);

      iwin = window.open("", "", "left="+winLeft+",top="+winTop+",height="+(winHeight+25)+",width="+(winWidth+25)+",directories=no,location=no,menubar=no,status=no,toolbar=no"+resStr);
      iwin.document.write("<html><head><title>", iwinTitle, "</title>");
      iwin.document.write("<link rel='stylesheet' type='text/css' href='imgwin.css' title='formal'>");
      iwin.document.write("</head>");
      iwin.document.write("<body class=ImgShow>");
      iwin.document.write("<a href='' onClick=\"window.close(); return false;\"><img width=", imWidth," height=", imHeight," src=\"", url, "\" alt='' border=0></a>");
      iwin.document.write("<p>", iTitle);
      iwin.document.write("</body></html>");
      poc++;
      return true;
    }

function okno(_ID, _VICE) {
win_size_x=420; //horizontální velikost okna
win_size_y=390; //vertikální velikost okna
win_pos_x=(screen.width-win_size_x)/2; //horizontální pozice okna
win_pos_y=(screen.height-win_size_y)/2; //vertikální velikost okna

window.open('/dotaz_na_dostupnost.php?kod='+_ID+'&vice='+_VICE, 'vycentrovaneokno', 'resizable=no,scrollbars=no,width=' + win_size_x + ',height=' + win_size_y + ',top=200,left=' + win_pos_x)
}
 
/*******************************************************************************
* Nastaví fokus prázdné pole
*******************************************************************************/  
function fokus() {
  var input = document.getElementById('fraze');
  input.value = '';
}

