function odoscopeHeatMap() {
  this.params = '';
  this.imageId = '';
  this.orgImageSrc = '';
  this.pageWidth = 0;
  
  odoscopeHeatMap.prototype.setPageWidth = function(value) {
  	this.pageWidth = value;
  }
  
  odoscopeHeatMap.prototype.setParams = function(value) {
  	this.params = value;
  }

  odoscopeHeatMap.prototype.setImageId = function(value) {
    this.imageId = value;
  }

  odoscopeHeatMap.prototype.initImage = function() {
  	var e = document.getElementById(this.imageId);
  	if (e != null) {
  		this.orgImageSrc = e.src;
  		e.src = this.orgImageSrc + this.params + '&x=-1&y=-1';
  	}
  }
  
  odoscopeHeatMap.prototype.initMouseCapture = function() {
  	document.oscHMObj = this;
    if (window.opera && document.addEventListener) {
      document.addEventListener('click', this.doClick, false);
      return true;
    } else if (document.addEventListener) {
      document.addEventListener('click', this.doClick, true);
      return true;
    } else if (document.attachEvent){
      var res = document.attachEvent('onclick', this.doClick);
      return res;
    } else {
      return false;
    }  
  }
  
  
  odoscopeHeatMap.prototype.getClientDimensions = function() {
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	
	return Array(x, y);
  }
  
  odoscopeHeatMap.prototype.doClick = function(e) {
    var IE = document.all?true:false;
    if (!e) {
      e = window.event;
    }
    
    if (IE) {
		if (document.documentElement) {
			var mouseX = event.clientX + document.documentElement.scrollLeft;
			var mouseY = event.clientY + document.documentElement.scrollTop;
		}
		else {
			if (document.body) {
				var mouseX = event.clientX + document.body.scrollLeft;
				var mouseY = event.clientY + document.body.scrollTop;      	
			}
		}
    } 
    else {
		var mouseX = e.pageX;
		var mouseY = e.pageY;
    }
    
    var dimensions = document.oscHMObj.getClientDimensions();
    if (IE) {
    	var totalWidth = dimensions[0];
    	mouseY = mouseY - 27;
    }
    else {
    	var totalWidth = dimensions[0] - 18;
    }
    var restWidth = totalWidth - document.oscHMObj.pageWidth;
    restWidth = Math.max(Math.round(restWidth / 2), 0);
    mouseX = mouseX - restWidth;
    
  	var e = document.getElementById(document.oscHMObj.imageId);
  	if (e != null) {
  		e.src = document.oscHMObj.orgImageSrc + document.oscHMObj.params + '&x=' + mouseX + '&y=' + mouseY;
  	}
  }
}
