
function initNav()
{
  if(!document.getElementById) return;
  var o = document.getElementById('mainNav');
  if(!o || o == null) return;
  var css_fake = (document.all && navigator.userAgent.toLowerCase().indexOf('msie') != -1) ? true : false;
  o = o.getElementsByTagName('UL');
  for (var i = 0; i < o.length; i++) {
    var oLI = o[i].parentNode;
    if(oLI.offsetLeft + o[i].offsetWidth > 780) {
      if (css_fake) {
        oLI.onmouseover = function() { cssFakeHoverOver(this); cssOpenRaOver(this); }
        oLI.onmouseout=function() { cssFakeHoverOut(this); cssOpenRaOut(this); }
      }
      else {
        oLI.onmouseover = function() { cssOpenRaOver(this); }
        oLI.onmouseout = function() { cssOpenRaOut(this); }
      }
      var oUL = oLI.getElementsByTagName('UL')[0];
      oUL.style.visibility = 'hidden';
      oUL.style.left = (oLI.offsetLeft-(oUL.offsetWidth-oLI.offsetWidth)) + 'px';
      oUL.style.left = '-999em';
      oUL.style.visibility = 'visible';
    } else {
      if (css_fake) {
        oLI.onmouseover = function() { cssFakeHoverOver(this); }
        oLI.onmouseout=function() { cssFakeHoverOut(this); }
      }
    }
  }
}

function cssFakeHoverOver(po)
{
  po.className += ' cssFakeHover';
}

function cssFakeHoverOut(po)
{
  po.className = po.className.replace(new RegExp(" cssFakeHover\\b"), '');
}

var MO = null;
var MOT = null;

function cssOpenRaOver(po)
{
  var oUL = po.getElementsByTagName('UL')[0];
  if (oUL == MO) window.clearTimeout(MOT);
  if (po.offsetLeft + oUL.offsetWidth > 780) {
    oUL.style.left = (po.offsetLeft-(oUL.offsetWidth-po.offsetWidth)) + 'px';
  }
}

function cssOpenRaOut(po)
{
  MO = po.getElementsByTagName('UL')[0];
  MOT = window.setTimeout("MO.style.left = '-999em'", 1); // prevent MOZ from flickering
}

function bSubmitOptionVal(po)
{
  o = po.options[po.selectedIndex].value;
  if(o.length==0){
    return false;
  }
  po.form.action = o;
  po.form.submit();
  return true;
}

/*
function bSubmitSearch()
{
  f = document.getElementById('freetext_search');
  if(!f || SearchURL.length==0){
    return false;
  }
  f.action = SearchURL;
  f.submit();
  return true;
}
*/


function popup(url, w, h)
{
	win = window.open(url, 'Hauptfenster', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=1,resizable=yes,copyhistory=no,width='+w+',height='+h);
}
