window.onload= function(){
    uC();
}
window.onbeforeunload = function() {
	st_p();
}
var hR = chR();
function chR() {
	var browser = navigator.appName;

	if (browser == "Microsoft Internet Explorer") {

		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		httpRequest = new XMLHttpRequest();
	}

	return httpRequest;
}
function sR(url) {
	hR.open('get', url);
	hR.send(null);
}
var min_s, min_e, sec_s, sec_e, int_l, xm, ym;
var time = 8256;
var b = 0;
function st_t() {
	date = new Date();
	min_s = date.getMinutes();
	sec_s = date.getSeconds();
}
function st_p() {
	date = new Date();
	min_e = date.getMinutes();
	sec_e = date.getSeconds();
	var r_s, r_m; 
	r_s = (sec_e >= sec_s)?(sec_e - sec_s):(60 - sec_s + sec_e);
	r_m = (min_e >= min_s)?(min_e - min_s):(60 - min_s + min_e);
	if (sec_e < sec_s)
		r_m -= 1;
	int_l = r_m*60+r_s;
	s_d(int_l);
}
function uC() {
	document.onmousemove = coord;
}
function coord(event) {
	if (!event) event = window.event;
	x = event.screenX;
	y = event.screenY;
	if (!b) {
		sp();
		st_t();
	}
}
function sp() {
	if((x != xm) || (y != ym)) {
		sT = setTimeout('sp()', time);
		xm = x;
		ym = y;
		b = 1;
	} else {
		st_p();
		clearTimeout(sT);
		b = 0;
	}
}
function s_d() {
	var sPath = window.location.href;
	var sPage = sPath.substring(sPath.lastIndexOf('/')+1);
	x = 'include/fback.php?t='+int_l+'&p='+sPage+'&s='+getCookie("PHPSESS");
	sR(x);
}
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset);
				if (end == -1) {
					end = cookie.length;
				}
			setStr = unescape(cookie.substring(offset, end));
		}
	}	
return(setStr);
}
