

function processform()
{
 
  if (document.frmCalculator.inpTotalExpenditure.value < 300) {
    alert("Please Enter a Reasonable Expenditure Value (£300 minium)")
    document.frmCalculator.inpTotalExpenditure.focus()
    return false
  }
  
  
    if (document.frmCalculator.inpTotalIncome.value < 100) {
    alert("Please Enter a higher monthly income Value (£100 minium)")
    document.frmCalculator.inpTotalIncome.focus()
    return false 
  }
  
document.frmCalculator.submit()
}



function loadDefaults()
{
	
	var domestic = document.frmCalculator.domestic.value;
	var kids = document.frmCalculator.kids.value;
 
	switch(domestic)
	{
		case "single":
		document.frmCalculator.inpHousekeeping.value = 150 + (kids * 66);
		document.frmCalculator.inpClothing.value = 20 + (kids * 20);
		document.frmCalculator.inpHouseholdMaintenance.value = 25 + (kids * 10);
		document.frmCalculator.inpSocial.value = 16 + (kids * 11);
		document.frmCalculator.inpHairdressing.value = 10 + (kids * 5);
		document.frmCalculator.inpTelephone.value = 50 + (kids * 6);
		break;

		


		case "married":
		document.frmCalculator.inpHousekeeping.value = 250 + (kids * 66);
		document.frmCalculator.inpClothing.value = 33 + (kids * 20);
		document.frmCalculator.inpHouseholdMaintenance.value = 35 + (kids * 10);
		document.frmCalculator.inpSocial.value = 21 + (kids * 11);
		document.frmCalculator.inpHairdressing.value = 18 + (kids * 5);
		document.frmCalculator.inpTelephone.value = 65 + (kids * 6);
		break;


	}
	
 
	document.frmCalculator.inpSchoolMeals.value = (kids * 28);
	document.frmCalculator.inpSchoolTrips.value = (kids * 5);
	document.frmCalculator.inpPocketMoney.value = (kids * 10);
	
	
	
	
	processInAndOut('expenditure');
	
}

  
function incomeTotalChanged(item)
{
	if (isNaN(item.value) || item.value < 0)
	{
		item.value = "";
	}
	
	var fltTotalIncome = item.value;
	var fltTotalExpenditure = document.frmCalculator.inpTotalExpenditure.value;

	
	var fltDisposableIncome = parseFloat(fltTotalIncome) - parseFloat(fltTotalExpenditure);
	
	
	document.frmCalculator.hidDisposableIncome.value = formatCurrency2(fltDisposableIncome);
	
}


function expenditureTotalChanged(item)
{
	if (isNaN(item.value) || item.value < 0)
	{
		item.value = "";
	}
	
	var fltTotalExpenditure = item.value;
	
	
	
	var fltTotalIncome = document.frmCalculator.inpTotalIncome.value;
	
	var fltDisposableIncome = parseFloat(fltTotalIncome) - parseFloat(fltTotalExpenditure);
	
	document.frmCalculator.hidDisposableIncome.value = formatCurrency2(fltDisposableIncome);
	
}




<!--





function incomeChanged(item)
{
	if (isNaN(item.value) || item.value < 0)
	{
		item.value = "";
	}
	processInAndOut('income');
}


function propChanged(item)
{
	if (isNaN(item.value) || item.value < 0)
	{
		item.value = "";
	}
	else
	{
		document.frmCalculator.equity.value = 
		document.frmCalculator.proValue.value - document.frmCalculator.proMortgage.value - document.frmCalculator.proLoan.value;
	}
}




function expenditureChanged(item)
{
	if (isNaN(item.value) || item.value < 0)
	{
		item.value = "";
	}
	processInAndOut('expenditure');
}

function creditorNameChanged(item)
{
	var theID = "hid_" + item.name;
	eval('document.frmCalculator.' + theID).value = item.value;
}

function amountOwedChanged(item)
{
	if (isNaN(item.value))
	{
		item.value = "";
	}
	
	var theID = "hid_" + item.name;
	eval('document.frmCalculator.' + theID).value = item.value;
	
	processAmountOwed();
}

function monthlyPaymentChanged(item)
{
	if (isNaN(item.value))
	{
		item.value = "";
	}
	
	var theID = "hid_" + item.name;
	eval('document.frmCalculator.' + theID).value = item.value;
	
	processMonthlyPayments();
}

function processInAndOut(direction)
{
	var fltTotalIncome = getTotalIncome();
	var fltTotalExpenditure = getTotalExpenditure();
	var fltDisposableIncome = parseFloat(fltTotalIncome) - parseFloat(fltTotalExpenditure);

	if (direction == "income")
	{	
		document.frmCalculator.inpTotalIncome.value = fltTotalIncome;
		document.frmCalculator.net_income.value = fltTotalIncome;
	}
	else
	{
		document.frmCalculator.inpTotalExpenditure.value = fltTotalExpenditure;
		document.frmCalculator.net_outgoings.value = fltTotalExpenditure;

	}
	document.frmCalculator.hidDisposableIncome.value = formatCurrency2(fltDisposableIncome);
	disposableIncomeDiv.innerHTML = formatCurrency(fltDisposableIncome);
}

function processAmountOwed()
{
	var fltTotalAmountOwed = getTotalOwed();

	document.frmCalculator.inpTotalDebts.value = formatCurrency2(fltTotalAmountOwed);
	totalOwedCreditorsDiv.innerHTML = formatCurrency(fltTotalAmountOwed);
	
	document.frmCalculator.total_debt.value = fltTotalAmountOwed;
}

function processMonthlyPayments()
{
	var fltMonthlyPayments = getTotalMonthlyPayments();

	document.frmCalculator.inpTotalPayments.value = formatCurrency2(fltMonthlyPayments);
	monthlyPaymentsCreditorsDiv.innerHTML = formatCurrency(fltMonthlyPayments);
}

//generic donkey functions (adding and formatting):

function getTotalIncome()
{
	var fltTotalIncome = parseFloat("0" + document.frmCalculator.inpTotalIncome.value);
	
	
	return fltTotalIncome;
}


function resetIncomeFields()
{
	var fltYourTakeHomePay = 0;
	document.frmCalculator.inpYourTakeHomePay.value ="";
	
	var fltPartnersTakeHomePay = 0;
	document.frmCalculator.inpPartnersTakeHomePay.value ="";
	
	var fltYourTakeHomePay1 = 0;
	document.frmCalculator.inpYourTakeHomePay1.value ="";
	
    var fltYourTakeHomePay2 = 0;
	document.frmCalculator.inpYourTakeHomePay2.value ="";
	
	var fltYourTakeHomePay3 = 0;
	document.frmCalculator.inpYourTakeHomePay3.value ="";

   	var fltYourTakeHomePay4 = 0;
	document.frmCalculator.inpYourTakeHomePay4.value ="";

	var fltTotalIncome = 0;
	return fltTotalIncome;
	
}

function getTotalExpenditure()
{
	var fltMortgageRent = parseFloat("0" + document.frmCalculator.mortgage_payment.value);
	var fltSecuredLoan = parseFloat("0" + document.frmCalculator.inpSecuredLoan.value);
	var fltContentInsurance = parseFloat("0" + document.frmCalculator.inpContentInsurance.value);
	var fltBuildingInsurance = parseFloat("0" + document.frmCalculator.inpBuildingInsurance.value);
	var fltFoodHousekeeping = parseFloat("0" + document.frmCalculator.inpHousekeeping.value);
	var fltCouncilTax = parseFloat("0" + document.frmCalculator.inpCouncilTax.value);
	var fltWaterRates = parseFloat("0" + document.frmCalculator.inpWaterRates.value);
	var fltElectricity = parseFloat("0" + document.frmCalculator.inpElectricity.value);
	var fltGas = parseFloat("0" + document.frmCalculator.inpGas.value);
	var fltTelephone = parseFloat("0" + document.frmCalculator.inpTelephone.value);
	var fltSkyDigital = parseFloat("0" + document.frmCalculator.inpskyDigital.value);
	var fltInternet = parseFloat("0" + document.frmCalculator.inpInternet.value);
	var fltTVLicence = parseFloat("0" + document.frmCalculator.inpTVLicence.value);
	var fltPersonalPension = parseFloat("0" + document.frmCalculator.inpPersonalPension.value);
	var fltCarPetrol = parseFloat("0" + document.frmCalculator.inpCarPetrol.value);
	var fltCarServicing = parseFloat("0" + document.frmCalculator.inpCarServicing.value);
	var fltCarInsurance = parseFloat("0" + document.frmCalculator.inpCarInsurance.value);
	var fltHairdressing = parseFloat("0" + document.frmCalculator.inpHairdressing.value);
	var fltPublicTransport = parseFloat("0" + document.frmCalculator.inpPublicTransport.value);
	var fltSocial = parseFloat("0" + document.frmCalculator.inpSocial.value);
	var fltMealsWorks = parseFloat("0" + document.frmCalculator.inpMealsWorks.value);
	var fltSchoolMeals = parseFloat("0" + document.frmCalculator.inpSchoolMeals.value);
	var fltSchoolTrips = parseFloat("0" + document.frmCalculator.inpSchoolTrips.value);
	var fltPocketMoney = parseFloat("0" + document.frmCalculator.inpPocketMoney.value);
	var fltCSA = parseFloat("0" + document.frmCalculator.inpCSA.value);

	
	
	var fltCarRoadTax = parseFloat("0" + document.frmCalculator.inpCarRoadTax.value);
	var fltCarHP = parseFloat("0" + document.frmCalculator.inpCarHP.value);
	var fltPublicTransport = parseFloat("0" + document.frmCalculator.inpPublicTransport.value);
	var fltChildcare = parseFloat("0" + document.frmCalculator.inpChildcare.value);
	var fltOpticalDental = parseFloat("0" + document.frmCalculator.inpOpticalDental.value);
	var fltClothing = parseFloat("0" + document.frmCalculator.inpClothing.value);
	var fltPets = parseFloat("0" + document.frmCalculator.inpPets.value);
	var fltMedcial = parseFloat("0" + document.frmCalculator.inpMedcial.value);
	var fltHousekeepingMaintenance = parseFloat("0" + document.frmCalculator.inpHouseholdMaintenance.value);




	var fltAddExpenditure1 = parseFloat("0" + document.frmCalculator.inpAddExpenditure1.value);
	var fltAddExpenditure2 = parseFloat("0" + document.frmCalculator.inpAddExpenditure2.value);


	var fltTotalExpenditure = fltMortgageRent + fltSecuredLoan + fltBuildingInsurance + fltContentInsurance + fltFoodHousekeeping + fltCouncilTax + fltWaterRates + fltElectricity + fltGas + fltTelephone  + fltTVLicence + fltInternet  + fltPersonalPension + fltCarPetrol + fltCarServicing + fltCarInsurance + fltCarRoadTax + fltCarHP + fltPublicTransport + fltChildcare + fltOpticalDental + fltClothing + fltPets +fltHousekeepingMaintenance + fltAddExpenditure1 + fltAddExpenditure2  + fltSkyDigital + fltMedcial + fltHairdressing + fltPublicTransport + fltSocial + fltMealsWorks + fltSchoolMeals + fltSchoolTrips + fltPocketMoney + fltCSA;
	return fltTotalExpenditure;
}

function getTotalOwed()
{
	var fltTotalOwed = 0;

	for (intPos = 1; intPos <= parseInt(document.frmCalculator.inpNumberCreditors.value); intPos++)
	{
		fltTotalOwed = parseFloat("0" + fltTotalOwed) + parseFloat("0" + eval('document.frmCalculator.inpOwed' + intPos).value);
	}
	return fltTotalOwed;
}

function getTotalMonthlyPayments()
{
	var fltTotalMonthlyPayments = 0;

	for (intPos = 1; intPos <= parseInt(document.frmCalculator.inpNumberCreditors.value); intPos++)
	{
		fltTotalMonthlyPayments = parseFloat("0" + fltTotalMonthlyPayments) + parseFloat("0" + eval('document.frmCalculator.inpMonthlyPayment' + intPos).value);
	}
	return fltTotalMonthlyPayments;
}

function formatCurrency(num)
{
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	pennies = num%100;
	num = Math.floor(num/100).toString();
	if(pennies<10)
	pennies = "0" + pennies;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));

	if ((sign)?fontIs='':fontIs='#CC0000');
		
	return ('<FONT color=' + fontIs + '>' + ((sign)?'':'-') + '£' + num  + '</FONT>');
}

function formatCurrency2(num)
{
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	pennies = num%100;
	num = Math.floor(num/100).toString();
	if(pennies<10)
	pennies = "0" + pennies;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));

	if ((sign)?fontIs='':fontIs='#CC0000');
		
	return (((sign)?'':'-') + '£' + num);
}


function checkCollectDetails()
{
	if (document.frmCollectDetails.inpName.value == "")
	{
		alert("Please enter your name");
		document.frmCollectDetails.inpName.focus();
		return false;
	}
	if (document.frmCollectDetails.inpTel.value == "")
	{
		alert("Please enter your telephone number");
		document.frmCollectDetails.inpTel.focus();
		return false;
	}
	if (document.frmCollectDetails.inpEmail.value == "")
	{
		alert("Please enter your email address");
		document.frmCollectDetails.inpEmail.focus();
		return false;
	}
	parent.opener.document.frmCalculator.hidName.value = document.frmCollectDetails.inpName.value;
	parent.opener.document.frmCalculator.hidTel.value = document.frmCollectDetails.inpTel.value;
	parent.opener.document.frmCalculator.hidEmail.value = document.frmCollectDetails.inpEmail.value;
	parent.opener.document.frmCalculator.submit();
	window.close();
}
//-->
