/**
 * WSHover.js - Inspired by SuckerFish
 * 
 * @author  Webstores <info at webstores dot nl>
 *           Copyright (c) Webstores internet totaalbureau <http://www.webstores.nl/>
 */

var WSHover = function() {
	var menuItems,
		activeItem,
		timeout;
	
	return {
		initialize: function() {
			var menuItems = document.getElementById("navigation").getElementsByTagName("li");
			for(var i = 0; i < menuItems.length; i++) {
				this.initEvents(menuItems[i]);
			}
		},
		initEvents: function(item) {
			var self = this;
			WS.Event.addEvent(item, 'mouseover', function() {
				if(timeout) {
					clearTimeout(timeout);
				}
				self.activate(this);
			});
			WS.Event.addEvent(item, 'mouseout', function() {
				if(this.getElementsByTagName('ul').length) {
					timeout = setTimeout(function() {
						self.deactivate(item);
					}, 1000);
				}
				else {
					self.deactivate(this);
				}
			});
		},
		activate: function(item) {
			if(activeItem) {
				this.deactivate(activeItem);
			}
			WS.addClass(item, 'wshover');
			activeItem = item;
		},
		deactivate: function(item) {
			WS.removeClass(item, 'wshover');
		}
	}
}();

WS.Event.addEvent(window, 'load', function() {
	//WSHover.initialize();
});

