<!--

var posX = 0;
var posY = 0;
var browser = "";
var start_tracking = "";
var data_posx = "";
var data_posy = "";
var data_time = "";
var data_scrollx = "";
var data_scrolly = "";
var currentTime = new Date()
var startTime = currentTime.getTime();
var iiii = 0;
var MTaccountID = "";

window.document.onmousemove = getMouseXY;
window.onscroll = getMouseXY;

var expdate=new Date(); expdate.setTime(expdate.getTime()+(24*60*60*1000*365));

var cookieval=0;
var cookieval_percentage=0;

function doPassVar(var1){
		window.document.mousetracking.SetVariable("var1", var1);
}

function catchClickHeat(e)
{
	try
	{
		startMouseTracking('KlikUpdate');
	}
	catch(e)
	{
	}
	return true;
}

function commitFlashObject(_obj, _container){
	_output=""
	_paramoutput=""
	_src=""
	_ver=""
	for(_cO in _obj){
		_output+=_cO+"=\""+_obj[_cO]+"\" "
		_paramoutput+="<param name="+_cO+" value=\""+_obj[_cO]+"\">";
		if(_cO=="movie")_src="src=\""+_obj[_cO]+"\"";
		if(_cO=="version")_ver=_obj[_cO];
	}
	if(_ver=="")_ver="8,0,0,0"
	ihtm="<object id=mousetracking classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+_ver+" "+_output+">\n"
	ihtm+=_paramoutput+"\n"
	ihtm+="<embed "+_src+" pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash "+_output+">\n";
	ihtm+="</embed>\n";
	ihtm+="</object>\n";
	document.getElementById(_container).innerHTML=ihtm
}

function GetCookie(name)
{
	var arg=name+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while(i<clen)
	{
		var j=i+alen;
		if(document.cookie.substring(i,j)==arg) return getCookieVal(j);
		i=document.cookie.indexOf(" ",i)+1;
		if(i==0)break;
	}
	return null;
}

function getCookieVal(offset)
{
	var endstr=document.cookie.indexOf(";",offset);
	if(endstr==-1)endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset,endstr));
}

function SetCookie(name, value, expires, path, domain, secure)
{
	document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
}

function getMouseXY(e) {	
	try
	{
		iiii++;
		var currentTime = new Date()
		tijdinmilliseconden = currentTime.getTime()
	
		if(navigator.appName == "Netscape"){
	
			if (e) {
				scroll_data_save_x = e.pageX
				scroll_data_save_y = e.pageY
				posX = scroll_data_save_x			
				posY = scroll_data_save_y
			}
		} else {
	
			if (document.all){
				scroll_data_save_x = document.body.scrollLeft;
				scroll_data_save_y = document.body.scrollTop;
			} else {
				scroll_data_save_x = window.pageXOffset;
				scroll_data_save_y = window.pageYOffset;
			}
	
			if ((scroll_data_save_x == 0) || (scroll_data_save_y == 0)) {
				scroll_data_save_x = document.documentElement.scrollLeft
				scroll_data_save_y = document.documentElement.scrollTop
			}
	
			posX = event.clientX + scroll_data_save_x
			posY = event.clientY + scroll_data_save_y	
		}
	
		if (posX <= 0) {posX = 0} 
		if (posY <= 0) {posY = 0}   
	
	
		if ((iiii % 4) == 0) {
			data_posx = data_posx + posX + ','
			data_posy = data_posy + posY + ','
			data_time = data_time + (tijdinmilliseconden-startTime) + ','
			data_scrollx = data_scrollx + scroll_data_save_x + ',' 
			data_scrolly = data_scrolly + scroll_data_save_y + ',' 
		}
	
		// 10x => x-,y-,time-pos
		if (iiii > 40) {
			startMouseTracking('TussenUpdate')
		}
	
	}
	catch(e)
	{
	}
	return true;
}
	
function startMouseTracking(Type_Update) {
	var currentTime = new Date()
	var endTime = currentTime.getTime();
	updateTrackingData(Type_Update,startTime,endTime,data_posx,data_posy,data_time,data_scrollx,data_scrolly);
	endTime="";
	data_posx="";
	data_posy="";
	data_time="";
	data_scrollx="";
	data_scrolly="";
	return true;	
}

function action_start_tracking() {	
	width = screen.width;
	height = screen.height;
	postdata = 'page=setstartdata|cookieid='+cookieval+'|browser='+navigator.userAgent+'|heightClient='+height+'|widthClient='+width+'|locationURL='+window.location.href+'|accountID='+MTaccountID;

	doPassVar(postdata);
}

function updateTrackingData(Type_Update,start_Time,end_Time,data_Xpos,data_Ypos,data_Time,data_Scrollx,data_Scrolly) {
	
	wsize=document.documentElement.clientWidth+','+document.documentElement.clientHeight;
	var token = gettokenExtern();

postdata = 'page=setdata|cookieid='+cookieval+'|typeupdate='+Type_Update+'|accountID='+MTaccountID+'|data_time_begin='+start_Time+'|data_time_eind='+end_Time+'|locationURL='+window.location.href+'|data_Xpos='+data_Xpos+'|data_Ypos='+data_Ypos+'|data_time='+data_Time+'|data_scrollx='+data_Scrollx+'|data_scrolly='+data_Scrolly+'|wsize='+wsize+'|TokenExtern='+token;

	iiii=0;
	doPassVar(postdata);
}

function gettokenExtern() {

	var yourQS = location.search;
	// now you need to eliminate that ? mark
	yourQS = location.search.substring(1);
	var pairs = yourQS.split("&");
	var tmpAry;
	for(var i=0; i<pairs.length; i++){
		tmpAry = pairs[i].split("=");
		if (tmpAry[0] == "token") {
			return tmpAry[1];
		}
	}
}

function initMouseTracking(path,MouseTrackingID,percentage) {

	MTaccountID = MouseTrackingID;
	
	cookieval = GetCookie(MTaccountID+"_id");
	cookieval_percentage = GetCookie(MTaccountID+"_percentage");
	
	if(cookieval == null)
	{
		var rnd = Math.round(Math.random()*1000000000);	
		var rnd2 = Math.round(Math.random()*100);
			
		SetCookie(MTaccountID+"_id",rnd,expdate,"/",null,false);
		SetCookie(MTaccountID+"_percentage",rnd2,expdate,"/",null,false);
		cookieval = GetCookie(MTaccountID+"_id");
		cookieval_percentage = GetCookie(MTaccountID+"_percentage");
	}
	
//	alert(cookieval_percentage +" <= "+ percentage);
	if (parseInt(cookieval_percentage) <= parseInt(percentage)) {
		WsObj=new Object;
		WsObj.movie=path;
		WsObj.FlashVars="allowResize=false";
		WsObj.quality="high"; WsObj.wmode="transparent"; WsObj.width=0; WsObj.height=0; WsObj.version="5,0,0,0"; commitFlashObject(WsObj, "mousetracking_div");

		if (typeof document.onmousedown == 'function')
		{
			currentFunc = document.onmousedown;
			document.onmousedown = function(e) { catchClickHeat(e); return currentFunc(e); }
		} else {
			document.onmousedown = catchClickHeat;
		}
		
		action_start_tracking();
	}

}
// -->