function $(id) {
  return document.getElementById(id);
}

function kopirovat() {
  document.execCommand("Copy");
}

function bookmarksite(title,url) {
  if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
  else if(window.opera && window.print) { // opera
	var elem = document.createElement("a");
	elem.setAttribute("href",url);
	elem.setAttribute("title",title);
	elem.setAttribute("rel","sidebar");
	elem.click();
  } else if(document.all) // ie
	window.external.AddFavorite(url, title);
}

function getAjax() {
  var ajaxDiv = $("loader");
  ajaxDiv.style.visibility = "visible";
  if (document.all) {
	ajaxDiv.innerHTML = '<img src="grafika/ajax-loader.gif" alt="ajax loading">';
  }
}

function setFocus() {
  var txt = $("url");
  if(txt!=null) {
     var val = txt.value;
     txt.value = "";
     if(document.all) {
        txt.focus();
     }
     txt.value = val;
     txt.focus();
  }
}

function nactiSoubor(soubor) {
  if($("hpclanky")) {
    var d = new Date();
    var tm = "" + d.getFullYear() + d.getMonth() + d.getDate() + d.getHours();
    var vypis = getFile(soubor + ".hp.inc?" + tm);
    $("hpclankyobsah").innerHTML = vypis;
  }
}

function getFile(url) {
  AJAX = (window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));
  if (AJAX) {
     AJAX.open("GET", url, false);
     //AJAX.setRequestHeader("Content-type", "text/html; charset=windows-1250");
     AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=windows-1250");
     AJAX.setRequestHeader("Cache-Control", "no-store");
     AJAX.setRequestHeader("Cache-Control", "no-cache");
     AJAX.setRequestHeader("Cache-Control", "must-revalidate");
     AJAX.setRequestHeader("Pragma", "no-cache");
     AJAX.send(null);
     return AJAX.responseText;
  } else {
     return false;
  }                                             
}

function getClanky() {
  $('hpclankyobsah').innerHTML = '<em class="loader">Načítání...</em>';
  nactiSoubor("clanky");
  $('aclanky').setAttribute("class","active");
  $('awebtrh').setAttribute("class","");
}
function getWebtrh() {
  $('hpclankyobsah').innerHTML = '<em class="loader">Načítání...</em>';
  nactiSoubor("webtrh");
  $('aclanky').setAttribute("class","");
  $('awebtrh').setAttribute("class","active");
}

window.onload = function() {
   // anti autohits/autosurf & iframes
   if (top.location != self.location) {
      top.location = self.location.href;
   }
   //if($("jsenable")) {
   //   $("jsenable").value = "1";
   //}
   if($('bubbles')) {
     $('aclanky').setAttribute("href","javascript:void(0)");
     $('awebtrh').setAttribute("href","javascript:void(0)");
     $('aclanky').onclick = getClanky;
     $('awebtrh').onclick = getWebtrh;
   }
   setFocus();
   //řč
}