/* comments */


var soc_p;
var soc_kp = 0;
var soc_at = new Date();
var soc_interval = window.setInterval(soc_timedMousePos,250);
var soc_xPos = -1;
var soc_yPos = -1;
var soc_firstX = -1;
var soc_firstY = -1;
var soc_intervals = 0;
var soc_d = 0;
var soc_mt = 0;
	
function soc_dist(aX, aY, bX, bY) {
	soc_mt = Math.round(Math.sqrt(Math.pow(aX-bX, 2) + Math.pow(aY-bY, 2)));
}

function soc_timedMousePos() {
	if(soc_xPos >= 0 && soc_yPos >= 0) {
		var newX = soc_xPos;
		var newY = soc_yPos;
		soc_intervals++;
	}
	if(soc_intervals == 1) {
		soc_firstX = soc_xPos;
		soc_firstY = soc_yPos;
	} else if(soc_intervals == 2) {
		clearInterval(soc_interval);
		soc_dist(soc_firstX,soc_firstY,newX,newY);	
	}
}

function soc_getMousePos(p) {
	if(!p) { var p = window.event; }
	if (p.pageX || p.pageY) {
		soc_xPos = p.pageX;
		soc_yPos = p.pageY;
	} else if (p.clientX || p.clientY) {
		soc_xPos = p.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		soc_yPos = p.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
}

function soc_submitActual() {
	soc_d = (new Date()) - soc_at;
	var form = document.forms['contentSubmission'];
	form.mT.value = soc_mt;
	form.d.value = soc_d;
	form.kP.value = soc_kp;
	form.submit();
	return false;
}

function soc_submitComment() {
	if($("contentSubmission").hasClassName("ratings")) {
		soc_submitRating(soc_submitActual);
		return false;
	} else {
		soc_submitActual();
	}
}

Event.observe(document,'mousemove',soc_getMousePos);
Event.observe(document,'keypress',function() { soc_kp++; });
