$(document).ready(function () {
	
	$('.photo').mousemove(function(e) {
		$('#staff-name').show();
		if (window.event) e = window.event;
		$('#staff-name').html($(this).attr('alt'));
		tempX = 0;
		tempY = 0;
		if ($.browser.msie) { // grab the x-y pos.s if browser is IE
			tempX = event.clientX + document.body.scrollLeft+10;
			tempY = event.clientY + document.body.scrollTop+10;
		}
		else {  // grab the x-y pos.s if browser is NS
			tempX = e.pageX+10;
			tempY = e.pageY+10;
		}
		tempX = $(this).offset().left-110;
		tempY = $(this).offset().top+102;
		$("#staff-name").css("left", tempX).css("top", tempY);
	});
	$('.photo').mouseout(function() {
		$('#staff-name').hide();
	});
	
	
	$('.photo').click(function() {
		//lowestLimit = $(this).offset().top;
		h = $(this).next('.staff-hidden').html();
		$('#staff-profile').fadeOut(100, function() {
			$('#staff-profile').html(h);
			$('#staff-profile').fadeIn(100);
		});
		
	});
	
	h = $('.staff-hidden:first').html();
	$('#staff-profile').html(h);
	
	setInterval(adjustSidebar,500);

});

//the lowest limit of the floating sidebar
//should be the thumbnail's top.
//var lowestLimit = 253;
function adjustSidebar() {
	
	var offset = 286;
	var scroll = 0;
	
	var offsetTop = $('#staff-profile').offset().top;
	if ($.browser.msie && $.browser.version == '8.0') offsetTop -= 2;
	if ($.browser.msie && $.browser.version == '7.0') offset = 288;
	if ($.browser.mozilla || $.browser.opera) scroll = window.pageYOffset;
	if ($.browser.safari) scroll = document.body.scrollTop;
	if ($.browser.msie) scroll = document.documentElement.scrollTop;
	
	if (scroll < offset) {
		$('#staff-profile').css("top",offsetTop).animate({top: offset}, 300);
	}else{//if (scroll > offset && scroll < lowestLimit){
		$('#staff-profile').animate({top: scroll}, 300);
	}
}