var inputCurrency;
var inputEmployees;
var inputEmployeeCost;
var inputEmployeeTime;
var validCurrency;
var validEmployees;
var validEmployeeCost;
var validEmployeeTime;
var roiProduct;
var roiAction;
var roiCurrency;
var roiSavingMinute;
var roiSavingDay;
var roiSavingWeek;
var roiSavingYear;
var roiUserLicenseCost;
var roiTotalLicenseCost;
var roiUserLicense;
var roiPayForItself;
var roiShowResult;
var roiNote;

function isNumeric(input) {
   return (input - 0) == input && input.length > 0;
}

function addCommas(nStr) {
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function formatPrice(thePrice, decimal) {
	if(decimal==false) {
		return addCommas(Math.round(thePrice));
	}
	else {
		return addCommas(Math.round(thePrice*100)/100);
	}
}

function roiFieldChange() {
	var theCurrent;
	theCurrent = $('#roiNote').html();
	
	if(theCurrent!="It looks like you've made some changes, don't forget to re-calculate your ROI.") {
		// Notes
		$('#roiNote').fadeOut('fast', function() {
			$('#roiNote').html("It looks like you've made some changes, don't forget to re-calculate your ROI.");
			$('#roiNote').fadeIn('fast');
		});
	}
}

function formatDays(theDays) {
	theDays = Math.ceil(theDays);
	if(theDays==1) { return "less than a day"; }
	else if(theDays<7) { return "less than " + theDays + " days"; }
	else if(theDays<14) { return "less than 1 week"; }
	else if(theDays<21) { return "less than 2 weeks"; }
	else if(theDays<28) { return "less than 3 weeks"; }
	else if(theDays<35) { return "less than a month"; }
	else if(theDays<65) { return "less than 2 months"; }
	else if(theDays<95) { return "less than 3 months"; }
	else if(theDays<125) { return "less than 4 months"; }
	else if(theDays<155) { return "less than 5 months"; }
	else if(theDays<185) { return "less than 6 months"; }
	else if(theDays<365) { return "less than a year"; }
	else if(theDays<730) { return "less than 2 years"; }
	else if(theDays<1095) { return "less than 3 years"; }
	else if(theDays<1460) { return "less than 4 years"; }
	else if(theDays<1825) { return "less than 5 years"; }
	else { return "more than 5 years"; }
	
}

function roiChangeCurrency() {
	inputCurrency = $('#inputCurrency').val();
	if(inputCurrency=="GBP") { roiCurrency = "&pound;"; }
	else if(inputCurrency=="EUR") { roiCurrency = "&euro;"; }
	else if(inputCurrency=="USD") { roiCurrency = "&#36;"; }
	$('#roiCurrency1').html(roiCurrency);
}

function roiCalculate() {
	// Reset validation
	validCurrency = null;
	validEmployees = null;
	validEmployeeCost = null;
	validEmployeeTime = null;
	roiShowResult = false;
	roiNote = "";
	// Get fields
	roiProduct = $('#roitype').val();
	inputCurrency = $('#inputCurrency').val();
	inputEmployees = $('#inputEmployees').val();
	inputEmployeeCost = $('#inputEmployeeCost').val();
	inputEmployeeTime = $('#inputEmployeeTime').val();
	// Check fields are valid
	if(inputCurrency=="GBP" || inputCurrency=="EUR" || inputCurrency=="USD") { validCurrency = true; }
	if(isNumeric(inputEmployees) && inputEmployees>0/* && inputEmployees<2000*/) { validEmployees = true; }
	if(isNumeric(inputEmployeeCost)) { validEmployeeCost = true; }
	if(isNumeric(inputEmployeeTime)) { validEmployeeTime = true; }
	// If everything is valid
	if(validCurrency==true && validEmployees==true && validEmployeeCost==true && validEmployeeTime==true) {
		// Calculation - currency
		if(inputCurrency=="GBP") { roiCurrency = "&pound;"; }
		else if(inputCurrency=="EUR") { roiCurrency = "&euro;"; }
		else if(inputCurrency=="USD") { roiCurrency = "&#36;"; }
		// Calculation - saving day
		roiSavingDay = inputEmployees * inputEmployeeCost * inputEmployeeTime;
		// Calculation - saving week
		roiSavingWeek = roiSavingDay * 5;
		// Calculation - saving year
		roiSavingYear = roiSavingWeek * 50;
		// Calculation - saving 60 secs
		roiSavingMinute = roiSavingDay / (7.5 * 60);
		// Calculation - license cost
		// InterGate Web Security 'In the Cloud'
		if(roiProduct=="InterGate Web Security 'In the Cloud'") {
			if(inputEmployees<99) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 2.3 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (2.3 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (2.3 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "10 to 99";
				roiShowResult = true;
			}
			else if(inputEmployees<499) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 1.9 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (1.9 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (1.9 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "100 to 499";
				roiShowResult = true;
			}
			else if(inputEmployees<2499) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 1.7 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (1.7 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (1.7 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "500 to 2,499";
				roiShowResult = true;
			}
			else if(inputEmployees<4999) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 1.6 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (1.6 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (1.6 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "2,500 to 4,999";
				roiShowResult = true;
			}
			else if(inputEmployees<9999) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 1.5 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (1.5 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (1.5 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "5,000 to 9,999";
				roiShowResult = true;
			}
			else if(inputEmployees<19999) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 1.4 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (1.4 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (1.4 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "10,000 to 19,999";
				roiShowResult = true;
			}
			else {
				if(inputCurrency=="GBP") { roiUserLicenseCost = 1.3 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (1.3 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (1.3 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "20,000+";
				roiShowResult = true;
			}
			// Minimum order price is £480
			if(inputCurrency=="GBP" && roiTotalLicenseCost<480) { roiTotalLicenseCost = 480; }
			else if(inputCurrency=="EUR" && roiTotalLicenseCost<(480 / 1.1)) {roiTotalLicenseCost = (480 / 1.1); }
			else if(inputCurrency=="USD" && roiTotalLicenseCost<(480 / 1.5)) { roiTotalLicenseCost = (480 / 1.5); }
		}
		// InterGate Web Security 'On Premise' & Intergate App Blocker
		else if(roiProduct=="InterGate Web Security 'On Premise'" || roiProduct=="InterGate App Blocker") {
			if(inputEmployees<11) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 304; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 329; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 420; }
				roiUserLicense = "10";
				roiShowResult = true;
			}
			else if(inputEmployees<26) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 544; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 590; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 753; }
				roiUserLicense = "25";
				roiShowResult = true;
			}
			else if(inputEmployees<51) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 897; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 973; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 1241; }
				roiUserLicense = "50";
				roiShowResult = true;
			}
			else if(inputEmployees<76) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 1221; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 1324; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 1689; }
				roiUserLicense = "75";
				roiShowResult = true;
			}
			else if(inputEmployees<101) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 1528; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 1657; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 2113; }
				roiUserLicense = "100";
				roiShowResult = true;
			}
			else if(inputEmployees<151) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 2108; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 2286; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 2915; }
				roiUserLicense = "150";
				roiShowResult = true;
			}
			else if(inputEmployees<201) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 2660; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 2885; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 3679; }
				roiUserLicense = "200";
				roiShowResult = true;
			}
			else if(inputEmployees<251) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 3193; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 3462; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 4415; }
				roiUserLicense = "250";
				roiShowResult = true;
			}
			else if(inputEmployees<301) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 3711; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 4024; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 5131; }
				roiUserLicense = "300";
				roiShowResult = true;
			}
			else if(inputEmployees<401) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 4714; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 5111; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 6518; }
				roiUserLicense = "400";
				roiShowResult = true;
			}
			else if(inputEmployees<501) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 5684; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 6163; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 7859; }
				roiUserLicense = "500";
				roiShowResult = true;
			}
			else if(inputEmployees<601) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 6630; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 7189; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 9167; }
				roiUserLicense = "600";
				roiShowResult = true;
			}
			else if(inputEmployees<701) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 7556; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 8193; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 10447; }
				roiUserLicense = "700";
				roiShowResult = true;
			}
			else if(inputEmployees<801) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 8466; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 9179; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 11705; }
				roiUserLicense = "800";
				roiShowResult = true;
			}
			else if(inputEmployees<901) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 9362; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 10151; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 12944; }
				roiUserLicense = "900";
				roiShowResult = true;
			}
			else if(inputEmployees<1001) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 10247; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 11110; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 14167; }
				roiUserLicense = "1,000";
				roiShowResult = true;
			}
			else if(inputEmployees<1251) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 12415; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 13461; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 17164; }
				roiUserLicense = "1,250";
				roiShowResult = true;
			}
			else if(inputEmployees<1501) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 14534; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 15758; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 20093; }
				roiUserLicense = "1,500";
				roiShowResult = true;
			}
			else if(inputEmployees<1751) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 16613; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 18012; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 22967; }
				roiUserLicense = "1,750";
				roiShowResult = true;
			}
			else if(inputEmployees<2001) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 18659; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 20230; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 25795; }
				roiUserLicense = "2,000";
				roiShowResult = true;
			}
			else if(inputEmployees<2251) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 20678; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 22149; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 28585; }
				roiUserLicense = "2,250";
				roiShowResult = true;
			}
			else if(inputEmployees<2501) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 22672; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 24581; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 31342; }
				roiUserLicense = "2,500";
				roiShowResult = true;
			}
			else if(inputEmployees<3001) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 26600; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 28839; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 36771; }
				roiUserLicense = "3,000";
				roiShowResult = true;
			}
			else if(inputEmployees<4001) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 34263; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 37146; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 47362; }
				roiUserLicense = "4,000";
				roiShowResult = true;
			}
			else if(inputEmployees<5001) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 41732; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 45242; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 57685; }
				roiUserLicense = "5,000";
				roiShowResult = true;
			}
			else if(inputEmployees<6001) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 49052; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 53178; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 67802; }
				roiUserLicense = "6,000";
				roiShowResult = true;
			}
			else if(inputEmployees<7001) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 56254; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 60985; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 77756; }
				roiUserLicense = "7,000";
				roiShowResult = true;
			}
			else if(inputEmployees<8001) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 63358; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 68685; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 87573; }
				roiUserLicense = "8,000";
				roiShowResult = true;
			}
			else if(inputEmployees<9001) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 70378; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 76295; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 97275; }
				roiUserLicense = "9,000";
				roiShowResult = true;
			}
			else if(inputEmployees<100001) { 
				if(inputCurrency=="GBP") { roiTotalLicenseCost = 77325; }
				else if(inputCurrency=="EUR") { roiTotalLicenseCost = 83825; }
				else if(inputCurrency=="USD") { roiTotalLicenseCost = 106875; }
				roiUserLicense = "10,000";
				roiShowResult = true;
			}
			else {
				roiShowResult = false;
				roiNote = "Please contact us for a custom quote if you require more than 100,000 users for " + roiProduct + ".";
			}
		}
		// InterGate Email Security
		else if(roiProduct=="InterGate Email Security") {
			if(inputEmployees<99) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 2 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (2 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (2 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "10 to 99";
				roiShowResult = true;
			}
			else if(inputEmployees<499) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 1.75 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (1.75 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (1.75 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "100 to 499";
				roiShowResult = true;
			}
			else if(inputEmployees<2499) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 1.5 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (1.5 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (1.5 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "500 to 2,499";
				roiShowResult = true;
			}
			else if(inputEmployees<4999) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 1.25 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (1.25 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (1.25 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "2,500 to 4,999";
				roiShowResult = true;
			}
			else if(inputEmployees<9999) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 1 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (1 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (1 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "5,000 to 9,999";
				roiShowResult = true;
			}
			else if(inputEmployees<19999) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = .9 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (.9 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (.9 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "10,000 to 19,999";
				roiShowResult = true;
			}
			else {
				if(inputCurrency=="GBP") { roiUserLicenseCost = .9 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (.9 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (.9 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "20,000+";
				roiShowResult = true;
			}
			// Minimum order price is £480
			if(inputCurrency=="GBP" && roiTotalLicenseCost<480) { roiTotalLicenseCost = 480; }
			else if(inputCurrency=="EUR" && roiTotalLicenseCost<(480 / 1.1)) {roiTotalLicenseCost = (480 / 1.1); }
			else if(inputCurrency=="USD" && roiTotalLicenseCost<(480 / 1.5)) { roiTotalLicenseCost = (480 / 1.5); }
		}
		// Webroot Email Archiving
		else if(roiProduct=="Webroot Email Archiving") {
			if(inputEmployees<99) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 3.6 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (3.6 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (3.6 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "10 to 99";
				roiShowResult = true;
			}
			else if(inputEmployees<499) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 3.3 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (3.3 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (3.3 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "100 to 499";
				roiShowResult = true;
			}
			else if(inputEmployees<2499) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 3 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (3 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (3 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "500 to 2,499";
				roiShowResult = true;
			}
			else if(inputEmployees<4999) { 
				if(inputCurrency=="GBP") { roiUserLicenseCost = 2.75 * 12; }
				else if(inputCurrency=="EUR") { roiUserLicenseCost = (2.75 / 1.1) * 12; }
				else if(inputCurrency=="USD") { roiUserLicenseCost = (2.75 / 1.5) * 12; }
				roiTotalLicenseCost = roiUserLicenseCost * inputEmployees;
				roiUserLicense = "2,500 to 4,999";
				roiShowResult = true;
			}
			else {
				roiNote = "Please contact us for a custom quote if you require more than 4,999 users for " + roiProduct + ".";
				roiShowResult = false;
			}
			// Minimum order price is £480
			if(inputCurrency=="GBP" && roiTotalLicenseCost<480) { roiTotalLicenseCost = 480; }
			else if(inputCurrency=="EUR" && roiTotalLicenseCost<(480 / 1.1)) {roiTotalLicenseCost = (480 / 1.1); }
			else if(inputCurrency=="USD" && roiTotalLicenseCost<(480 / 1.5)) { roiTotalLicenseCost = (480 / 1.5); }
		}
		// Unknown
		else {
			roiShowResult = false;
		}
		
		// Notes
		$('#roiNote').fadeOut('fast', function() { 
			if(roiNote.length>0) {
				$('#roiNote').html(roiNote);
				$('#roiNote').fadeIn('fast');
			}
			else {
				$('#roiNote').html("&nbsp;");
			}
		});
		
		// If ok to show the result
		if(roiShowResult==true) {
		
			// Calculation - license cost
			roiPayForItself = roiSavingDay / roiTotalLicenseCost;
			
			// Hide Old Div's	
			$('#roinotewrap').slideUp('slow', function() { 
				$('#roifailwrap').slideUp('slow', function() { 
					// Update the content
					$('#roiCurrency2').html(roiCurrency);
					$('#roiCurrency3').html(roiCurrency);
					$('#roiCurrency4').html(roiCurrency);
					$('#roiCurrency5').html(roiCurrency);
					$('#roiProduct1').html(roiProduct);
					$('#roiProduct2').html(roiProduct);
					$('#roiUserLicense1').html(roiUserLicense);
					$('#roiPayForItself1').html(formatDays(roiPayForItself));
					$('#roiSavingDay1').html(formatPrice(roiSavingDay, false));
					$('#roiSavingWeek1').html(formatPrice(roiSavingWeek, false));
					$('#roiSavingYear1').html(formatPrice(roiSavingYear, false));
					$('#roiSavingMinute1').html(formatPrice(roiSavingMinute, true));
					// Show the content
					$('#roinotewrap').slideDown('slow');
				}); 
			});
		}
		// if not ok to show the result
		else {
			$('#roinotewrap').slideUp('slow', function() { $('#roifailwrap').slideUp('slow', function() { $('#roifailwrap').slideDown('slow'); } ); } );
		}		
	}
	// If something isn't valid
	else {
		// Notes
		$('#roiNote').fadeOut('fast', function() { 
			if(roiNote.length>0) {
				$('#roiNote').html(roiNote);
				$('#roiNote').fadeIn('fast');
			}
			else {
				$('#roiNote').html("&nbsp;");
			}
		});
		// Show the content
		$('#roinotewrap').slideUp('slow', function() { 
			$('#roifailwrap').slideUp('slow', function() { 
				$('#roifailmsg').html('You need to complete all fields before we can calculate your ROI.');
				$('#roifailwrap').slideDown('slow'); 
			});
		});
	}
}
