jQuery(function ($) {
	
	//add css frame to home page pics
	$('.home img').wrap('<div class="image-frame"></div>');	
	
	//mouseovers for home page (including a little trickery to preload the images)
	$('.home').append('<div id="preload" style="overflow:hidden;width:1px;height:1px;">')
		.find('#preload')
			.append('<div class="services"></div>')
			.append('<div class="training"></div>')
			.append('<div class="resources"></div>')
			.append('<div class="about"></div>')
			.append('<div class="contact"></div>');
	
	$('.home .menu a').mouseover(function () {
		switch ($(this).attr('title')) {
			case 'Services':
				$('.home .top').addClass('services');
				break;
			case 'Training':
				$('.home .top').addClass('training');
				break;
			case 'Resources':
				$('.home .top').addClass('resources');
				break;
			case 'About Us':
				$('.home .top').addClass('about');
				break;
			case 'Contact':
				$('.home .top').addClass('contact');
				break;
		}
	});
	$('.home .menu a').mouseout(function () {
		$('.home .top').removeClass('services training resources about contact');
	});
	
	//mouseovers/downs for menus throughout site
	$('.yui-t2 .menu a').hover(
		function () { $(this).parent().addClass('over') },
		function () { $(this).parent().removeClass('over') }
	);
	
	//turn brackets brown around links in highlights area
	$('#highlights p').each(function (){
		$this = $(this);
		$this.html($this.html().replace('[', '<span style="color:#5A3E02">[</span>'));
		$this.html($this.html().replace(']', '<span style="color:#5A3E02">]</span>'));
	});
	
	//course list page - fix table height to fill document
	$('.page-template-page-training-secondary-php tfoot').height($('#yui-main .yui-b').height() - $('tbody').height() - $('thead').height());
	
	//course page - stupid hack to make IE 8 NOT shift all the row text down to the baseline due to some style applied to the li's in the FG menu
	$('div.dates li').show();
	
	//form icons
	$('#fm_name').parent().append('<span class="man" />');
	$('#fm_email').parent().append('<span class="mail" />');
	$('#fm_message').parent().append('<span class="pen" />');
	
	//course date popup
	$('div.dates a.dates').each(function () {
		$(this).next().hide();
		$(this).menu({
			content: $(this).next().html(),		
			showSpeed: 300
		});
	});
	
	$('.fg-button').hover(
		function(){ $(this).removeClass('ui-state-default').addClass('ui-state-focus'); },
		function(){ $(this).removeClass('ui-state-focus').addClass('ui-state-default'); }
	);

	
	//make columns equal height
	//$('.yui-b').height(Math.max(500, $('.yui-b').height()[0], $('.yui-b').height()[1]));
	
	//ARIA accessibility role adder (so we can still validate XHTML compliant)
	$('#hd').attr('role', 'banner');
	$('#bd').attr('role', 'main');
	$('#menu').attr('role', 'navigation');
	$('#content, #ft').attr('role', 'contentinfo');	
	
});
