$(document).ready(function(){
	$('body').append('<div id="altDiv"></div>');
		
	$('div.open a img').bind('click',function(){
		if ($('#overlayImage').is('div')){
			$('#overlayImage').remove();
			$('#closeOverlay').remove();
			
		}
		
		$.blockUI({ message: null }); 
		newImage = $(this).attr('src').substring(0,$(this).attr('src').length-4) + '_big.jpg';
		offsetTop = $(this).position().top;
		
		$(this).attr('alt',$('#altDiv').html());
		
		$('body').append('<div id="overlayImage" style="position:absolute; top:'+offsetTop+'px; left:340px; display: none;"><div id="closeOverlay"><a href="#">x</a></div><img src="../../js/'+newImage+'" /><br/><span id="photoDescription">'+$(this).attr('alt')+'</span></div>');
		
		$('#closeOverlay a').bind('click',function(){
				$('#overlayImage').fadeOut(function(){
					$('#overlayImage').remove();
					$('#closeOverlay').remove();
					$.unblockUI();
					return false;
				});
				$.unblockUI();
				return false;
				
		});
		
		$('#overlayImage').fadeIn();
	
		return false;
	});
	
	
	 $('img').bind("mouseenter",function(){
	 	$('#altDiv').html($(this).attr('alt'));
	 	$('#altDiv').show();
	 	$(this).attr('alt','');
	 	
     }).bind("mouseleave",function(){
     	$(this).attr('alt',$('#altDiv').html());
    	$('#altDiv').hide();  
   	 });
	
	$('img').bind("mousemove",function(e){
	 	$('#altDiv').css({top: e.pageY + 15  + 'px', left: e.pageX + 15 + 'px'});
     });
   	 
	
});


