SafeEnergyWP = Class.create();
Object.extend(SafeEnergyWP.prototype, 
{
	initialize: function(__timeout) {
		
		this.safeEnergyCont = "safeEnergyCont";
		this.counter = 0;
	
		if(__timeout == undefined){
			this.counterMax = 10;//seconds
		}else{
			this.counterMax = __timeout;//seconds
		}

		this.closeAction = this.hidesafeEnergy.bind(this);
		//FF
		document.observe("mousemove", this.closeAction, false);
		//IE
		document.onmousemove = this.closeAction;

		this.check = this.checkTime.bind(this);
		
		
		
		this.tim = setInterval (this.check, 1000);
		
	},
	checkTime: function() {
		this.counter++
		if(this.counter == this.counterMax){
			this.showsafeEnergy()
		}
	},
	getWindowHeight: function() { 
		var p = [window.innerHeight ? window.innerHeight : null, document.body ? document.body.clientHeight : null, document.documentElement ? document.documentElement.clientHeight : null];
		for (var i = 0; i < p.length; i++) {
			if (p[i] > 0) return p[i];
		}
		return 0;
	},
	getWindowWidth: function () { 
		var p = [window.innerWidth ? window.innerWidth : null, document.documentElement ? document.documentElement.clientWidth : null, document.body ? document.body.clientWidth : null];
		for (var i = 0; i < p.length; i++) {
			if (p[i] > 0) return p[i];
		}
		return 0;
	},
	showsafeEnergy: function (){    
		var div = $(this.safeEnergyCont);	
		if(div == null){
			var f_width = this.getWindowWidth();
			var f_height = this.getWindowHeight();
			
			var h = '<div class="safeEnergyBack" style="height:'+f_height+'; width:'+f_width+';">';
			h += '<div class="safeEnergyC" style="height:228px; width:183px; margin-top:'+parseInt(f_height/2 - 130)+'px;margin-left:'+parseInt(f_width/2 - 90)+'px">';
			h += '</div>';
			h += '</div>';
			
			var div = document.createElement("DIV");
			div.id = "safeEnergyCont";
			document.body.appendChild(div);
			div.innerHTML = h;
			
			/*riprendo il div creato in modo da non causare errori su IE*/
			div = $(this.safeEnergyCont);
			
			div.setStyle({position:"absolute"});
			div.setStyle({zIndex:"1000"});			
			div.setStyle({left:"0px"});
			div.setStyle({top:"0px"});			
			div.setStyle({width:f_width + "px"});
			div.setStyle({height:f_height + "px"});
			div.setStyle({display:"none"});

		}

		div.appear({ duration: 3.0 });
		/*div.setStyle({display:"block"});*/
	},
	hidesafeEnergy: function (){
		this.counter = 0;
		var div = $(this.safeEnergyCont);		
		if(div != null){
			div.setStyle({display:"none"})
		}		
	}
});