<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<?php
$dbh = new PDO("mysql:host=localhost;dbname=mmaaaco_cjorgensen", "mmaaaco_cjorgen", "TD}*;vhNWkT$");
$page = basename($_SERVER['PHP_SELF']);
$uid = $_SESSION['id'];
$upsql = $dbh->prepare("update users set lastaction = now(),currpage = ? where id = ?");
$upsql->execute(array($page,$uid)); 

function makepass() {
$salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
srand((double)microtime()* 1000000);
$i=0;
while($i<7)
    {
 $num = rand() % 33;
 $tmp = substr($salt,$num,1);
 $pass = $pass.$tmp;
 $i++;
	}
return $pass;
}

?>
<script type="text/javascript">
function update(){

var	request = new XMLHttpRequest();
var url = 'update.php?id=<?= $_SESSION['id'];?>&page=<?=$page;?>';
request.open("GET", url, true);
request.send(null);
}
var timer = 0;

function checkedloggedin(){
	timer+=10;
	nomove
	if (timer > 300) {
	var notmoved = load( "checknomovement.php");
		//test value to see if still there if not then load password field
		
	//if there is no movement and the timer is at 300 seconds, ask them if they are still logged in, but log them out and ask for a password only 
	}
	 	}
	var myVar=setInterval(function(){checkedloggedin();},10000);


document.addEventListener("DOMContentLoaded", function(){
document.addEventListener("click", update, false);
document.addEventListener("keydown", update, false)    //Bind the key event here.
document.addEventListener("mousemove", update, false)    //Bind the key event here.
});





setInterval(function() {
	$( "#usersonline" ).load( "getusers.php?page=<?=$page;?>");
    


}, 5000);



</script>
