/*
 *	Author:	Claudio Bredfeldt
 *	Link:		www.cbmono.de
 *	Email:	claudio@cbmono.de
 *	Date:		11.12.2008
 */

var img_active = null;

function load_img (file)
{
	// Create a DIV with an absolute position and load a image file into it

	if (img_active == file) return;
	if ($('gal_main') != undefined) unload_img ();

	var body = document.getElementsByTagName ('body')[0];
	var main = Builder.node ('div', {id: 'gal_main'});
	var conatiner = Builder.node ('div', {id: 'gal_conatiner'});
	var img = Builder.node ('img', {id: 'gal_img_large'});
	var mask = Builder.node ('img', {id: 'gal_mask', src: 'images/gallery/mask.gif', onclick: 'unload_img()'});
	
	var img_large = new Image ();
	img_large.src = img_active = file;

	conatiner.appendChild (img);
	main.appendChild (conatiner);
	main.appendChild (mask);
	body.appendChild (main);

	$(conatiner.id).hide ();

	img_large.onload = function () 
	{
		// show image after loaded it

		setTimeout (function () 
		{
			$(img.id).src = img_large.src;
			$(conatiner.id).slideDown ({duration: .5});
		}, 
		1000);
	}
}

function unload_img ()
{
	// remove a DIV from the body (id: 'gal_main')

	var body = document.getElementsByTagName ('body')[0];
	body.removeChild ($('gal_main'));

	img_active = null;
}