// JavaScript Document
  var left=0;
  var inprogres=false;

  function winH(Sender) {
    /* NN4 a kompatibilní prohlížeče */
    if (Sender.innerHeight)
      return Sender.innerHeight;
    /* MSIE6 v std. režimu - Opera a Mozilla již uspěly s window.innerHeight */
    else if(Sender.document.documentElement && Sender.document.documentElement.clientHeight)
      return Sender.document.documentElement.clientHeight;
    /* starší MSIE + MSIE6 v quirk režimu */
    else if(Sender.document.body && Sender.document.body.clientHeight)
      return Sender.document.body.clientHeight;
    else
      return null;
  }
  function ResizeMyWin()
  {
    hb = document.getElementById("bkgnd").offsetHeight - 180;
    if(hb < 200)
      hb = 200;
    document.getElementById("bkgnd_m2").style.height = hb+"px";
    document.getElementById("imgsection").style.height = (hb-40)+"px";
    document.getElementById("exifsection").style.height = (hb-40)+"px";
    document.getElementById("bkgnd_b").style.top = 120+hb+"px";
  }

  function Right(id){
    var i = document.getElementById("inner_"+id);
    var o = document.getElementById("outer_"+id);
    //alert("Stisknuto -> Right");
    if( i.offsetLeft < 0)
      pom = i.offsetLeft*(-1);
    else{
      pom = i.offsetLeft;
    }
    oi = i.offsetWidth;
    oo = pom+o.offsetWidth;
    if(run>0 && oo <= oi){
      var pos = i.offsetLeft-20;
//      alert("oi->"+oi+"\noo->"+oo+"\npos->"+pos);
      i.style.left = pos+"px";
      left = pos;
      setTimeout('Right('+id+')',80);
    }
  }

  function Left(id){
    var i = document.getElementById("inner_"+id);
    pom = i.offsetLeft;
    //alert("Stisknuto -> Left");
    if(run && pom < 0){
      pos = i.offsetLeft + 20;
      i.style.left = pos+"px";
      left = pos;
      setTimeout('Left('+id+')',80);
    }
  }

  function MoveMenu(dir,id){
    run = dir;
    if(dir == 1)
      Left(id);
    if(dir == 2)
      Right(id);
  }

  function DisplayArrow(id){
    var o = document.getElementById("outer_"+id);                 //sirka vnejsiho
    var i = document.getElementById("inner_"+id);                 //sirka vnitrniho
    if(i.offsetLeft >= 0)
      document.getElementById("left_"+id).style.visibility = "hidden";
    else
      document.getElementById("left_"+id).style.visibility = "visible";
    l=GetLeft(id);
    wi = i.scrollWidth;
    wo = o.offsetWidth;
    pom = l + wi;
    if(pom <= wo)
      document.getElementById("right_"+id).style.visibility = "hidden";
    else
      document.getElementById("right_"+id).style.visibility = "visible";
  }

  function DisplaySection(){
    var s = document.getElementById("imgsection");
    if(s)
      s.style.display = "block";
  }

  function GetLeft(id){
    left=document.getElementById("inner_"+id).offsetLeft;
    return left;
  }

  function ShowExifData(){
    if(document.getElementById("imgsection").style.display == "block"){
      document.getElementById("imgsection").style.display = "none";
      document.getElementById("exifsection").style.display = "block";
    }else{
      document.getElementById("imgsection").style.display = "block";
      document.getElementById("exifsection").style.display = "none";
    }
  }

  function MaxLengthCount(txarea,lmax,atxt){
    if (!inprogres){
      inprogres = true;
      var txtlen = txarea.value.length;
      var barlen = parseInt(txtlen/lmax * 100);
      if (txtlen > lmax){
        alert(atxt);
        txarea.value = txarea.value.substring(0,lmax);
      }
      if (txtlen >= lmax){
        document.getElementById("commentbar").style.backgroundColor = "red";
      }else{
        document.getElementById("commentbar").style.backgroundColor = "green";
      }
      document.getElementById("commentbar").style.width = barlen+"%";
//      document.getElementById("commentbar").style.width = parseInt((parseInt(txarea.offsetWidth)*barlen)/100)+"px";
      document.getElementById("cbartxt").innerHTML = txtlen+"/"+lmax;
      inprogres = false;
    }
  }