/***************************************************************************
 *       ___ _   _                    ____           _       _
 *      |  _| | | |_ __  _ _  ___    / ___|  ___ _ _(_)_ __ | |_
 *      | |_| |_| | '_ \| '_)/ _ \   \___ \ / __| '_) | '_ \| __| 
 *      |  _|  _  | |_) | | | (_) |   ___) | (__| | | | |_) | |_ 
 *      |_| |_| |_| .__/|_|  \___/   |____/ \___|_| |_| .__/ \__|
 *                |_|  www.fhpro.de                   |_|
 *
 *   Copyright            : (c) 2006 Frank Hinkel
 *   Kontakt              : info@fhpro.de
 *
 ***************************************************************************/


/*** IMAGE LAYER ***/
function FhproWebtrack() {
	this._showTrack = 0;
    this._clickPos  = { x: 0, y: 0 };
}
FhproWebtrack.prototype = {  
	initialize: function() 
	{
		if (this._showTrack != 1 && this._showTrack != 2)
			return;
			
		var xPos = 0;
		try
		{	
			// minus Referenz X
			xPos = CLweb2.getAbsPosition(CLweb2.getElem('webtrackRef')).x;
		}
		catch(e) {}				
			
        var objpreBox = CLweb2.getElem('webtrackBox');                        
		var objAlpha  = document.createElement("div");
		objAlpha.setAttribute('id','webtrackBoxAlpha');	
		
		if (this._showTrack == 2)
            objAlpha.className = 'webtrackBoxAlpha';
		else
            objAlpha.className = 'webtrackBoxNonAlpha';
		
		objAlpha.innerHTML = '<img src="/heatmap/heatmap.png?do=display&maptype=' + (this._showTrack-1) + '&web=100&xpos='+xPos+'" id="webtrackBoxAlpha" />';		
		objpreBox.appendChild(objAlpha);   
	},
	onMouseDown: function(e) 
	{
		if (this._showTrack > 0)
			return;		
		
	    var xCoord, yCoord;
	    
		if (typeof e != 'undefined' && !window.event)
		{
		    // FF
			topHeight = document.body.scrollTop ? document.body.scrollTop : window.pageYOffset;
			this._clickPos.x = e.pageX;
			this._clickPos.y = e.pageY;
		}
		else
		{
		    // IE
            topHeight = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
			this._clickPos.x = window.event.clientX;
			this._clickPos.y = window.event.clientY + topHeight;	
		}
		
		try
		{	
			// minus Referenz X
			this._clickPos.x = this._clickPos.x - CLweb2.getAbsPosition(CLweb2.getElem('webtrackRef')).x;
		}
		catch(e) {}	
			
		var sendInk = (location.protocol=="https:"?"https:":"http:")+"//www.tuninglove.de"
		sendInk += '/heatmap/heatmap.png?do=webTrack&x=' + this._clickPos.x + '&y=' + this._clickPos.y + '&web=100';

    	if(document.images)
    	{
        	if(typeof(arrImg)=="undefined")
            	arrImg = new Array();
            
        	var ii = arrImg.length;
        	arrImg[ii] = new Image();
        	arrImg[ii].src = sendInk;
		}
		else		
			document.write('<img src="'+sendInk+'" height="1" width="1" />');
	}
}

//var CLwebtrack = new FhproWebtrack(); 
//CLweb2.addEvent(document,'mousedown','CLwebtrack.onMouseDown(e);');
//CLweb2.setOnLoad("CLwebtrack.initialize();");
