//----------------------------------------------------------------------------------------------------------------
/**
* ConconiEngine is an abstract base class.
* The class implements a framework to estimate performance and trainingzones based on inputs from a conconitest. 
* @class
* @version 1.0
* @author Lasse Storgaard Jacobsen
* @constructor
*/

function ConconiEngine(){
}//ConconiEngine end

//Adds the functions to the class
ConconiEngine.prototype.setDataPoint = setDataPoint;
ConconiEngine.prototype.generate = generate;
ConconiEngine.prototype.resetAll = resetAll;

ConconiEngine.prototype.getAtPace = getAtPace;
ConconiEngine.prototype.getAtPuls = getAtPuls;
ConconiEngine.prototype.getAtSpeed = getAtSpeed;

ConconiEngine.prototype.getAetPace = getAetPace;
ConconiEngine.prototype.getAetPuls = getAetPuls;
ConconiEngine.prototype.getAetSpeed = getAetSpeed;

ConconiEngine.prototype.getNiv1ZonePaceMin = getNiv1ZonePaceMin;
ConconiEngine.prototype.getNiv1ZonePaceMax = getNiv1ZonePaceMax;

ConconiEngine.prototype.getNiv1ZonePulsMin = getNiv1ZonePulsMin;
ConconiEngine.prototype.getNiv1ZonePulsMax = getNiv1ZonePulsMax;

ConconiEngine.prototype.getNiv1ZoneSpeedMin = getNiv1ZoneSpeedMin;
ConconiEngine.prototype.getNiv1ZoneSpeedMax = getNiv1ZoneSpeedMax;

ConconiEngine.prototype.getNiv2ZonePaceMin = getNiv2ZonePaceMin;
ConconiEngine.prototype.getNiv2ZonePaceMax = getNiv2ZonePaceMax;

ConconiEngine.prototype.getNiv2ZonePulsMin = getNiv2ZonePulsMin;
ConconiEngine.prototype.getNiv2ZonePulsMax = getNiv2ZonePulsMax;

ConconiEngine.prototype.getNiv2ZoneSpeedMin = getNiv2ZoneSpeedMin;
ConconiEngine.prototype.getNiv2ZoneSpeedMax = getNiv2ZoneSpeedMax;

ConconiEngine.prototype.getNiv3ZonePaceMin = getNiv3ZonePaceMin;
ConconiEngine.prototype.getNiv3ZonePaceMax = getNiv3ZonePaceMax;

ConconiEngine.prototype.getNiv3ZonePulsMin = getNiv3ZonePulsMin;
ConconiEngine.prototype.getNiv3ZonePulsMax = getNiv3ZonePulsMax;

ConconiEngine.prototype.getNiv3ZoneSpeedMin = getNiv3ZoneSpeedMin;
ConconiEngine.prototype.getNiv3ZoneSpeedMax = getNiv3ZoneSpeedMax;

ConconiEngine.prototype.getNiv4ZonePaceMin = getNiv4ZonePaceMin;
ConconiEngine.prototype.getNiv4ZonePaceMax = getNiv4ZonePaceMax;

ConconiEngine.prototype.getNiv4ZonePulsMin = getNiv4ZonePulsMin;
ConconiEngine.prototype.getNiv4ZonePulsMax = getNiv4ZonePulsMax;

ConconiEngine.prototype.getNiv4ZoneSpeedMin = getNiv4ZoneSpeedMin;
ConconiEngine.prototype.getNiv4ZoneSpeedMax = getNiv4ZoneSpeedMax;

ConconiEngine.prototype.getTestMaxPuls = getTestMaxPuls;
ConconiEngine.prototype.getTestMaxPace = getTestMaxPace;
ConconiEngine.prototype.getTestMaxSpeed = getTestMaxSpeed;

ConconiEngine.prototype.getTestMinPuls = getTestMinPuls;
ConconiEngine.prototype.getTestMinPace = getTestMinPace;
ConconiEngine.prototype.getTestMinSpeed = getTestMinSpeed;

ConconiEngine.prototype.getAerobTrendlinePuls = getAerobTrendlinePuls;
ConconiEngine.prototype.getAnaerobTrendlinePuls = getAnaerobTrendlinePuls;

/**
* @private
*/
var datapoints 	= [];
var at_puls 	= 0;
var at_pace 	= "0:00";
var at_speed	= 0;

var aet_puls	= 0;
var aet_pace	= 0;
var aet_speed	= "0:00";


var niv1ZonePulsMin	= 0;
var niv1ZonePulsMax	= 0;

var niv1ZonePaceMin	= "";
var niv1ZonePaceMax	= "";

var niv1ZoneSpeedMin	= 0;
var niv1ZoneSpeedMax	= 0;

var niv2ZonePulsMin	= 0;
var niv2ZonePulsMax	= 0;

var niv2ZonePaceMin	= "";
var niv2ZonePaceMax	= "";

var niv2ZoneSpeedMin	= 0;
var niv2ZoneSpeedMax	= 0;

var niv3ZonePulsMin	= 0;
var niv3ZonePulsMax	= 0;

var niv3ZonePaceMin	= "";
var niv3ZonePaceMax	= "";

var niv3ZoneSpeedMin	= 0;
var niv3ZoneSpeedMax	= 0;

var niv4ZonePulsMin	= 0;
var niv4ZonePulsMax	= 0;

var niv4ZonePaceMin	= "";
var niv4ZonePaceMax	= "";

var niv4ZoneSpeedMin	= 0;
var niv4ZoneSpeedMax	= 0;

var testMaxPuls		= 0;
var testMaxPace		= "";
var testMaxSpeed	= 0;

var testMinPuls		= 0;
var testMinPace		= "";
var testMinSpeed	= 0;

var aerobTrendVertex	= 0;
var aerobTrendKonstant	= 0;
var anaerobTrendVertex	= 0;
var anaerobTrendKonstant= 0;





//----------------------------------------------------------------------------------------------------------------
/**
* This function adds a datapoint to the test sample. 
* The return datatype is a Void
* @param {Int} puls_int The time in secounds
* @param {Float} speed_float The speed in km/t
* @returns {Void} 
*/
function setDataPoint(puls_int,speed_float){
	var datapoint=[puls_int,speed_float];
	datapoints.push(datapoint);
}//setDataPoint end


//----------------------------------------------------------------------------------------------------------------
/**
* This function generate a performance based on the existing datapoints. 
* The return datatype is a Void
* @param {Int} sensebillity_int A value between 1-10 indicate the sensebillity in finding the AT breakpoint. Standart is 5
* @returns {Void} 
*/
function generate(){

	var currentVertex=0;
	
	var trendVertex1=0;
	var trendVertex2=0;
		
	var trendConstant1=0;
	var trendConstant2=0;
	
	var trendPoint1X=0
	var trendPoint1Y=0
	var trendPoint2X=0
	var trendPoint2Y=0
	
	var i=0;
	var datapoint1 = 0;
	var datapoint2 = 0;
	
	
	if (datapoints.length>11){
		
		//make trandline1
		for(i=1;i<11;i++){
	    datapoint1 = datapoints[i-1];
			datapoint2 = datapoints[i]; 
			currentVertex=(datapoint2[0]-datapoint1[0])/(datapoint2[1]-datapoint1[1]);
						
			if (i>1){
			  trendVertex1 = (trendVertex1+currentVertex)/2;	 
			}else{
			  trendVertex1 = currentVertex;	
			}		
	  }//end for
		
		
		
		
		
		
		
		//make trandline2
		for (i=datapoints.length-1;i>(datapoints.length-6);i--){
			datapoint1 = datapoints[i-1];
			datapoint2 = datapoints[i]; 
			currentVertex=(datapoint2[0]-datapoint1[0])/(datapoint2[1]-datapoint1[1]);
				
			if (i<datapoints.length-1){
				trendVertex2 = (trendVertex2+currentVertex)/2;	
			}else{
				trendVertex2 = currentVertex;	
			}
			
		}
		
			
		//make trendpoints
		for(i=0;i<(datapoints.length);i++){
			datapoint1 = datapoints[i]; 
					
			if (i<10){
				trendPoint1X+=datapoint1[0];
			 	trendPoint1Y+=datapoint1[1];	 
			}//end if
					
			if(i>(datapoints.length-5)){
				trendPoint2X+=datapoint1[0];
			 	trendPoint2Y+=datapoint1[1];
			}//end if
		}//end for
		trendPoint1X = trendPoint1X/10;
		trendPoint1Y = trendPoint1Y/10;
		trendPoint2X = trendPoint2X/4;
		trendPoint2Y = trendPoint2Y/4;
		
		
	
		
		//find breakpoint and set result values
		trendConstant1 = (trendVertex1*trendPoint1Y)-trendPoint1X;
		trendConstant2 = (trendVertex2*trendPoint2Y)-trendPoint2X;
		
		
		//AT values
		at_speed= ((trendConstant2-trendConstant1)/(trendVertex2-trendVertex1)).toFixed(2);
		at_puls = Math.round((trendVertex2*at_speed)-trendConstant2);
		at_pace = convertSecToPaceStr(((60/at_speed)*60));
			
		//AeT values
		aet_pace = convertSecToPaceStr(((60/(at_speed*0.91))*60));
		aet_speed = (at_speed*0.91).toFixed(2);
		aet_puls  = Math.round((trendVertex1*aet_speed)-trendConstant1);
			
		//niv 1 zone values
		niv1ZoneSpeedMin = (at_speed*0.75).toFixed(2);
		niv1ZonePaceMin  = convertSecToPaceStr(parseInt((3600/niv1ZoneSpeedMin)));
		niv1ZonePulsMin  = Math.round((trendVertex1*niv1ZoneSpeedMin)-trendConstant1);
		
		niv1ZoneSpeedMax = (at_speed*0.88).toFixed(2);
		niv1ZonePaceMax  = convertSecToPaceStr(parseInt(3600/niv1ZoneSpeedMax));
		niv1ZonePulsMax  = Math.round((trendVertex1*niv1ZoneSpeedMax)-trendConstant1);
			
		//niv 2 zone values
		niv2ZoneSpeedMin = (parseFloat(niv1ZoneSpeedMax)+0.01).toFixed(2);
		niv2ZonePaceMin  = convertSecToPaceStr((parseInt(3600/niv1ZoneSpeedMax)-1));
		niv2ZonePulsMin  = niv1ZonePulsMax+1
		
		niv2ZoneSpeedMax = (at_speed*0.97).toFixed(2);
		niv2ZonePaceMax  = convertSecToPaceStr(parseInt(3600/niv2ZoneSpeedMax));
		niv2ZonePulsMax  = Math.round((trendVertex1*niv2ZoneSpeedMax)-trendConstant1);
		
		//niv 3 zone values
		niv3ZoneSpeedMin = (parseFloat(niv2ZoneSpeedMax)+0.01).toFixed(2);
		niv3ZonePaceMin = convertSecToPaceStr((parseInt(3600/niv2ZoneSpeedMax)-1));
		niv3ZonePulsMin  = niv2ZonePulsMax+1;	
		
		niv3ZoneSpeedMax = (at_speed*1.03).toFixed(2);
		niv3ZonePaceMax = convertSecToPaceStr(parseInt(3600/niv3ZoneSpeedMax));
		niv3ZonePulsMax  = Math.round((trendVertex2*niv3ZoneSpeedMax)-trendConstant2);
			
		//niv 4 zone values
		niv4ZoneSpeedMin = (parseFloat(niv3ZoneSpeedMax)+0.01).toFixed(2);
		niv4ZonePaceMin = convertSecToPaceStr((parseInt(3600/niv3ZoneSpeedMax)-1));
		niv4ZonePulsMin  = niv3ZonePulsMax+1;
		
		niv4ZoneSpeedMax = (at_speed*1.25).toFixed(2);
		niv4ZonePaceMax = convertSecToPaceStr(parseInt(3600/niv4ZoneSpeedMax));
		niv4ZonePulsMax  = Math.round((trendVertex2*niv4ZoneSpeedMax)-trendConstant2);
		
		//min and max test values
		for (i=0;i<datapoints.length;i++){
			datapoint1 = datapoints[i];
			if(i==0){
				testMaxPuls = parseInt(datapoint1[0]);
				testMinPuls = parseInt(datapoint1[0]);
				testMaxSpeed = parseFloat(datapoint1[1]);
				testMinSpeed = parseFloat(datapoint1[1]);
			}//end if
			
			if (testMaxPuls<parseInt(datapoint1[0])){
				testMaxPuls = parseInt(datapoint1[0]);
			}//end if
		
			if (testMinPuls>parseInt(datapoint1[0])){
				testMinPuls = parseInt(datapoint1[0]);
			}//end if
		
			if (testMaxSpeed<parseFloat(datapoint1[1])){
				testMaxSpeed = parseFloat(datapoint1[1]);
			}//end if
		
			if (testMinSpeed>parseFloat(datapoint1[1])){
				testMinSpeed = parseFloat(datapoint1[1]);
			}//end if
				
		}//for end
		
		testMaxPace	= convertSecToPaceStr(parseInt(3600/testMaxSpeed));
		testMinPace	= convertSecToPaceStr(parseInt(3600/testMinSpeed));
			
		
		//set aerob and anaerob trend lines for extern use
		aerobTrendVertex	= trendVertex1;
		aerobTrendKonstant	= trendConstant1;
		anaerobTrendVertex	= trendVertex2;
		anaerobTrendKonstant	= trendConstant2;
		
		
		
		
			
		datapoint1 = datapoints[datapoints.length-3];
		if (at_speed>datapoint1[1]){
			//resetAll();
			alert("Could not find the AT breakpoint within the added data points");
		}//end if
			
	}else{
		alert("Not enough data. Need minimum 12 points. You have currently added " + datapoints.length + " data points");
	}//end if
}//generate end








//----------------------------------------------------------------------------------------------------------------
/**
* This function resets all test values 
* The return datatype is a Void
* @param {Void} 
* @returns {Void} 
*/
function resetAll(){
	datapoints	=[];
	at_puls 	= 0;
	at_pace 	= "";
	at_speed	= 0;
	
	aet_puls	= 0;
	aet_pace	= 0;
 	aet_speed	= "";
 	
 	niv1ZonePulsMin	= 0;
	niv1ZonePulsMax	= 0;
	
	niv1ZonePaceMin	= "";
	niv1ZonePaceMax	= "";
	
	niv1ZoneSpeedMin= 0;
	niv1ZoneSpeedMax= 0;
	
	niv2ZonePulsMin	= 0;
	niv2ZonePulsMax	= 0;
	
	niv2ZonePaceMin	= "";
	niv2ZonePaceMax	= "";
	
	niv2ZoneSpeedMin= 0;
	niv2ZoneSpeedMax= 0;
	
	niv3ZonePulsMin	= 0;
	niv3ZonePulsMax	= 0;
	
	niv3ZonePaceMin	= "";
	niv3ZonePaceMax	= "";
	
	niv3ZoneSpeedMin= 0;
	niv3ZoneSpeedMax= 0;
	
	niv4ZonePulsMin	= 0;
	niv4ZonePulsMax	= 0;
	
	niv4ZonePaceMin	= "";
	niv4ZonePaceMax	= "";
	
	niv4ZoneSpeedMin= 0;
	niv4ZoneSpeedMax= 0;
 	
 	testMaxPuls	= 0;
	testMaxPace	= "";
	testMaxSpeed	= 0;
	
	testMinPuls	= 0;
	testMinPace	= "";
	testMinSpeed	= 0;
	
	aerobTrendVertex	= 0;
	aerobTrendKonstant	= 0;
	anaerobTrendVertex	= 0;
	anaerobTrendKonstant	= 0;
	
}//resetAll end




//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the test AT pace. 
* The return datatype is a String
* @param {Void} 
* @returns {String} AT pace in min/km
*/
function getAtPace(){
	return at_pace;
}//getAtPace end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the test AT puls. 
* The return datatype is a Int
* @param {Void} 
* @returns {Int} AT puls in heartbeat per min
*/
function getAtPuls(){
	return at_puls;
}//getAtPuls end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the test AT speed. 
* The return datatype is a Float
* @param {Void} 
* @returns {Float} AT speed in km/t
*/
function getAtSpeed(){
	return at_speed;
}//getAtSpeed end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the test AeT pace. 
* The return datatype is a String
* @param {Void} 
* @returns {String} AeT pace in min/km
*/
function getAetPace(){
	return aet_pace;
}//getAetPace end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the test AeT puls. 
* The return datatype is a Int
* @param {Void} 
* @returns {Int} AeT puls in heartbeat per min
*/
function getAetPuls(){
	return aet_puls;
}//getAetPuls end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the test AeT speed. 
* The return datatype is a Float
* @param {Void} 
* @returns {Float} AeT speed in km/t
*/
function getAetSpeed(){
	return aet_speed;
}//getAetSpeed end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum pace in niveau 1 zone. 
* The return datatype is a String
* @param {Void} 
* @returns {String} The minimum pace in the niveau 1 zone in min/km
*/
function getNiv1ZonePaceMin(){
	return niv1ZonePaceMin;
}//getNiv1ZonePaceMin end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum pace in niveau 1 zone. 
* The return datatype is a String
* @param {Void} 
* @returns {String} The maximum pace in the niveau 1 zone in min/km
*/
function getNiv1ZonePaceMax(){
	return niv1ZonePaceMax;
}//getNiv1ZonePaceMax end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum puls in the niveau 1 zone. 
* The return datatype is a Int
* @param {Void} 
* @returns {Int} The minimum puls in the niveau 1 zone in heartbeat per min
*/
function getNiv1ZonePulsMin(){
	return niv1ZonePulsMin;
}//getNiv1ZonePulsMin end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum puls in the niveau 1 zone. 
* The return datatype is a Int
* @param {Void} 
* @returns {Int} The maximum puls in the niveau 1 zone in heartbeat per min
*/
function getNiv1ZonePulsMax(){
	return niv1ZonePulsMax;
}//getNiv1ZonePulsMax end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum speed in the niveau 1 zone.
* The return datatype is a String
* @param {Void} 
* @returns {Float} The minimum speed in the niveau 1 zone in km/t
*/
function getNiv1ZoneSpeedMin(){
	return niv1ZoneSpeedMin;
}//getNiv1ZoneSpeedMin end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum speed in the niveau 1 zone.
* The return datatype is a String
* @param {Void} 
* @returns {Float} The maximum speed in the niveau 1 zone in km/t
*/
function getNiv1ZoneSpeedMax(){
	return niv1ZoneSpeedMax;
}//getNiv1ZoneSpeedMax end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum pace in niveau 2 zone. 
* The return datatype is a String
* @param {Void} 
* @returns {String} The minimum pace in the niveau 2 zone in min/km
*/
function getNiv2ZonePaceMin(){
	return niv2ZonePaceMin;
}//getNiv2ZonePaceMin end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum pace in niveau 2 zone. 
* The return datatype is a String
* @param {Void} 
* @returns {String} The maximum pace in the niveau 2 zone in min/km
*/
function getNiv2ZonePaceMax(){
	return niv2ZonePaceMax;
}//getNiv2ZonePaceMax end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum puls in the niveau 2 zone. 
* The return datatype is a Int
* @param {Void} 
* @returns {Int} The minimum puls in the niveau 2 zone in heartbeat per min
*/
function getNiv2ZonePulsMin(){
	return niv2ZonePulsMin;
}//getNiv2ZonePulsMin end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum puls in the niveau 2 zone. 
* The return datatype is a Int
* @param {Void} 
* @returns {Int} The maximum puls in the niveau 2 zone in heartbeat per min
*/
function getNiv2ZonePulsMax(){
	return niv2ZonePulsMax;
}//getNiv2ZonePulsMax end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum speed in the niveau 2 zone.
* The return datatype is a String
* @param {Void} 
* @returns {Float} The minimum speed in the niveau 2 zone in km/t
*/
function getNiv2ZoneSpeedMin(){
	return niv2ZoneSpeedMin;
}//getNiv2ZoneSpeedMin end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum speed in the niveau 2 zone.
* The return datatype is a String
* @param {Void} 
* @returns {Float} The maximum speed in the niveau 2 zone in km/t
*/
function getNiv2ZoneSpeedMax(){
	return niv2ZoneSpeedMax;
}//getNiv2ZoneSpeedMax end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum pace in niveau 3 zone. 
* The return datatype is a String
* @param {Void} 
* @returns {String} The minimum pace in the niveau 3 zone in min/km
*/
function getNiv3ZonePaceMin(){
	return niv3ZonePaceMin;
}//getNiv3ZonePaceMin end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum pace in niveau 3 zone. 
* The return datatype is a String
* @param {Void} 
* @returns {String} The maximum pace in the niveau 3 zone in min/km
*/
function getNiv3ZonePaceMax(){
	return niv3ZonePaceMax;
}//getNiv3ZonePaceMax end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum puls in the niveau 3 zone. 
* The return datatype is a Int
* @param {Void} 
* @returns {Int} The minimum puls in the niveau 3 zone in heartbeat per min
*/
function getNiv3ZonePulsMin(){
	return niv3ZonePulsMin;
}//getNiv3ZonePulsMin end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum puls in the niveau 3 zone. 
* The return datatype is a Int
* @param {Void} 
* @returns {Int} The maximum puls in the niveau 3 zone in heartbeat per min
*/
function getNiv3ZonePulsMax(){
	return niv3ZonePulsMax;
}//getNiv3ZonePulsMax end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum speed in the niveau 3 zone.
* The return datatype is a String
* @param {Void} 
* @returns {Float} The minimum speed in the niveau 3 zone in km/t
*/
function getNiv3ZoneSpeedMin(){
	return niv3ZoneSpeedMin;
}//getNiv3ZoneSpeedMin end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum speed in the niveau 3 zone.
* The return datatype is a String
* @param {Void} 
* @returns {Float} The maximum speed in the niveau 3 zone in km/t
*/
function getNiv3ZoneSpeedMax(){
	return niv3ZoneSpeedMax;
}//getNiv3ZoneSpeedMax end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum pace in niveau 4 zone. 
* The return datatype is a String
* @param {Void} 
* @returns {String} The minimum pace in the niveau 4 zone in min/km
*/
function getNiv4ZonePaceMin(){
	return niv4ZonePaceMin;
}//getNiv4ZonePaceMin end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum pace in niveau 4 zone. 
* The return datatype is a String
* @param {Void} 
* @returns {String} The maximum pace in the niveau 4 zone in min/km
*/
function getNiv4ZonePaceMax(){
	return niv4ZonePaceMax;
}//getNiv4ZonePaceMax end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum puls in the niveau 4 zone. 
* The return datatype is a Int
* @param {Void} 
* @returns {Int} The minimum puls in the niveau 4 zone in heartbeat per min
*/
function getNiv4ZonePulsMin(){
	return niv4ZonePulsMin;
}//getNiv4ZonePulsMin end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum puls in the niveau 4 zone. 
* The return datatype is a Int
* @param {Void} 
* @returns {Int} The maximum puls in the niveau 4 zone in heartbeat per min
*/
function getNiv4ZonePulsMax(){
	return niv4ZonePulsMax;
}//getNiv4ZonePulsMax end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum speed in the niveau 4 zone.
* The return datatype is a String
* @param {Void} 
* @returns {Float} The minimum speed in the niveau 4 zone in km/t
*/
function getNiv4ZoneSpeedMin(){
	return niv4ZoneSpeedMin;
}//getNiv4ZoneSpeedMin end



//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum speed in the niveau 4 zone.
* The return datatype is a String
* @param {Void} 
* @returns {Float} The maximum speed in the niveau 4 zone in km/t
*/
function getNiv4ZoneSpeedMax(){
	return niv4ZoneSpeedMax;
}//getNiv4ZoneSpeedMax end


//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum speed in the added points.
* The return datatype is a Float
* @param {Void} 
* @returns {Float} The minimum speed in the added points
*/
function getTestMinSpeed(){
	return testMinSpeed;
}//getTestMinSpeed end


//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum pace in the added points.
* The return datatype is a String
* @param {Void} 
* @returns {String} The minimum pace in the added points
*/
function getTestMinPace(){
	return testMinPace;
}//getTestMinPace end


//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the minimum puls in the added points.
* The return datatype is a Integer
* @param {Void} 
* @returns {Int} The minimum puls in the added points
*/
function getTestMinPuls(){
	return testMinPuls;
}//getTestMinPuls end


//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum speed in the added points.
* The return datatype is a Float
* @param {Void} 
* @returns {Float} The maximum speed in the added points
*/
function getTestMaxSpeed(){
	return testMaxSpeed;
}//getTestMaxSpeed end


//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum pace in the added points.
* The return datatype is a String
* @param {Void} 
* @returns {String} The maximum pace in the added points
*/
function getTestMaxPace(){
	return testMaxPace;
}//getTestMaxPace end


//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the maximum puls in the added points.
* The return datatype is a Integer
* @param {Void} 
* @returns {Int} The maximum puls in the added points
*/
function getTestMaxPuls(){
	return testMaxPuls;
}//getTestMaxPuls end


//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the a pacetime format as a string. The function is for private use only
* The return datatype is a String
* @param {Int} pace_int pace as a number of sec
* @returns {String} The pace string
*/
function convertSecToPaceStr(pace_in_sek_int){
	
	var pace_min = 0;
	var pace_sec = 0;
	
	pace_min = parseInt(pace_in_sek_int/60);
	pace_sec = parseInt(pace_in_sek_int-(60*pace_min));
	
	if(pace_sec<10){
		return pace_min + ":0" +pace_sec ;
	}else{
		return pace_min + ":" +pace_sec ;
	}//end if/else
	
		
}//convertSecToPaceStr end


//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the a puls on the aerob trendline. Based on the a speed value and the trendline formula can the puls be calculated
* The return datatype is a Int
* @param {Float} speed_float speed as a value in km/t
* @returns {Int} The puls Int
*/
function getAerobTrendlinePuls(speed_float){
	return ((aerobTrendVertex*speed_float)-aerobTrendKonstant);

}//getAerobTrendlinePuls end


//----------------------------------------------------------------------------------------------------------------
/**
* This function returns the a puls on the anaerob trendline. Based on the a speed value and the trendline formula can the puls be calculated
* The return datatype is a Int
* @param {Float} speed_float speed as a value in km/t
* @returns {Int} The puls Int
*/
function getAnaerobTrendlinePuls(speed_float){
	return ((anaerobTrendVertex*speed_float)-anaerobTrendKonstant);

}//getAnaerobTrendlinePuls end
