/********************************************************
 *
 *	Wallpaper
 *
 *	Displays the image as a BODY-background.
 *
 *	If a click URL is provided in init-call, 
 *	the BODY-background is made clickable.
 *
 ********************************************************/

var Wallpaper = {
	image: null, 
	clickUrl: null, 
		
	init: function (image, clickUrl) {
		Wallpaper.image = image;
		Wallpaper.clickUrl = clickUrl;
		
		Wallpaper.load();
		
		if (Wallpaper.isClickable()) {
			EventAttacher.add(document, 'click', Wallpaper.click);
		}
	}, 

	load: function() {
		document.body.style.backgroundImage = 'url(' + Wallpaper.image + ')';
		document.body.style.backgroundRepeat = 'no-repeat';
		document.body.style.backgroundPosition = 'center top';
		document.body.style.backgroundColor = '#ffffff';
		
		if (Wallpaper.isClickable()) {
			document.body.style.cursor = "pointer";
			document.getElementById('GratisSpilBody').style.cursor = 'default';
		}
	},

	click: function(e) {
		var EE = e ? e : event;
		if (!EE) return;
	
		var t = EE.target ? EE.target : EE.srcElement;

		if (!t || t.tagName != "BODY") return;
		else window.open(Wallpaper.clickUrl);
	}, 
	
	isClickable: function() {
		return (Wallpaper.clickUrl && Wallpaper.clickUrl.length > 0);
	}
}	
