$(document).ready(function(){

	// Set tabindex on the main and section divs so IE knows they are focusable, and so Webkit browsers will focus() them.
	$('#maincontent').attr('tabindex', -1);
	$('.section').attr('tabindex', -1);

	var is_webkit = navigator.userAgent.toLowerCase().indexOf('webkit') > -1;
	var is_opera = navigator.userAgent.toLowerCase().indexOf('opera') > -1;

	// If there is a '#' in the URL (someone linking directly to a page with an anchor), highlight that section and set focus to it.
	if (document.location.hash) {
		var myAnchor = document.location.hash;
		$(myAnchor).css("backgroundColor","#ffff66").animate({ backgroundColor: "#ffffff" }, 1000);
		$(myAnchor).focus();
	}
	
	// Highlight targets of in-page links when clicked. If Webkit, set focus to it.
	$("a[href^='#']").click(function(event){
		var clickAnchor="#"+this.href.split('#')[1];
		$(clickAnchor).css("backgroundColor","#ffff66").animate({ backgroundColor: "#ffffff" }, 1000);
		if(is_webkit || is_opera) 
		{
			$(clickAnchor).focus();
		}
	});
	
	// If there's a 'fade' id (used for error identification), highlight it and set focus to it.
	if ($('#fade').length ) {
		$('#fade').css("backgroundColor","#ffff66").animate({ backgroundColor: "#ffffff" }, 1000);
		$('#fade').attr('tabindex', -1);
		$('#fade').focus();
	}


});



