$(document).ready(function() {
	//alert($('#topphotos li:first').offset().left);
	//$(".thumbnail a").fancybox();
	$('.thumbnail a').click(function(){return hs.expand(this)});
	$('#topphotos a').click(function(){return false});
	
	$('#topphotos .wrapper').each(function(){
		imgSrc = $(this).children('a').attr('href');
		$(this).append('<div class="tooltip"><img src="'+imgSrc+'" alt="" /></div>');
	});
	$('#topphotos .wrapper').mouseenter(function(e) {
		x = -190;
		y = 60;

		if ($(this).offset().left + x < 0) x = -$(this).offset().left;
		if ($(this).offset().left + x + 525 > $(document).width()) {x = ($(document).width()-($(this).offset().left + 525))};
		// Set the z-index of the current item, 
		// make sure it's greater than the rest of thumbnail items
		// Set the position and display the image tooltip
		$(this).css('z-index','15')
		.children("div.tooltip")
		.css({'top': y ,'left': x ,'display':'block'})
		
	}).mousemove(function(e) {
		
		// Calculate the position of the image tooltip			
		x = e.pageX - $(this).offset().left;
		y = e.pageY - $(this).offset().top;
		
		// This line causes the tooltip will follow the mouse pointer
		//$(this).children("div.tooltip").css({'top': y + 10,'left': x + 20});
		
	}).mouseleave(function() {
		
		// Reset the z-index and hide the image tooltip 
		$(this).css('z-index','1')
		.children("div.tooltip")
		.animate({"opacity": "hide"}, "fast");
	});
        
	$('body.home .blockcontainer:gt(0)').each(function(){
		var _max = 0;
		$('.block',this).each(function(){
			_max = Math.max(_max,$(this).height());
		});
		if (_max) $('.block',this).height(_max);
	});
        
});

