function trCol(objekt, barva) {
  bunky = objekt.getElementsByTagName("TD");
  for (i = 0; i < bunky.length; i++) bunky[i].style.background = barva;
}

function runClock() {
 today=new Date();
 day=today.getDate();
 month=today.getMonth()+1;
 year=today.getFullYear();
 hours=today.getHours();
 minutes=today.getMinutes();
 seconds=today.getSeconds();
 timeValue=day+". "+month+". "+year+"  ";
 timeValue+=hours;
 timeValue+=((minutes<10) ? ":0" : ":")+minutes;
 timeValue+=((seconds<10) ? ":0" : ":")+seconds;
 if (document.getElementById("hodiny").innerHTML != timeValue) document.getElementById("hodiny").innerHTML=timeValue;
 setTimeout("runClock()",100);
 return timeValue;
}

pic=new Array();
jmena=new Array("domu","vystoupeni","nahravky","zpvazba","vzkazy","skupina","podklady","obrazky","kestazeni","odkazy");
poziceyh=new Array(159,196,226,257,289,323,353,387,419,452);
poziceyd=new Array(163,197,229,259,294,325,355,386,421,454);
for (a=0; a<10; a++) {
 pic[2*a]=new Image(); pic[2*a].src="obrazky/"+jmena[a]+"_h.png";
 pic[2*a+1]=new Image(); pic[2*a+1].src="obrazky/"+jmena[a]+"_d.png";
}
zpetp=new Image(); zpetp.src="obrazky/zpet_a.gif";

function winH() {
   if (window.innerHeight)
      return window.innerHeight;
   else if
   (document.documentElement &&
   document.documentElement.clientHeight)
      return document.documentElement.clientHeight;
   else if
   (document.body && document.body.clientHeight)
      return document.body.clientHeight;
   else
      return null;
}

function winW() {
   if (window.innerWidth)
      return window.innerWidth;
   else if
   (document.documentElement &&
   document.documentElement.clientWidth)
      return document.documentElement.clientWidth;
   else if
   (document.body && document.body.clientWidth)
      return document.body.clientWidth;
   else
      return null;
}

var absx, absy;

function vystredit() {
   document.getElementById("hlavni").style.position = "absolute";
   absx = (winW()-740)/2 > 0 ? Math.round((winW()-740)/2) : 0;
   document.getElementById("hlavni").style.left = absx + "px";
   absy = (winH()-555)/2 > 0 ? Math.round((winH()-555)/2) : 0;
   document.getElementById("hlavni").style.top = absy + "px";
   document.getElementById("hodiny").style.position = "absolute";
   document.getElementById("hodiny").style.left = (absx + 610) + "px";
   document.getElementById("hodiny").style.top = (absy + 18) + "px";
   document.getElementById("nv").style.position = "absolute";
   document.getElementById("nv").style.left = (absx + 20) + "px";
   document.getElementById("nv").style.top = (absy + 20) + "px";
   document.getElementById("anketa").style.position = "absolute";
   document.getElementById("vrteni").style.position = "absolute";
   document.getElementById("okno").style.left = (absx + 226) + "px";
   document.getElementById("okno").style.top = (absy + 187) + "px";
   document.getElementById("pata").style.left = (absx + 200) + "px";
   document.getElementById("pata").style.top = (absy + 518) + "px";
   document.getElementById("mapa").style.left = (absx + 30) + "px";
   document.getElementById("mapa").style.top = (absy + 180) + "px";
   return false;
}

var t = null;

function vrtse(stav, obr) {
  switch(stav) {
    case 0: {
              document.getElementById("vrteni").innerHTML = "<A href='?stranka=" + obr + "'><IMG src='obrazky/" + jmena[obr] + "_d.png' border='0' onmouseout='stuj()'></A>";
              document.getElementById("vrteni").style.left = (absx + 13) + "px";
              document.getElementById("vrteni").style.top = (absy + poziceyd[obr]) + "px";
              pom = obr;
              t = setTimeout("vrtse(1, pom)",150)
            }
            break
    case 1: {
              document.getElementById("vrteni").innerHTML = "";
              pom = obr;
              t = setTimeout("vrtse(2, pom)",150)
            }
            break
    case 2: {
              document.getElementById("vrteni").innerHTML = "<A href='?stranka=" + obr + "'><IMG src='obrazky/" + jmena[obr] + "_h.png' border='0' onmouseout='stuj()'></A>";
              document.getElementById("vrteni").style.left = (absx + 13) + "px";
              document.getElementById("vrteni").style.top = (absy + poziceyh[obr]) + "px";
              pom = obr;
              t = setTimeout("vrtse(3, pom)",150)
            }
            break
    case 3: {
              document.getElementById("vrteni").innerHTML = "";
              pom = obr;
              t = setTimeout("vrtse(0, pom)",150)
            }
            break
  }
  return false;
}

function stuj() {
  document.getElementById("vrteni").innerHTML = "";
  clearTimeout(t);
}

var ofsox = 0, ofsoy = 0, ot = null;

function ousko(ven) {
  document.getElementById("anketa").style.left = (absx + 660 + ofsox) + "px";
  document.getElementById("anketa").style.top = (absy + 50 + ofsoy) + "px";
  if (ven) {
    if (ofsox < 80) {
      ofsox += 1;
      ot = setTimeout("ousko(true)", 30);
    } else {
      ot = setTimeout("ousko(false)", 30);
    }
  } else {
    if (ofsox > 0) {
      ofsox -= 1;
      ot = setTimeout("ousko(false)", 30);
    } else {
      ot = setTimeout("ousko(true)", 30);
      ofsoy = Math.round(Math.random()*375);
    }
  }
  return true;
}

function kontrola() {
      if (document.prisp.jmeno.value == "") {
            alert("Položka se jménem musí být vyplněna.");
            document.prisp.jmeno.focus();
            return false;
      }
      else if (document.prisp.zprava.value == "") {
            alert("Zpráva musí obsahovat text.");
            document.prisp.zprava.focus();
            return false;
      }
      else return true;
}

function sprav() {
      if (document.objed.jmeno.value == "") {
            alert("Položka se jménem musí být vyplněna.");
            document.objed.jmeno.focus();
            return false;
      }
      else if (document.objed.email.value == "") {
            alert("Musíš zadat svůj e-mail. To abychom ti mohli potvrdit přijetí objednávky a odeslání.");
            document.objed.email.focus();
            return false;
      }
      else if (document.objed.ulice.value == "") {
            alert("Bez zadané adresy bychom ti to nemohli poslat.");
            document.objed.ulice.focus();
            return false;
      }
      else if (document.objed.mesto.value == "") {
            alert("Bez zadané adresy bychom ti to nemohli poslat.");
            document.objed.mesto.focus();
            return false;
      }
      else if (document.objed.psc.value == "") {
            alert("Pošta by se na nás zlobila, kdybychom to poslali bez PSČ.");
            document.objed.psc.focus();
            return false;
      }
      else if (!(document.objed.hrtky.checked) && !(document.objed.nhdol.checked) && !(document.objed.dzvsn.checked)) {
            alert("Přece nechceš dostat jen prázdný balíček...");
            document.objed.hrtky.focus();
            return false;
      }
      else return true;
}

function regkomp() {
      if (document.regis.jmeno.value == "") {
            alert("Položka se jménem musí být vyplněna, abychom věděli, komu pak cenu předat.");
            document.regis.jmeno.focus();
            return false;
      }
      else if (document.regis.email.value == "") {
            alert("Musíš zadat svůj e-mail. To abychom ti mohli dát vědět o chystaném koncertu, kde se bude předávat výhra.");
            document.regis.email.focus();
            return false;
      }
      else return true;
}

var slen = 999;

function countit()
{
   str = document.prisp.zprava.value;
   strlength = str.length;
   document.getElementById("kolik").innerHTML = slen - strlength;

   if (slen-strlength < 0) {
     document.getElementById("kolik").innerHTML = '0';
     document.prisp.zprava.value = document.prisp.zprava.value.substring(0, slen);
   }
}

function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin) {
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
// version 3.0.4

        if (bgcolor=="") {
                bgcolor="#FFFFFF";
        }
        var adj=10;
        var w = screen.width;
        var h = screen.height;
        var byFactor=1;

        if(w<740){
          var lift=0.90;
        }
        if(w>=740 & w<835){
          var lift=0.91;
        }
        if(w>=835){
          var lift=0.93;
        }
        if (imageWidth>w){
          byFactor = w / imageWidth;
          imageWidth = w;
          imageHeight = imageHeight * byFactor;
        }
        if (imageHeight>h-adj){
          byFactor = h / imageHeight;
          imageWidth = (imageWidth * byFactor);
          imageHeight = h;
        }

        var scrWidth = w-adj;
        var scrHeight = (h*lift)-adj;

        if (imageHeight>scrHeight){
            imageHeight=imageHeight*lift;
          imageWidth=imageWidth*lift;
        }

        var posLeft=0;
        var posTop=0;

        if (hugger == "hug image"){
          if (hugMargin == ""){
            hugMargin = 0;
          }
          var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
          if (scrHeightTemp < scrHeight) {
                scrHeight = scrHeightTemp;
          }
          var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
          if (scrWidthTemp < scrWidth) {
                scrWidth = scrWidthTemp;
          }

          if (scrHeight<100){scrHeight=100;}
          if (scrWidth<100){scrWidth=100;}

          posTop =  ((h-(scrHeight/lift)-adj)/2);
          posLeft = ((w-(scrWidth)-adj)/2);
         }

        if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
                imageHeight=imageHeight-adj;
                imageWidth=imageWidth-adj;
        }
        posTop = parseInt(posTop);
        posLeft = parseInt(posLeft);
        scrWidth = parseInt(scrWidth);
        scrHeight = parseInt(scrHeight);

        var agt=navigator.userAgent.toLowerCase();
        newWindow = window.open("vwd_justso.htm","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
        newWindow.document.open();
        newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onBlur="self.close()" onClick="self.close()">');
        newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+'><tr><td>');
        newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' alt="Kliknutím zavřete okno" />');
        newWindow.document.write('</td></tr></table></body></html>');
        newWindow.document.close();
        newWindow.focus();

}
