$(function(){
	$('.one, .four, .five').addClass('width-fix');
});


// Clear the search field
$(function(){

	var initial = $('input.searchterm').attr('value');
	$('input.searchterm').focus(function(){
		if($(this).attr('value') == initial){
			$(this).attr('value', '');
		}
	});
	$('input.searchterm').blur(function(){
		if($(this).attr('value') == ''){
			$(this).attr('value', initial);
		}
	});
	// Little helper for the main menu
	$('ul#resources ul.child').hover(
		function(){
			$(this).siblings('a').addClass('hover');
		},
		function(){
			$(this).siblings('a').removeClass('hover');
		}
	);
	$('ul#resources ul.child ul.grandchild').parent('li').addClass('haschildren');
	
	var hover_elements = [
		'ul#navigation .toplevel',
		'ul#resources .toplevel',
		'#whats-new ol li',
		'#in-the-magazine ol li',
		'#projects-and-campaigns ol li',
		'#news .clickable',
		'#top-articles .clickable',
		'#gallery .clickable',
		'#what-we-like .clickable'
	];
	for (var i = 0; i < hover_elements.length; i++) {
		$(hover_elements[i]).mouseover(
			function(){ $(this).addClass('hover'); }
		).mouseout(
			function(){ $(this).removeClass('hover'); }
		);
	}
	$('ul#resources li:first-child,ul#navigation li:first-child').addClass('first-child');
	$('ul#resources li:last-child,ul#navigation li:last-child').addClass('last-child');
	
	//$('.article-main ul, .article-main ol').after('<div class="clear"></div>');
	
	$('.clickable a').bigTarget({
		hoverClass : 'over',
		clickZone : '.clickable:eq(0)'
	});
	
});