var totalamt;
function calculate(){
	$("#howmuch").hide();
	var currency = "£";
	 
	var solo = 6;//5
	var joint = 6;//4
	var income1 = stripCurrency(document.mortgage_calculator.income1.value);
	var income2 = stripCurrency(document.mortgage_calculator.income2.value);
	if(isNaN(income1) || isNaN(income2) || (income1 == "" && income2 == "") ){
		alert("Please enter a correct number");
	}else{
		if(income2 == 0 || income2 == ""){
			totalamt = income1 * solo;
		}else{
			totalamt1 = income1 * solo;
			totalamt = (parseInt(income1)+parseInt(income2)) * joint;
			if(totalamt1 > totalamt){
				totalamt = totalamt1;
			}
		}
		// send to global var
		AH.Mortgage.loan_amount = totalamt;
		// put data into JSON for cookie
		var m = new Object();
		m.loan = totalamt;
		mortgage_cookie_value = $.json.encode(m);
		Set_Cookie("mortgage",mortgage_cookie_value,expires,'/');
		//Set_Cookie("ahloanamt",formatCurrency(totalamt),expires,'/');
		// auto submits back to previous page and displays result there (usually deals)
		if(document.location.href.indexOf('#') != -1){
			history.back();
		}else{
			$("#howmuch").show('slow');
			//document.getElementById("howmuch").style.display = "block";
			document.getElementById("borrow_output").innerHTML = "You could borrow up to &pound;" + formatCurrency(totalamt);

			//document.mortgage_calculator.loanamount.value = formatCurrency(totalamt);
		}
	}
}