$(document).ready(function() {
	
	$('#home-car').hover(
      function () {
        $('#home-car #bubble').show();
      }, 
      function () {
      	$('#home-car #bubble').hide();
      }
    );
	
	$(".section-list-item h2 a").bigTarget({
		hoverClass: 'targethover',
		clickZone : 'div:eq(0)'
	});
	
	$('#calculate').click(function(){
		var salary = $("#employee-salary").val();
		var numberemployees = $("#number-employees").val();
		var overhead = calcOverhead(salary);
		var employeecost = calcEmployeeCost(overhead,salary);
		var staffcost = calcStaffCost(numberemployees,employeecost);
		var downtimecost = calcDowntimeCost(staffcost);
		var pcdowntime = 2;
		var serverdowntime = 3.5;
		var yearlycost = calcYearlyCost(numberemployees,downtimecost,pcdowntime,serverdowntime);
		var pclifetime = 3;
		var lifetimecost = calcLifetimeCost(pclifetime,yearlycost);
		var pccost = calcPCCost(lifetimecost,numberemployees);
	
		$(".overhead").html(overhead).formatCurrency({roundToDecimalPlace:0});
		$(".employee-cost").html(employeecost).formatCurrency({roundToDecimalPlace:0});
		$(".staff-cost").html(staffcost).formatCurrency({roundToDecimalPlace:0});
		$(".downtime-cost").html(downtimecost).formatCurrency({roundToDecimalPlace:0});
		$(".yearly-cost").html(yearlycost).formatCurrency({roundToDecimalPlace:0});
		$(".lifetime-cost").html(lifetimecost).formatCurrency({roundToDecimalPlace:0});
		$(".pc-cost").html(pccost).formatCurrency({roundToDecimalPlace:0});
		
		return false;	
	});

});

function calcOverhead(salary){
	var overhead = salary * 0.4;
	return overhead;
}
function calcEmployeeCost(o,s){
	var employeecost = (eval(o) + eval(s)) / 52;
	return employeecost;
}
function calcStaffCost(n,e){
	var staffcost = eval(n) * eval(e) ;
	return staffcost;
}
function calcDowntimeCost(s){
	var downtimecost = eval(s) * 1 / 37.5 ;
	return downtimecost;
}
function calcYearlyCost(n,d,p,s){
	var yearlycost = eval(d) * (12 * eval(p) + eval(s) * eval(n));
	return yearlycost;
}
function calcLifetimeCost(p,y){
	var lifetimecost = eval(p) * eval(y);
	return lifetimecost;
}
function calcPCCost(l,n){
	var pccost = eval(l) / eval(n);
	return pccost;
}
