function CreateBookmarkLink(title,url){
  if (window.sidebar) {
    //mozilla, firefox, ...
    window.sidebar.addPanel(title, url,"");
  }
  else if (window.opera && window.print) {
    //opera
    var mbm = document.createElement('a');
    mbm.setAttribute('rel','sidebar');
    mbm.setAttribute('href',url);
    mbm.setAttribute('title',title);
    mbm.click();
  }
  else if (document.all) {
    //msie
    window.external.AddFavorite(url, title);
  }
}

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)+",width="+(winWidth)+",resizable=yes,scrollbars=no,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='css/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 check_search(fld) {
  if (fld.value.length<2) {
    alert('Zadejte alespoň 2 znaky.')
    fld.focus();
    return false;
    };
  }


function zkontroluj_nasobnost(idzbozi,hodnota) {
  pocet = document.getElementById(idzbozi).value;
  //alert(pocet + ' : JUP');
  if(hodnota > 1) {
    if(pocet % hodnota == 0) {
      return true;
    } else {
      var dve = hodnota * 2;
      var tri = hodnota * 3;
      alert('Musíte vloľit násobnost ' + hodnota + '. Např. ' + dve + ', ' + tri + ', ...');
      return false;
    }
  }
  return true;
}

