Event.observe(document, 'dom:loaded', function () {
	//Add browser specific tags to body
	for (var b in Prototype.Browser) if (Prototype.Browser[b]) $(document.body).addClassName(b);
	if (window.navigator.appName == "Microsoft Internet Explorer") {
	   if (document.documentMode) $(document.body).addClassName('IE'+document.documentMode);
	   else if (document.compatMode == "CSS1Compat") $(document.body).addClassName('IE7');
	}
	
	$('top_menu').observe('mouseover', function (event) {
		var el = event.element();
		
		if (el.match('.nav') || el.match('.nav *')) {
			if (el.tagName!='SPAN') el = el.up('.nav');
			
			this.select('.popnav').invoke('hide');
			if (el.getAttribute('menu')) $(el.getAttribute('menu')).show();
			
			event.stop();return;
		}
		
	}).observe('mouseleave', function () {
		$$('#top_menu .popnav').invoke('hide');
	});
	
	
	
	//add saved textsize class if is set, otherwise default to small
	//setup textsize switcher events
	$('sizeselect').observe('click', function (event) {
		var el = event.element();
		
		if (el.match('a')) {
			document.body.className = document.body.className.replace(/(^|\s+)textsize-[\w]+(\s+|$)/,' ').strip();
			document.body.addClassName('textsize-'+el.className);

			Cookie.setData('textsize', el.className);

			event.stop();return false;
		}
	});
		
});
