var Splash = {
	init: function(options){
		this.options = $extend({
		}, options || {});
		
		$('latest-news').setStyles({'opacity':0});
	
		if($$('div.photography').length>0){
		
			this.imgSrc = randomImg;
		
			this.largeView = new Element('div', {'id': 'largeView','class':'viewer', 'styles': {'display': 'none'}}).injectInside(document.body);
			this.largeView.onclick = this.close.bind(this);;

			this.preload = new Image();
			this.preload.onload = this.onImgLoaded.bind(this);
			this.preload.src = this.imgSrc;	
		
		}
		
	},
	getContent: function(){
		var arr = $$('.mod_newsarchive');
		return arr[0];
	},
	onImgLoaded: function(){

		el = this.largeView;
		el.setStyles({'opacity':0,'display':'block'});
		el.style.backgroundImage = 'url('+this.imgSrc+')';
		el.style.width = this.preload.width+'px';
		el.style.height = this.preload.height+'px';
		
		el.fade(0,1);
		
		// fade out after some seconds
		this.close.delay(5000);	

		
	},
	close: function(){
		Splash.showNews.delay(600);
		$('largeView').fade(0);
		
		
		
		if (this.preload){
			if(!Browser.Engine.trident){
				this.preload.onload = Class.empty;
			}
			this.preload = null;
		}
		
		return false;
		
	},
	showNews: function(){
		$('latest-news').fade(1);
	
	}
};
/*
var loc = String(document.location);
if(loc.indexOf("?")<0){
	document.location.href = loc+"?month=201101";
}
*/
window.addEvent('domready', Splash.init.bind(Splash));
