function init_gallery()
{
	var images = new Array();
	$('#presentation #content a img').each(function(i){
			var imagesrc = $(this).attr('src');
			var imagename = imagesrc.replace("sample","large_sample");
			images[i] = new Image();
			images[i].src = imagename;
		});
		$('#presentation #content a').each(function(i){
				 $(this).hover(function() {
					var captiontext = $(this).children('img').attr('alt');
					$('#preview p').text(captiontext);
					$('#preview').show();
					$().mousemove(function(mouse)
						{
							var x = getscroll();
							var y = getwindowsize();
							
							if ((x + y) > (mouse.pageY+images[i].height+90-150))
								{
									$('#preview').css({top:mouse.pageY-150, left:mouse.pageX + 20});
								} else
								{
									$('#preview').css({top:x+y-images[i].height-90, left:mouse.pageX + 20});	
								}
						});
					$('#preview').css({width:images[i].width, height:images[i].height+60});
					$('#preview img').attr('src', images[i].src);
					}, function()
					{
					$('#preview').hide();
		});
	 	$('#presentation #content a').click(function(){return false;})
	});
}
function getscroll()
{

	var scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
	
	return scrollTop;
}
function getwindowsize()
{
 	var viewportheight;
	  if (typeof window.innerWidth != 'undefined')
		 {
			   viewportheight = window.innerHeight
		 } else if (typeof document.documentElement != 'undefined'
		 && typeof document.documentElement.clientWidth !=
		 'undefined' && document.documentElement.clientWidth != 0)
		 {
			   viewportheight = document.documentElement.clientHeight
		 } else
		 {
			   viewportheight = document.getElementsByTagName('body')[0].clientHeight
		 }
	return viewportheight;
}
jQuery(function($) 
	{
		init_gallery();
 	});