var initialized = false;
var oldClass = "";
var lastClickedRow = "";

function init() {

  nav = $('lst-main-nav');

  items = nav.getElementsByTagName('li');
  for (j=0;j<items.length;j++) {
    if (items[j].id != "") {
      navItems = items[j].getElementsByTagName('a');
      for (i=0; i<navItems.length; i++) {
        if (navItems[i].id != "") {

        addEvent("main", navItems[i]);
        addEvent("sub",  navItems[i]);

        }
      }
    }
  }
}

function addEvent(type, id) {
  switch(type) {
    case "main":
      id.onmouseover = function() {
        $('sub-nav-'+this.id).style.display = "block";
				this.focus();
        this.className = 'lnk-main-active';
        // Form Elemente deaktivieren
				if (isIE6() == true || isFF() == true) {
          $('fld-search').style.visibility   = "hidden";
				}
      }
      id.onmouseout = function() {
        $('sub-nav-'+this.id).style.display = "none";
        this.className = '';
        // Form Elemente aktivieren
				if (isIE6() == true || isFF() == true) {
          $('fld-search').style.visibility   = "visible";
				}
      }
    break;

    case "sub":
      $('sub-nav-'+id.id).onmouseover = function() {
        $(this.id).style.display = "block";
        // Effect.Appear(this.id, {duration: 0.3});
        $(id.id).className = 'lnk-main-active';
        clearTimeout();
        // Form Elemente deaktivieren
				if (isIE6() == true || isFF() == true) {
	        $('fld-search').style.visibility   = "hidden";
				}
      }
      $('sub-nav-'+id.id).onmouseout = function() {
        // Effect.Fade(this.id, {duration: 0.3});
        //setTimeout("hide(this.id)", 500);
        hide(this.id);
        $(id.id).className = '';
        // Form Elemente aktivieren
 				if (isIE6() == true || isFF() == true) {
	        $('fld-search').style.visibility   = "visible";
				}
      }
    break;
  }
}

function isIE6() {
	if (window.XMLHttpRequest == undefined) {
		return true;
	}
	// return false;
}

function isFF() {
	if (document.selection) {
		return false;
	}
	return true;
}

function hide(id){
  $(id).style.display = "none";
}


function initHover(element) {

  if (!initialized) {
    tr = document.getElementsByTagName('tr');
    td = document.getElementsByTagName('td');

    initialized = true;
	
    for (i = 0; i < tr.length; i++) {

      input = tr[i].getElementsByTagName('input');

      tr[i].input = input[0];
      tr[i].mouseblocked = false;
	  tr[i].initialClass = tr[i].className;

      tr[i].onmouseover = function() {
		if (this.className == "") {
			oldClass = this.initialClass;
		} else {
			oldClass = this.className;
		}
        this.className = "col-hover";
      }

      tr[i].onmouseout = function() {
        if (!this.mouseblocked) {
          this.className = oldClass;
        }
      }

      tr[i].onmouseup = function() {
        this.className = "col-hover";
        this.input.checked = "checked";
        this.mouseblocked = true;
		
		for (x = 0; x < td.length; x++) {
			td[x].id = "";
		}
		
        if (lastClickedRow != "") {
			lastClickedRow.className = lastClickedRow.initialClass;
			lastClickedRow.mouseblocked = false;
		}

        lastClickedRow = this;

      }
    }
  }
}


