
function calcTOR()
{
	var avgnumemp, numempleav, tor;
	avgnumemp = Math.round(document.getElementById('avgNumEmp').value);
	numempleav = Math.round(document.getElementById('totNumEmp').value);
	tor = parseInt((numempleav/avgnumemp) * 100);
	if (isNaN(tor))
		tor = 0;
	document.getElementById('tor').value = tor;
}

function roundUp()
{
	var dv;
	dv = document.getElementById('annualSalary').value;
	var alphack = /[^0-9]{1}/;
	var charck = dv.substr(0,1);
	var result = charck.match(alphack);
	if (result != null)
	{
		dv = dv.substr(1);
	}
	dv = parseInt(dv.replace(',',''));
	document.getElementById('annualSalary').value = Math.round(dv);
	document.getElementById('benefitsPercentage').value = Math.round(document.getElementById('benefitsPercentage').value*100)/100;
	document.getElementById('expectedVacancy').value = Math.round(document.getElementById('expectedVacancy').value);
}

	  
function calcSavings()
{
	var dv, eev, av, bv, cv, fv, iv, jv, kv, nv, yv, tot1, tot2, ttype;
    // wages and benefits saved
    av = (document.getElementById('avgNumEmp').value * 1);
    bv = (document.getElementById('totNumEmp').value * 1);
    dv = (document.getElementById('annualSalary').value * 1);
    eev = (document.getElementById('benefitsPercentage').value*1/100);
	fv = (document.getElementById('expectedVacancy').value * 1);		
	
	var iv = Math.round(((dv+(dv*eev))/365) * fv * 0.15 + ((dv+(dv*eev))*.01));

	var jv =  Math.round(((dv+(dv*eev))/365)*fv*0.15);

	var kv = Math.round((dv+(dv*eev))*0.07);	
		
	totg = iv + jv + kv;
	if (totg.toString().length > 3){
		totStr = totg.toString();
		totg = totStr.slice(0,-3) + "," + totStr.slice(-3);
		}
			 
	toth = (iv + jv + kv)*bv;
	if (toth.toString().length > 3){
		totStr = toth.toString();
		var front = totStr.slice(0,-3);
		if (front.length > 3){
			var front2 = front.slice(0,-3) + ",";
			var front1 = front.slice(-3) + ",";
			}
		else {
			var front2 = '';
			var front1 = front + ",";
		}
	
	toth = front2 + front1 + totStr.slice(-3);
	}
			
	document.getElementById('minEstTurnover').value	= totg; 
	document.getElementById('MinEstAnnualTurnover').value= toth;
}



