function validateForm() {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var company_name = document.getElementById('company_name');
	var contact_name = document.getElementById('contact_name');
	var phone = document.getElementById('phone');
	var mail = document.getElementById('mail');
	
	if (company_name.value=='') {
		company_name.focus();
		alert("Please, enter your company name.");
		return false;
	} else if (contact_name.value=='') {
		contact_name.focus();
		alert("Please, enter your contact name.");
		return false;
	} else if (phone.value=='') {
		phone.focus();
		alert("Please, enter your phone number.");
		return false;
	} else if (mail.value != "" && reg.test(mail.value) == false) {
		alert("Please, enter a valid e-mail.");
		return false;
	} else {
		return true;
	}
}

var total_roll = 0;
var total_staff = 0;

$('.payroll').keyup(function () {
	var rolls = $('.payroll');
	total_roll = 0;
	for (var i=0; i < rolls.length; i++) {
		var roll = rolls[i];
		if (!isNaN(parseInt($(roll).val()))) {
			total_roll += parseInt($(roll).val());
		}
	};
	$('.total_roll').html('$' + total_roll);
});

$('.employees').keyup(function () {
	var staff = $('.employees');
	total_staff = 0;
	for (var i=0; i < staff.length; i++) {
		var person = staff[i];
		if (!isNaN(parseInt($(person).val()))) {
			total_staff += parseInt($(person).val());
		}
	};
	$('.total_staff').html(total_staff);
});
