// functie om Events te laden
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

// ################################################################################
// link op td plaatsen
// ################################################################################

var status = false;

function addToURL() {
	// controle of deze functie wel uitgevoerd kan worden
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById("wrap")) return false;

	// de layer waar het menu in staat (onderdeel van mode_swmenufree)
	var menu = document.getElementById("wrap");	
	// mouseover op td omdat op a al een mouseover wordt toegevoegd
	var tds = menu.getElementsByTagName("td");

	// de javascript functie toevoegen
	for (var i=0; i < tds.length; i++) {
		tds[i].onmouseover = function() {
			status = true;
			// de link (a) in de td opzoeken
			var links = this.getElementsByTagName("a");
			var currentLink = links[0];

			openURL.delay(1500, currentLink)

		}
		tds[i].onmouseout = function() {
			status = false;
		}	
	}
}

function openURL() {
	if (status) {	
		// de home pagina heeft een andere url dan / of /index.php
		if (this.innerHTML == "Home" && (self.location == "default.htm" || self.location == "index.php")) {
			return false;
		}
		if (this.href != self.location) {
			self.location = this.href;
		}
	}
}

// ################################################################################
// onLoad
// ################################################################################

// laad de volgende functies:
addLoadEvent(addToURL);
