// JavaScript Document
function test()
{
	alert('foo');
}

function showPreview(thumb)
{
	// preload the preview image so we can reliably get the width for positioning
	var preload = new Image();
	preload.onload = function()
	{
		// preload is complete, get the position of the thumbnail and proceed
		var pos = findPos(thumb);
		var pp = document.getElementById('preview');
		pp.innerHTML = '<img id="previewImg" src="images/gallery/' + thumb.id + '-prev.jpg" />';
		var imgWidth = document.getElementById('previewImg').width;
		pp.style.top = (pos[1] - 156) + 'px';
		pp.style.left = (pos[0] - Math.round((imgWidth - thumb.width) / 2))+ 'px';
		pp.style.visibility = 'visible';
		//alert('pooz');
	}
	preload.src = 'images/gallery/' + thumb.id + '-prev.jpg';
}

function hidePreview()
{
	var pp = document.getElementById('preview');
	pp.style.visibility = 'hidden';
}

function swapMain(thumb)
{
	var extension = 'jpg';
	if (thumb == 'ce_marilyn') // hack for the wink!
	{
		extension = 'gif';
	}
	var mainImage = document.getElementById('pic');
	mainImage.src = 'images/gallery/' + thumb + '-large.' + extension;
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		do
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
		while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}
