window.addEvents({
	'domready': function() {
		initSubMenuClass();
		findExternalLinks();
	},
	'load': function() {
		
	}
});

/**
 * menu linkitems with class index
 * 
 * @author phison.do, <phison.do@efocus.nl>
 * @version 1.0, 12 feb, 2010
 * @requires MooTools 1.2.4 Core, <http://www.mootools.net>
 * @return void
 */
function initSubMenuClass() {
	var elSubNav = $$('div.subnav')[0];
	if(elSubNav){
		var arrSubNavItems = elSubNav.getElements('li');
		var x = 1;
		arrSubNavItems.each(function(elSubNavItem, i){
			var elSubNavItemWidth = elSubNavItem.getWidth();		
			elSubNavItem.addClass('link'+(x++));
		});
	};
}

/**
 * Find all external links, and add class External
 * 
 * @author Mirjam Verloop, <mirjam.verloop@efocus.nl>
 * @version 1.0, 12 feb, 2010
 * @requires MooTools 1.2.4 Core, <http://www.mootools.net>
 * @requires <a href="http://www.efocus.nl/" class="external">eFocus</a>
 * @return void
 */
function findExternalLinks () {
	var allExternalLinks = $$('a[href^="http://"]');
	var thisDomain = window.location.host;
	allExternalLinks.each(function(thisLink) {
		if (!thisLink.get('href').contains(thisDomain)) {
			thisLink.addClass('external');
		}
	});
	initExternalLinks();	
}

/**
 * Opens external links valid in a new window without the target attribute.
 * 
 * @author Mirjam Verloop, <mirjam.verloop@efocus.nl>
 * @version 1.0, 12 feb, 2010
 * @requires MooTools 1.2.4 Core, <http://www.mootools.net>
 * @requires <a href="http://www.efocus.nl/" class="external">eFocus</a>
 * @return void
 */
function initExternalLinks() {
	var arrExternalLinks = $$('a.external');
	if (arrExternalLinks.length > 0) {
		arrExternalLinks.each(function(elExternalLink) {
			elExternalLink.addEvent('click', function(event) {
				event.stop();
				window.open(this.get('href'));
			});
		});	
	}
}


