// -- Revision 1.0 -->
// -- Copyright (c) 2007-2009 e-dynamics GmbH  All rights reserved. -->
// -- $DateTime: 2009/09/24 18:34:00 $ -->
function Heatmap(){
    // configure
	this.collectData = true; // tracking on/off
	this.randomtracking = 1;  // 1 = every user
	this.dom = 'upi.e-heat.de';
	this.accountID = 'eh303037_6161';
	this.maxHeight = 5000; // maximum height
	this.interval = 1000; // time between clicks in milliseconds
	this.startPoint = document.getElementById('page');
	
	// initialize tracking
	this.debug = false; // debugging on (no requests will be send)
	if(this.collectData === true){this.go();}
}
Heatmap.prototype.loadEvent=function(){var that=this;document.body.attachEvent?document.body.attachEvent('onmousedown',function(event){that.getClick(event);}):document.body.addEventListener('mousedown',function(event){that.getClick(event);},false);};
Heatmap.prototype.getClick=function(e){e=e||window.event;if((e.which&&e.which==3)||(e.button&&e.button==2)){return;}var actual_time=new Date();if(actual_time.getTime()-this.timeDiff<this.interval){return;}this.timeDiff=actual_time.getTime();this.setPos();this.setWidth();if(this.IE){this.x=event.clientX+document.body.scrollLeft-this.offX;this.y=event.clientY+document.body.scrollTop-this.offY;}else{this.x=e.pageX-this.offX;this.y=e.pageY-this.offY;}if(this.y>this.maxHeight){return;}this.request();};
Heatmap.prototype.request=function(){var url='http'+(window.location.protocol.indexOf('https:')==0?'s':'')+'://'+this.dom+'/'+this.accountID+'/img.gif?';url+='x='+this.x+'&y='+this.y+'&t='+(this.timeDiff-this.time)+'&w='+this.ww+'&p='+encodeURIComponent(this.pagename);for(var seg in this.segment){url+='&'+seg+'='+encodeURIComponent(this.segment[seg]);}if(this.debug){alert(decodeURIComponent(url));}else{this.sendRequest(url);}};
Heatmap.prototype.sendRequest=function(url){if(document.images){this.images[this.index]=new Image();this.images[this.index].src=url;this.index++;}else{document.write('<img alt="" border="0" name="heatimage" width="1" height="1" src="'+url+'">');}};
Heatmap.prototype.go=function(){var z=Math.random()*this.randomtracking;if(z>1){return;}this.segment={};this.images=[];this.index=0;this.timeDiff=new Date();this.time=this.timeDiff=this.timeDiff.getTime();this.IE=(navigator.appName=='Microsoft Internet Explorer')?true:false;if(!this.startPoint){this.startPoint=document.getElementsByTagName('body')[0].childNodes[1];}if(!this.pagename){this.pagename=window.location.pathname;}this.loadEvent();};
Heatmap.prototype.defSegment=function(p_name,p_value){if(this.segment){this.segment[p_name]=p_value;}};
Heatmap.prototype.setPos=function(){this.offX=this.offY=0;var obj=this.startPoint;if(obj.offsetParent){do{this.offX+=obj.offsetLeft;this.offY+=obj.offsetTop;}while(obj=obj.offsetParent);}else if(obj.x){this.offX+=obj.x;this.offY+=obj.y;}};
Heatmap.prototype.setWidth=function(){this.ww=this.IE?document.body.clientWidth:window.innerWidth;};

