function ShowImg(jmeno, sirka, vyska, popis) {
  wokno=window.open("", "_blank", "resizeable=yes,toolbar=no,status=no,menubar=no,scrollbars=no,directories=no,location=no,resize=yes,width="+sirka+",height="+vyska);
  wokno.document.write("<html><head><title>"+popis+"</title></head><body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">");
  wokno.document.write("<img src=\""+jmeno+"\" width="+sirka+" height="+vyska+" border=0 alt=\""+popis+"\" onClick=\"window.close();\">");
  wokno.document.write("</body></html>");
}  

function ShowPageImg(jmeno, sirka, vyska, popis) {
  wokno=window.open("", "_blank", "resizeable=yes,toolbar=no,status=no,menubar=no,scrollbars=no,directories=no,location=no,resize=yes,width="+sirka+",height="+vyska);
  wokno.document.write("<html><head><title>"+popis+"</title></head><body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">");
  wokno.document.write("<img src=\""+jmeno+"\" width="+sirka+" height="+vyska+" border=0 alt=\""+popis+"\" onClick=\"window.close();\">");
  wokno.document.write("</body></html>");
}  

function ShowWnd(jmeno, sirka, vyska) {
  wokno=window.open(jmeno, "_blank", "resizeable=yes,toolbar=no,status=no,menubar=no,scrollbars=yes,directories=no,location=no,resize=no,width="+sirka+", height="+(vyska));
}

function isEmail(string) {
  if(string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
    return true;
  else return false;
}

function galleryZoomImage(thumb) {
  if(/MSIE ((5\.5)|[6])/.test(navigator.userAgent)) return true;
  //
  document.getElementById('bigimage').src=gallerypath+'im/'+galleryimages[thumb][0];
  document.getElementById('biglink').onclick=function() { return galleryShowOriginal(thumb); };
  return false;
}

var scrollTimer;

function galleryLog(text) {
  document.getElementById('log').value+=text+"\n";
}

function galleryInit() {
  if(/MSIE ((5\.5)|[6])/.test(navigator.userAgent)) return false;
  //
  gal=document.getElementById("gallery");
  if(gal) gal.className="gallery";
}

function galleryShowOriginal(image) {
  if(/MSIE ((5\.5)|[6])/.test(navigator.userAgent)) return true;
  //
  var cur=image+1;
  var max=galleryimages.length-1;
  var win=document.getElementById("gallerywindow");
  win.style.width=galleryimages[image][1]+22;
  document.getElementById("galleryoriginal").innerHTML="<img src=\""+gallerypath+galleryimages[image][0]+"\" width="+galleryimages[image][1]+" height="+galleryimages[image][2]+" alt=\"\" onClick=\"galleryCloseOriginal()\">";
  document.getElementById("gallerypos").innerHTML="Obrázek "+cur+" z "+max;
  var nav="";
  if(cur>1) nav="<a href=\"\" onClick=\"return galleryShowOriginal("+(cur-2)+")\">&lt; Předchozí</a>"; else nav="&lt; Předchozí";
  nav+=" &nbsp; ";
  if(cur<max) nav+="<a href=\"\" onClick=\"return galleryShowOriginal("+(cur)+")\">Další &gt;</a>"; else nav+="Další &gt;";
  document.getElementById("gallerynav").innerHTML=nav;
  document.getElementById("galleryback").className="";
  win.className="";
  win.style.marginLeft="-"+Math.round(win.scrollWidth/2)+"px";
  win.style.marginTop="-"+Math.round(win.scrollHeight/2)+"px";
  return false;
}

function galleryCloseOriginal() {
  document.getElementById("galleryback").className="hidden";
  document.getElementById("gallerywindow").className="hidden";
  document.getElementById("galleryoriginal").innerHTML="<p></p>";
  return false;
}

function galleryDoScroll(step) {
  //galleryLog("galleryDoScroll("+step+")");
  sc=document.getElementById("scroller");
  cont=true;
  if(sc) {
    tp=sc.offsetTop;
    if(tp+step>0) {
      tp=-step;
      cont=false;
    }
    //galleryLog("tp = "+tp+"; step = "+step); 
    //galleryLog("result = "+(tp+step)+"; height = "+sc.parentNode.clientHeight);
    if(tp+step<sc.parentNode.clientHeight-sc.clientHeight) {
      tp=sc.parentNode.clientHeight-sc.clientHeight-step;
      cont=false;
    }
    sc.style.marginTop=(tp+step)+"px";
  }
  if(cont) scrollTimer=setTimeout("galleryDoScroll("+step+")", 50);
}

function galleryStartScroll(step) {
  //galleryLog("galleryStartScroll("+step+")");
  scrollTimer=setTimeout("galleryDoScroll("+step+")", 50);
}

function galleryStopScroll() {
  //galleryLog("galleryStopScroll()");
  clearTimeout(scrollTimer);
}

function galleryShowVideo(name, width, height, pathfix) {
  if(/MSIE ((5\.5)|[6])/.test(navigator.userAgent)) return true;
  //
  var win=document.getElementById("gallerywindow");
  win.style.width=width+22;
  document.getElementById("galleryoriginal").innerHTML="<p id=\"flashcontent\" style=\"width: "+width+"px; height: "+height+"px\">Prostor pro video</p>";
  document.getElementById("gallerypos").innerHTML="Video";
  document.getElementById("gallerynav").innerHTML="";
  document.getElementById("galleryback").className="";
  win.className="";
  win.style.marginLeft="-"+Math.round(win.scrollWidth/2)+"px";
  win.style.marginTop="-"+Math.round(win.scrollHeight/2)+"px";
  //
  var s1 = new SWFObject(pathfix+'modules/system/lib/jwflvplayer/player.swf','player',width,height,'9');
  s1.addParam('allowfullscreen','true');
  s1.addParam('allowscriptaccess','always');
  s1.addParam('bgcolor','#888888');
  //
  flvfile='../../../../video/'+name+'.flv';
  jpgfile='../../../../video/'+name+'.jpg';
  if(name=='pocta-freddiemu-mercurymu') flvfile='http://www.omecsvatehovaclava.cz/media/ohnostroj03-2010.flv';
  //
  s1.addParam('flashvars','file='+flvfile+'&image='+jpgfile+'&fullscreen=true&bufferlength=5');
  s1.write('flashcontent');
  //
  return false;
}

function HideDialog() {
  var div = document.getElementById("propagation");
  div.className="front-panel-off";
}

function showOpeningTime() {
  $('#index-news-frame').fadeToggle('slow');
}
