function addOverHandlers(root) {
if (!root) return;
for (var i = 0; i < root.childNodes.length; i++) {
var node = root.childNodes[i];
if(node.className=="submenu"){
node.onmouseover = function() {
this.className += "over";
}
node.onmouseout = function() {
this.className = this.className.replace("over", "");
}}
}
}
window.onload = function() {
addOverHandlers(document.getElementById("menu"));
external();
}


function writeFlashX(path,width,height){
document.write('<object type="application/x-shockwave-flash"  data="'+path+'" height="'+height+'" width="'+width+'" >'+
              '<param name="autoStart" value="-1" />'+
              '<param name="movie" value="'+path+'" />' +
              '<param name="play" value="true" />' +
              '<param name="loop" value="true" />' +
              '<param name="quality" value="high" />' +
              '<param name="scale" value="noborder" />' +
              '<param name="devicefont" value="true" />' +
              '<param name="bgcolor" value="black" />' +
              '<param name="wmode" value="transparent">' +
              '</object>');}
              
function writeFlash(path){
document.write('<object type="application/x-shockwave-flash"  data="'+path+'" height="161" width="782" >'+
              '<param name="autoStart" value="-1" />'+
              '<param name="movie" value="'+path+'" />' +
              '<param name="play" value="true" />' +
              '<param name="loop" value="true" />' +
              '<param name="quality" value="high" />' +
              '<param name="scale" value="noborder" />' +
              '<param name="devicefont" value="true" />' +
              '<param name="bgcolor" value="#FFFFFF" />' +
              '</object>');}

function selectTerm(txt){
document.getElementById('terminy').innerHTML="<select onchange=\"selectObsadenost(this.value)\" name=\"terminy\">"+txt+"</select>";
selectObsadenost("-")

}
wokno=null;

function show_popup(href,name,width,height){
 
  var int_windowLeft = (screen.width - width) / 2;
  var int_windowTop = (screen.height - height) / 2;
  
try{
      wokno.close();
}catch(e){}
      
wokno=null;

//wokno=window.open("http://agrio.sk/showFoto.php?href=" + href + "", "Agrio - archív","resizable=no;scrollbars=yes;titlebar=no;status=no;toolbar=no,menubar=no,height="+height+",width="+width+",top="+int_windowTop+",left="+int_windowLeft+"");
wokno=window.open( '/showFoto.php?href='+href, 'obrazok', 'top='+int_windowTop+', left='+int_windowLeft+', width='+width+',height='+height+',resizable=yes,scrollbars=1')
}

function selectObsadenost(txt){
txt=txt.replace(/bold/, "<b>");
txt=txt.replace(/boldend/, "</b>");
//txt.replace(/%/b%/, "</b>");
pole=txt.split(":");
if(pole[0]&&pole[0]!="-"){
document.getElementById('obsadenost').innerHTML=pole[2];
//document.getElementById('id').value=pole[0];
//document.getElementById('idterminu').value=pole[1];
}else{
document.getElementById('obsadenost').innerHTML="-";
//document.getElementById('id').value="";
//document.getElementById('idterminu').value="";
}
}

function submitForm(){
document.getElementById('limit').value=0;
document.getElementById('kategorie').submit();
}

function external() {
 if (document.getElementsByTagName) {
  var i, a;
  a = document.getElementsByTagName('a');
  for (i in a) {
  if (a[i].rel == 'external') a[i].target = '_blank';
  }
 }
}

function setLimit(limit){
document.getElementById('limit').value=limit;
document.getElementById('kategorie').submit();
}
