var ZoomGallery = new function() {

	this.locked = false;
	
	this.lock = function(t) {
		this.locked = true;
		setTimeout("ZoomGallery.locked=false;",t);
	}

	this.set = function(imgURL)
	{
		$('Zoomed').src = imgURL;
	}

	this.show = function(thumbId, imgURL)
	{
		if (this.locked) return;
		this.lock(400);
		
		this.set(imgURL);
		this.position(thumbId);
		
		$('ZoomedViewer').blindDown({duration:0.4}).appear({duration:0.4});
		$('ZoomedViewer').onclick = function() {  ZoomGallery.hide(); };
			
	}
	
	this.hide = function()
	{
		if (this.locked) return;
		this.lock(400);
		
		$('ZoomedViewer').blindUp({duration:0.4}).fade({duration:0.4});
	}

	this.position = function(thumbId)
	{
		var coords = GetCoords(thumbId);
		var coords2 = GetCoords('landing_column_middle');
		$('ZoomedViewer').style.left = coords2[0] + 'px';
		$('ZoomedViewer').style.top = coords[1]-1 + 'px';
	}
	
}

function GetCoords(thumbId)
{
	// Get the "scroll position" (x and y) of the element
	var thumbPos = $(thumbId).cumulativeOffset();
	
	return(thumbPos);
}

function preloadImage(imageUrl)
{
	if (document.images)
	{
		var img = new Image();
		img.src = imageUrl;
	}
}

