(function($) {
	var staff = null;
	
	function handleJSON(res) {
		staff = res.staff;
		changeStaff();
	}
	
	function changeStaff() {
		var c = null;
		$(staff).each(function(i,s) { if(current == s.name) c = s; });
		$('.side-note').stop().animate({ marginRight:'-290px' }, 250, function() {
			var html = '';
			if(c.image) html += '<img src="/images/staff/'+c.image+'" alt="'+c.name+'" />';
			html += '<p><strong>'+c.name+'</strong><br />'+c.position+'</p>';
			html += c.details;
			html += '<p class="photo-credit">*Photography provided by Gary Mester Master Photographer</p>';
			$(this).html(html).animate({ opacity:1 }, 300).animate({ marginRight:0 });	
			pageTracker._trackPageview('about-board/'+c.url);
		});
	}
	
	$(document).ready(function() {
		var mask = $('<div id="mask"></div>').css({ float:'right', overflow:'hidden', margin:'0 3px 20px 15px', width:'290px' });;
		$('.side-note').appendTo(mask);
		$('.major h2:first').after(mask);
		
		$('.staff').click(function() {
			current = $(this).find('strong').text();
			if(!staff) $.getJSON('ajax-data.php', { action:'getStaff' }, handleJSON);
			else changeStaff();
			return false;						   
		});
	});
})(jQuery);
