var timer;
var delay = 45000;
var Hjemmeside = 'http://konowsbilpleie.no/Sider/Tilbud.php';

if (typeof Kundepanel != 'undefined'){
	start_timer();
	document.onmousedown = reset_timer();
	document.onkeypress = reset_timer();
}

addLoadEvent(
	function(){
		if (window.location.href == Hjemmeside){
			clearTimeout(timer);
		} 
	}
);

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

function start_timer(){
	timer = setTimeout(function () {
		go_home();
	},delay);
}

function reset_timer(){
	clearTimeout(timer)
	start_timer();
}

function go_home(){
	window.location.href = Hjemmeside;
}
