var fresherCTC; 
var batchSize;
var trainingPeriod;
var TrainingCost;
var trainerCTC;
var managerCost;
var infraCost;
var totalCost;
var costPerTrainee;
/*var digisCost;*/
var savingAmt;
var savingsPercentage;
var result;

function init(){
	fresherCTC = document.getElementById("fresherCTC").value;
	batchSize = document.getElementById("batchSize").value;
	trainingPeriod = document.getElementById("trainingPeriod").value;
	TrainingCost = document.getElementById("TrainingCost").value;
	trainerCTC = document.getElementById("trainerCTC").value;
	managerCost = document.getElementById("managerCost").value;	
	infraCost = document.getElementById("infraCost").value;
	totalCost = document.getElementById("totalCost").value;
	costPerTrainee = document.getElementById("costPerTrainee").value;
	/*digisCost = document.getElementById("digisCost").value;*/

	calc();
	validate();
}

function calc(){
	TrainingCost = (fresherCTC * batchSize * trainingPeriod) / 12;
	document.getElementById("TrainingCost").value = TrainingCost;

	totalCost = parseInt(TrainingCost) + parseInt(trainerCTC) + parseInt(managerCost) + parseInt(infraCost);
	document.getElementById("totalCost").value = totalCost;

	costPerTrainee = totalCost / batchSize;
	document.getElementById("costPerTrainee").value = Math.round(costPerTrainee);

	/*savingAmt = Math.round(costPerTrainee - digisCost);

	savingsPercentage = Math.round(100-((digisCost/costPerTrainee)*100));*/
}

function defaultResult(){
	/*document.getElementById("result").innerHTML="You Save \<span\> RS.25333\<\/span\>, that is \<span\>50\% \<\/span\> ";
	document.getElementById("result").innerHTML += " of the cost by outsourcing training to us!!!";*/
	document.getElementById("result").innerHTML="Save upto \<span\>50\% \<\/span\>of this cost by outsourcing the training to us \!\!\!";
	}

function validate(){
	if ( isNaN(costPerTrainee))
	{
		document.getElementById("result").innerHTML=" \<span\> Oops! I accept only numbers... \<span\>";
	}
	else if(costPerTrainee < 0 )
	{
		document.getElementById("result").innerHTML = " \<span\> Education is not that easy today... Change the numbers, please\! \<span\>";

	}
	else
	{
		/*document.getElementById("result").innerHTML="You Save \<span\> RS."+ savingAmt +"\<\/span\>, that is \<span\>"+ savingsPercentage +"\% \<\/span\>";
		document.getElementById("result").innerHTML += " of the cost by outsourcing training to us!!!";*/
		document.getElementById("result").innerHTML="Save upto \<span\>50\% \<\/span\>of this cost by outsourcing the training to us \!\!\!";
	}
}