<?php

// Load settings
$O__fileData = O__XMLdata($O__DBpath . "/pageTypes/O__screensaver/configs/settings.xml", 0);
$O__screensaverActive = O__XMLxDataGet($O__fileData,"/settings/setting","screensaverActive",0,"value");
$O__screensaverStart = O__XMLxDataGet($O__fileData,"/settings/setting","screensaverStart",0,"value");
unset($O__fileData);
?>

<script>
	var O__screenSaverSwitch = <?php echo($O__screensaverActive); ?>;
	var O__startSaver = <?php echo($O__screensaverStart); ?>;
	var O__countSaver = 0;
	
	function O__checkSaver(){
		if (O__countSaver == (O__startSaver*60)){ 
			location.href="/O__screensaver"; 
		} else {
			O__countSaver++;
			setTimeout("O__checkSaver();", 1000);
		}
	}

	function O__resetSaver(){ O__countSaver=0; }

	<?php if (strpos($_SERVER["HTTP_USER_AGENT"],"MSIE")==""){ //if not an IE browser ?> 
		document.addEventListener("keydown", O__resetSaver, false);
		document.addEventListener("mousemove", O__resetSaver, false);
		document.addEventListener("click", O__resetSaver, false);
	<?php } else { // if an IE browser ?> 
		document.attachEvent("keydown", O__resetSaver, false);
		document.attachEvent("mousemove", O__resetSaver, false);
		document.attachEvent("click", O__resetSaver, false);	
	<?php }?>
	
	var O__currentURL = window.location.search.slice(1);
	var O__self = O__currentURL.indexOf("O__screensaver");	
	if((O__screenSaverSwitch == 1)&&(O__self == -1)){ O__checkSaver(); }
</script>
