// HOTNEWS -----------------------
var delay = 45;
var delay2 = 3000;
var count = -1;
var text_index = 0;
var href = '';
var my_timeout;

function init_hotnews(){
  if(messages.length != null || messages.length != 0) {
    my_timeout = setTimeout("scroll_hotnews();", delay);
	}
}

function scroll_hotnews(){
  count = (count + 1) % (text.length + 1);
  var html = text.substr(0, count);
  if(elem = document.getElementById('hotnews')) {
    if (href != '') {
      if (count == text.length) {
        elem.innerHTML = "<a href='"+href+"'>"+html+"&nbsp;&ndash;&nbsp;<span class='vice'>více</span></a>";
      }
      else {
        elem.innerHTML = "<a href='"+href+"'>"+html+"</a>";
      }
    }
    else {elem.innerHTML = html;}
  }

  if(count == text.length) {
  	my_timeout = setTimeout("scroll_hotnews();", delay2);
    text_index = (text_index + 1) % messages.length;
    text = messages[text_index];
    if (hrefs[text_index] != null) {href = hrefs[text_index];} else {href = '';}
    count = 0;
  } 
  else {
  	my_timeout = setTimeout("scroll_hotnews();", delay);
  }
}

// HODINY -----------------------
function hodiny() {
   var timeTimeout=window.setTimeout( "hodiny()", 1000 );
   t = new Date();
   sec = t.getSeconds();
   min = t.getMinutes();
   if (sec<10) sec = "0"+sec;if (min<10) min = "0"+min;
   time=t.getHours()+':'+min+':'+sec;
   if(document.getElementById){
      document.getElementById('timer').innerHTML = time;
   }
}

// ZMENA OBRAZKU -----------------
var img = new Array();
var cimg = 1;
function chimgs() {
  var imgTimeout=window.setTimeout( "chimgs()", 10000 );
  if (cimg == fotky.length) {cimg = 0};
   if(document.getElementById('hlimg')) {
      document.getElementById('hlimg').src = fotky[cimg];
   } 
  cimg = (cimg + 1);
}
function loadImages() {
  if (fotky!=null) {
    if (fotky.length>1) {
      for (i=1;i<fotky.length;i++) { // nulovou fotku vynecháme, je už nahraná kódem
        img[i] = new Image(201,150);
        img[i].src = fotky[i];
      }
      var imgTimeout=window.setTimeout( "chimgs()", 10000 );
    }
  }
}
