function heightsPlot() {
				this.heightsBuffer   = [];
				this.distancesBuffer = [];
				this.htmlContainer = document.getElementById('heightImage');
        this.graphURL = '../routes/heightGraph.php?q';
}

heightsPlot.prototype.addHeight = function(h) {
	this.heightsBuffer.push(h);
}

heightsPlot.prototype.addDistance = function(d) {
	this.distancesBuffer.push(d);
}

heightsPlot.prototype.deleteLastPoint = function ( ) {
	this.heightsBuffer.pop();
	this.distancesBuffer.pop();
}


heightsPlot.prototype.insertGraph = function (  ) {
	var hImg = this.htmlContainer;
  var params = "";
	if ( this.heightsBuffer.length > 0 && this.distancesBuffer.length == this.heightsBuffer.length) {

					var totDist  = 0;
					for ( i in this.heightsBuffer )
					{
												 params += "&h[]=" + this.heightsBuffer[ i ];
					}

					for ( i in this.distancesBuffer )
					{
												 totDist += this.distancesBuffer [ i ];
												 params += "&d[]=" + totDist;
					}
	}

	hImg.src = this.graphURL  + params;
	hImg.style.display = 'block';
  hImg.onclick = function () { this.style.display = 'none' }
}


