// JavaScript Document

function Init_main(){
  document.getElementById("menu_down").style.top = 140;

}

function Posun_start(co, kam){
  margin = margin + kam;
  
  lmax = document.body.clientWidth-460-857;
  
  if(kam == Math.abs(kam)){
    if(margin >= 20) margin = 20;
    document.getElementById(co).style.marginLeft = margin+"px";
    
  }
  else{
    if(margin <= lmax) margin = lmax;
      document.getElementById(co).style.marginLeft = margin+"px";
    
  }
  timeout = setTimeout("Posun_start('"+co+"',"+kam+");", 100);
}

function Posun_stop(){
  clearTimeout(timeout);
}


function Vertical_posun(co1,co2, kam, max){
  vmargin = vmargin + kam;
  
  lmax = document.body.clientHeight+ max -128 -75;
  
  if(kam == Math.abs(kam)){
    if(vmargin >= max) vmargin = max;
    document.getElementById(co1).style.marginTop = vmargin+"px";
    document.getElementById(co2).style.marginTop = vmargin+"px";
    
  }
  else{
    if(vmargin <= lmax) vmargin = lmax;
      document.getElementById(co1).style.marginTop = vmargin+"px";
      document.getElementById(co2).style.marginTop = vmargin+"px";
    
  }
  timeout = setTimeout("Vertical_posun('"+co1+"','"+co2+"',"+kam+","+max+");", 100);
}
function getMaxWidth(){
  value = screen.availWidth-20;
  return value;
}

function getMaxHeight(){
  value = screen.availHeight-100;
  return value;
}

function OtevriOkno(x,y,cesta){
   
  if((getMaxWidth()>=x) && (getMaxHeight() >=y))  window.open(cesta, "_blank","'scrollbars=no, menubar, width="+x+",height="+eval(y+70)+"'");
  else{ 
    if((getMaxWidth() < x) && (getMaxHeight() >= y)) window.open(cesta, "_blank","'scrollbars=no, menubar, width="+screen.availWidth+",height="+eval(y+70)+"'"); 
    else {
      if((getMaxWidth()>=x) && (getMaxHeight() < y)) window.open(cesta, "_blank","'scrollbars=no, menubar, width="+x+",height="+screen.availHeight+"'");
      else {
        if(eval(x/getMaxWidth()) > eval(y/getMaxHeight())){
        
         window.open(cesta, "_blank","'scrollbars=no, menubar, width="+screen.availWidth+",height="+eval(getMaxWidth()*y/x)+"'");
         }
        else {
          
          window.open(cesta, "_blank","'scrollbars=no, menubar, width="+eval(getMaxHeight()*x/y)+",height="+eval(screen.availHeight-50)+"'");
        }
     }
   }
  } 
  //else document.images["obrazek"].height = getMaxHeight();
  


}
function Rotuj(pozice,rychlost){
  pozice = pozice - rychlost;
  
  if(pozice != Math.abs(pozice)){
    pozice = document.body.clientWidth;
  }

  document.getElementById("info_text").style.left = pozice+"px";
  
  timeout2 = setTimeout("Rotuj('"+pozice+"',"+rychlost+");", 100);
}

