/*
 * Hosted Exchange Quick Quote Generator
 * Copyright 2011, Cobweb Solutions Ltd
 * v 1.1
 */

 
 /* Calculate on the front page */
function licence(){ 
	if (document.getElementById("outlook").checked == true) {
	document.getElementById("out").value = "1.49";
	}
	else if (document.getElementById("outlook").checked == false) {
	document.getElementById("out").value = "0.00";
	}	 
}

function costs_year(){
	if (document.getElementById("year").checked == true && document.getElementById("support").checked == true)  {
	document.getElementById("years").value = 4.98; 
	}
	else if (document.getElementById("year").checked == false && document.getElementById("support").checked == true) {
	document.getElementById("years").value = 6.28; 
	}
	else if (document.getElementById("year").checked == true && document.getElementById("support").checked == false) {
	document.getElementById("years").value = 3.29; 
	}
	else if (document.getElementById("year").checked == false && document.getElementById("support").checked == false) {
	document.getElementById("years").value = 4.29; 
	}
}

function calc_cost(){	
	var amount = document.getElementById("amount").value;
	var years_final = document.getElementById("years").value;
	var out_final = document.getElementById("out").value;
	var tot_cost = parseFloat(years_final)+parseFloat(out_final);
	var total_cost =  amount * tot_cost;
	var final_cost = (total_cost).toFixed(2);
	document.getElementById("tcost").value = final_cost;
	document.getElementById("tot_cost").value = tot_cost.toFixed(2);
		if (document.getElementById("amount").value >= 101) {
		document.getElementById("tcost").value= "CALL";
		alert ("For our best Enterprise pricing, please call 0845 207 0708");
		}
		else if (document.getElementById("amount").value < 10) {
		document.getElementById("tcost").value = "SMB";	
		var smb = confirm("Standalone Hosted Exchange is not available for under 10 users." + "\n\n" + "Would you like to see our Hosted Exchange Suite for small business?");
			if (smb==true) {
			window.location = 'http://www.hostedexchange.co.uk/small_business.aspx';	
			}
		}	
		else if (document.getElementById("tcost").value != 0) {
		$("#total").show("slow");
		document.getElementById("CalculatePrice").value = "Recalculate Quote";
		}
}

/* SMB Suite specific Calculator */
function costs_yearSmb(){
	if (document.getElementById("yearSmb").checked == true)  {
	document.getElementById("yearsSmb").value = 4.99; 
	}
	else if (document.getElementById("yearSmb").checked == false) {
	document.getElementById("yearsSmb").value = 5.99; 
	}
}	
 
function calc_cost_smb(){	
	var users = document.getElementById("users").value;
	var yearsSmb_final = document.getElementById("yearsSmb").value;
	var tot_cost_smb = parseFloat(yearsSmb_final);
	var total_cost_smb =  users * tot_cost_smb;
	var final_cost_smb = (total_cost_smb).toFixed(2);
	document.getElementById("tcost").value = final_cost_smb;
	
	if (document.getElementById("users").value > 50) {
	document.getElementById("tcost").value = "N/A";	
	var smb = confirm("The Small Business Suite is only available for up to 50 users." + "\n\n" + "Would you like to see our Hosted Exchange Suite for Enterprise business?");
	if (smb==true) {
	window.location = 'http://www.cobweb.com/hosted-services/hosted-exchange.aspx';	
	}
}
	else if (document.getElementById("yearSmb").checked == true && document.getElementById("users").value < 5) {
	document.getElementById("tcost").value = "N/A";		
	alert ('Please note, a three year term requires a minimum of 5 users');
	}
	
	else if (document.getElementById("tcost").value != 0) {
	$("#total").show("slow");
	document.getElementById("CalculatePriceSmb").value = "Recalculate Quote";
	}
}

/* Show Price - all screens */
$("CalculatePrice").click(function () {
    $("p").show("slow");
    });
