window.addEvent('domready',function()
{
	//preload

//	preloadImgs(imgs);
	
});


function preloadImgs(imgs)
{
	imgs.each(function(im){
		var img = new Element('img');
		img.src = im;
		img.set('styles',{
			'position':'absolute',
			'left':'-1000px',
			'top':0
		});
		img.injectBottom(document.body);
	})
}

function shadowShow(url, data)
{
var a = new Request(
	{
		'url': url,
		'data': data,
		onComplete : function(result)
		{
			var sElem = shadow();			
			sElem.set('html',result);
		},
		evalScripts : true		
	}).send();
}


function shadow(destroyOnClick)
{
	if (typeof(destroyOnClick) == 'undefined') destroyOnClick = true;
	var w = window.getCoordinates().width;
	var h = window.getScrollSize().y;
	
	var d = new Element('div');
	d.setStyles ({
		'position':'absolute',
		'left' : 0,
		'top' : 0,
		'width' : w,
		'height' : h,
		'background' : 'url(images/bg-75.png) repeat',
		'opacity' : 0,
		'z-index': 9999
	});
	d.addEvent('click', function()
	{
		if (!destroyOnClick) return d;
		this.tween('opacity',0).get('tween').chain(function()
		{
			this.destroy();
		}.bind(this));
	}.bind(d));	
	d.set('tween',{duration:800, link:'chain'});
	d.injectTop(document.body);
	d.morph({'opacity':1});
	return d;
}


