// JavaScript Document

function itemShow(itemid) {
  var item = document.getElementById(itemid);
  if (item) {
    item.style.display = "block";
  }
}

function itemHide(itemid) {
  var item = document.getElementById(itemid);
  if (item) {
    item.style.display = "none";
  }
}

function itemFlip(itemid) {
  var item = document.getElementById(itemid);
  if (item)
  {
    if (item.style.display == "none") {
      item.style.display = "block";
    } else {
      item.style.display = "none";
    }
  }
}

function saveBanner() {
	var timestampActual = new Date();
	var timestampNew = new Date(timestampActual.getTime()+1*(24*60*60*1000)); // 1 den
  document.cookie = "homebanner=1;expires="+timestampNew.toGMTString()+";";
}

/* ---  --- */

var fotoWin = new Object;
fotoWin.foto = new Image();
fotoWin.foto.onload = zobrazFotografii;

function otevriFotografii(fotografie,width,height) {
  fotoWin.width = width;
  fotoWin.height = height;
  fotoWin.foto.src = fotografie;
}

function zavriFotografii() {
  fotoWin.win.close();
}

function zobrazFotografii() {
  if (fotoWin.win && !fotoWin.win.closed) {
    fotoWin.win.close();
  }
  fotoWin.win = window.open(fotoWin.foto.src,"fotografie","width="+(fotoWin.width+40)+",height="+(fotoWin.height+30)+",location=0,status=0,scrollbars=0");
	fotoWin.win.focus();
	fotoWin.win.onclick = zavriFotografii;
	fotoWin.win.document.onclick = zavriFotografii;
}

/* --- functions for home small banner --- */

var homeSmallImg =  new Object;
homeSmallImg.timer = null;
homeSmallImg.actual = 0;
homeSmallImg.speed = 4000;
homeSmallImg.dir = 'images_home/';

function homeSmallFlippingStart() {
  homeSmallImg.timer = setInterval("homeSmallFlipping()",homeSmallImg.speed);
}

function homeSmallFlipping() {
  var elemHomeImg = document.getElementById('elemhomeimg');
  if (!elemHomeImg || !arrRandomPictures || arrRandomPictures.length<1) return false;
  if (arrRandomPictures[homeSmallImg.actual+1]) {
    homeSmallImg.actual++;
  } else {
    homeSmallImg.actual = 0;
  }
  if (elemHomeImg.filters && elemHomeImg.filters[0]) {
    elemHomeImg.filters[0].Apply();
  }
  elemHomeImg.src = REL_LINK+homeSmallImg.dir+arrRandomPictures[homeSmallImg.actual][0];
  if (elemHomeImg.filters && elemHomeImg.filters[0]) {
    elemHomeImg.filters[0].Play();
  }
}

