function loadMenu(){
    if (window.location.href != "http://www.reisprofiel.nl/reisgids/" && window.location.href != "http://www.reisprofiel.nl/reisgids" && window.location.href != "http://reisprofiel.nl/reisgids/" && window.location.href != "http://reisprofiel.nl/reisgids") {
        loadXMLDocMenu('http://www.reisprofiel.nl/landeninformatie/landenmenu.php');
	}
}

var req;
function loadXMLDocMenu(url){
    // branch for native XMLHttpRequest object (Dus voor FireFox, Safari + IE7)
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChangeMenu;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version (IE < 7)
    }else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChangeMenu;
            req.open("GET", url, true);
            req.send();
        }
    }
}


function processReqChangeMenu(){
    // alleen als req shows "complete"
    if (req.readyState == 4) {
        // alleen als "OK"
        if (req.status == 200) {
            if ((document.getElementById('menuTD') != undefined)) {
                document.getElementById('menuTD').innerHTML = req.responseText;
            }
        }else{
            if ((document.getElementById('menuTD') != undefined)) {
                document.getElementById('menuTD').innerHTML = "Kon niet de data ophalen";
            }
        }
    }
}

if ((document.all) && (document.getElementById)) {
    function MenuListElementHoverFix() {
		var _this	= this;
		
		if (typeof(Array.prototype.push) == 'undefined') {
			function push() {
				var j = this.length;
				for (var i = 0; i < push.arguments.length; ++i) {
					this[j] = push.arguments[i];
					j++;
				}
			}
			function pop() {
				var i = this[this.length - 1];
				this.length--;
				return i;
			}
			Array.prototype.push	= push;
			Array.prototype.pop		= pop;
		}
		
		this.className				= 'sfhover';
		this.classNameSuffix		= ' ' + this.className;
		this.removeClassNameRegExp	= new RegExp("\\b ?" + this.className + "\\b");
		this.hoverElementStack		= new Array();
		
		this.onmouseover	= function() {
			if (!_this.isHover(this)) {
				if (this.getAttribute('is_hover_class_removing') != 'true') {
					this.className	+= _this.classNameSuffix;
				}
				this.setAttribute('is_hover', 'true');
			}
		}
		this.isHover	= function(element) {
			return (element.getAttribute('is_hover') == 'true');
		}
		this.checkNonHoverState	= function(element) {
			if (!_this.isHover(element)) {
				element.className	= element.className.replace(_this.removeClassNameRegExp, '');
			}
			element.removeAttribute('is_hover_class_removing');
		}
		this.checkLastNonHoverState	= function() {
			var hoverElement	= null;
			if (_this.hoverElementStack.length > 0) {
				hoverElement	= _this.hoverElementStack.pop();
			}
			for (var i = _this.hoverElementStack.length - 1; i >= 0; i--) {
				var o = _this.hoverElementStack[i];
				while (o != null) {
					o	= o.offsetParent;
					if (o == hoverElement) {
						_this.checkNonHoverState(_this.hoverElementStack[i]);
						break;
					}
				}
			}
			if (hoverElement != null) {
				_this.checkNonHoverState(hoverElement);
			}
		}
		this.onmouseout		= function() {
			this.setAttribute('is_hover', 'false');
			if (this.getAttribute('is_hover_class_removing') != 'true') {
				this.setAttribute('is_hover_class_removing', 'true');
				_this.hoverElementStack.push(this);
				window.setTimeout(_this.checkLastNonHoverState, 10);
			}
		}
		this.fixElement		= function(elementRoot) {
			for (var i=0; i < elementRoot.childNodes.length; i++) {
				var node = elementRoot.childNodes[i];
				if (node.nodeName == "LI") {
					node.onmouseover	= this.onmouseover;
					node.onmouseout		= this.onmouseout;
				}
				this.fixElement(node);
			}
		};
		this.findElement	= function(elementRoot) {
			for (var i=0; i< elementRoot.childNodes.length; i++) {
				var node = elementRoot.childNodes[i];
				if (node.nodeName == "UL") {
					if ((node.id != '') && ((node.id.indexOf("menu") >= 0) || (node.id.indexOf("nav") >= 0))) {
						this.fixElement(node);
						continue;
					}
				}
				this.findElement(node);
			}
		};
		this.fix			= function() {
			var node = document.body;
			if (node) {
				window.setTimeout(function() {
                    _this.findElement(node);
                }, 300);
			}
		}
		this.addOnLoad		= function() {
			if (window.attachEvent) {
				window.attachEvent("onload", this.fix);
			}
		}
	}
    (new MenuListElementHoverFix()).addOnLoad();
}

