window.addEvent('domready',function(){
	// If there's .spacer
	if ($E('#body .spacer')) {
		$E('#body h2').addClass('short'); //Shorten H2s in content when there's third col
	// otherwise..
	} else if ($('body')) {
		$('body').addClass('short');
	}
	
	// If there's submenu, let's make some corrections:
	menu_uls = $$('#submenu ul');
	if (window.ie6 || window.ie7) {
		menu_uls.each(function(item){
			// add 'first' and 'last' classes
			var lis = $ES('li',item);
			if (!lis[0].hasClass('first')) lis[0].addClass('first');
			if (!lis[lis.length-1].hasClass('last')) lis[lis.length-1].addClass('last');
		});
	}
	// make sure every UL that has children _and_ grandchildren, gets 'current_page_parent' class
	$$('#submenu li li').setStyle('display','none');
	
	$$('#submenu .current_page_item').each(function(item){
		theparent = item.parentNode;
		while(theparent.tagName == 'UL' || theparent.tagName == 'LI') {
			if (theparent.parentNode.tagName == 'LI' && !theparent.parentNode.hasClass('current_page_parent')) theparent.parentNode.addClass('current_page_parent')
			theparent = theparent.parentNode;
		}
	});
	
	$$('#submenu .current-cat').each(function(item){
		theparent = item.parentNode;
		while(theparent.tagName == 'UL' || theparent.tagName == 'LI') {
			if (theparent.parentNode.tagName == 'LI' && !theparent.parentNode.hasClass('current-cat-parent')) theparent.parentNode.addClass('current-cat-parent')
			theparent = theparent.parentNode;
		}
	});
	
	$$('#submenu li.current_page_parent li').setStyle('display','block');
	$$('#submenu li.current_page_item li').setStyle('display','block');
	$$('#submenu li.current-cat-parent li').setStyle('display','block');
	$$('#submenu li.current-cat li').setStyle('display','block');
	
	// add appropriate event handlers to logos at news page
	if ($$('ul.list-1 dl.entry')) {
		$$('ul.list-1 dl.entry').each(function(item){
			var prev = item.getPrevious();
			if (prev.tagName == 'A') {
				prev.addEvent('mouseover',function(){
					this.getNext().getElement('dt a').addClass('hover');
				});
				prev.addEvent('mouseout',function(){
					this.getNext().getElement('dt a').removeClass('hover');
				});
			}
		});
	}
	
	// correct markup for h3s in .box'es 
	if ($$('.extrait .box h3')) {
		$$('.extrait .box h3').each(function(item){
			item.innerHTML = '<span><span>' + item.innerHTML + '</span></span>'; 
		});
	}
	
});

