<!--
// This JavaScript was created by Nathan Kerr on 14/06/2005
//Modified from /javascript/budgetPlanner/weddingPlanner.js

function calculate()
{

// All variables are decalared here

        var valBrideRing = document.weddingPlanner.brideRing.value;
        var valGroomRing = document.weddingPlanner.groomRing.value;
        var valRingInsurance = document.weddingPlanner.ringInsurance.value;
        
		var valAnnouncements = document.weddingPlanner.announcements.value;
        var valEngagementVenue = document.weddingPlanner.engagementVenue.value;
        var valEngagementFood = document.weddingPlanner.engagementFood.value;
        var valBridalShower = document.weddingPlanner.bridalShower.value;
        var valHensNight = document.weddingPlanner.hensNight.value;
		var valBucksNight = document.weddingPlanner.bucksNight.value;

        var valBridesDress = document.weddingPlanner.bridesDress.value;
        var valBridesmaidsDresses = document.weddingPlanner.bridesmaidsDresses.value;
        var valGroomSuit = document.weddingPlanner.groomSuit.value;
        var valGroomsmenSuits = document.weddingPlanner.groomsmenSuits.value;
        var valFlowergirlDresses = document.weddingPlanner.flowergirlDresses.value;
        var valPageboySuit = document.weddingPlanner.pageboySuit.value;
        var valDrycleaning = document.weddingPlanner.drycleaning.value;

        var valCeremonyLocationHire = document.weddingPlanner.ceremonyLocationHire.value;
        var valMinister = document.weddingPlanner.minister.value;
        var valMarriageLicence = document.weddingPlanner.marriageLicence.value;
        var valChurch = document.weddingPlanner.church.value;

        var valReceptionLocationHire = document.weddingPlanner.receptionLocationHire.value;
        var valReception = document.weddingPlanner.reception.value;
        var valFurnitureHire = document.weddingPlanner.furnitureHire.value;
		var valUtensils = document.weddingPlanner.utensils.value;
        var valWaitingStaff = document.weddingPlanner.waitingStaff.value;
        var valReceptionFood = document.weddingPlanner.receptionFood.value;
		var valReceptionDrinks = document.weddingPlanner.receptionDrinks.value;

		var valEngagementInvites = document.weddingPlanner.engagementInvites.value;
        var valWeddingInvites = document.weddingPlanner.weddingInvites.value;
        var valReceptionPlacecards = document.weddingPlanner.receptionPlacecards.value;

		var valTransportCeremony = document.weddingPlanner.transportCeremony.value;
        var valTransportReception = document.weddingPlanner.transportReception.value;

        var valBrideBouquet = document.weddingPlanner.brideBouquet.value;
		var valBridesmaidsBouquets = document.weddingPlanner.bridesmaidsBouquets.value;
		var valFlowergirlBouquets = document.weddingPlanner.flowergirlBouquets.value;
        var valButtonHoles = document.weddingPlanner.buttonHoles.value;
        var valCeremonyFlowers = document.weddingPlanner.ceremonyFlowers.value;
		var valReceptionFlowers = document.weddingPlanner.receptionFlowers.value;

        var valCeremonyEntertainment = document.weddingPlanner.ceremonyEntertainment.value;
        var valReceptionEntertainment = document.weddingPlanner.receptionEntertainment.value;

		var valPhotography = document.weddingPlanner.photography.value;
		var valAlbums = document.weddingPlanner.albums.value;
		var valVideographer = document.weddingPlanner.videographer.value;
		var valCopies = document.weddingPlanner.copies.value;

        var valWeddingCake = document.weddingPlanner.weddingCake.value;
        var valServingCake = document.weddingPlanner.servingCake.value;
		var valCakeBoxes = document.weddingPlanner.cakeBoxes.value;

        var valHairdresser = document.weddingPlanner.hairdresser.value;
		var valMakeup = document.weddingPlanner.makeup.value;
        var valFacials = document.weddingPlanner.facials.value;
        var valManicures = document.weddingPlanner.manicures.value;
		var valBridalParty = document.weddingPlanner.bridalParty.value;

		var valFirstNight = document.weddingPlanner.firstNight.value;
		var valHolidays = document.weddingPlanner.holidays.value;

		var valGrandTotal;

// Test all inputs to see if they are valid (ie. numbers, not letters or characters) If the
// input entered is not valid, issue an alert message to the user, reset the value to zero,
// and set the focus back in the text box that had the invalid input.

        if (isNaN(removeComma(valBrideRing)))
        {
                alert("Invalid figure entered for the 'Rings - Bride'");
                valBrideRing = 0;
                document.weddingPlanner.brideRing.value = formatAmount(valBrideRing);
                document.weddingPlanner.brideRing.focus();
        }
        else
        {
                valBrideRing = removeComma(valBrideRing);
        		document.weddingPlanner.brideRing.value = formatAmount(valBrideRing);
        }
        if (isNaN(removeComma(valGroomRing)))
        {
                alert("Invalid figure entered for the 'Rings - Groom'");
                valGroomRing = 0;
                document.weddingPlanner.groomRing.value = formatAmount(valGroomRing);
                document.weddingPlanner.groomRing.focus();
        }
        else
        {
                valGroomRing = removeComma(valGroomRing);
        		document.weddingPlanner.groomRing.value = formatAmount(valGroomRing);
        }
        if (isNaN(removeComma(valRingInsurance)))
        {
                alert("Invalid figure entered for the 'Rings - Insurance'");
                valRingInsurance = 0;
                document.weddingPlanner.ringInsurance.value = formatAmount(valRingInsurance);
                document.weddingPlanner.ringInsurance.focus();
        }
        else
        {
                valRingInsurance = removeComma(valRingInsurance);
        		document.weddingPlanner.ringInsurance.value = formatAmount(valRingInsurance);
        }
        if (isNaN(removeComma(valAnnouncements)))
        {
                alert("Invalid figure entered for the 'Pre-wedding celebrations - Announcements'");
                valAnnouncements = 0;
                document.weddingPlanner.announcements.value = formatAmount(valAnnouncements);
                document.weddingPlanner.announcements.focus();
        }
        else
        {
                valAnnouncements = removeComma(valAnnouncements);
        		document.weddingPlanner.announcements.value = formatAmount(valAnnouncements);
        }
        if (isNaN(removeComma(valEngagementVenue)))
        {
                alert("Invalid figure entered for the 'Pre-wedding celebrations - Engagement (venue and entertainment)'");
                valEngagementVenue = 0;
                document.weddingPlanner.engagementVenue.value = formatAmount(valEngagementVenue);
                document.weddingPlanner.engagementVenue.focus();
        }
        else
        {
                valEngagementVenue = removeComma(valEngagementVenue);
        		document.weddingPlanner.engagementVenue.value = formatAmount(valEngagementVenue);
        }
        if (isNaN(removeComma(valEngagementFood)))
        {
                alert("Invalid figure entered for the 'Pre-wedding celebrations - Engagement (food and drink)'");
                valEngagementFood = 0;
                document.weddingPlanner.engagementFood.value = formatAmount(valEngagementFood);
                document.weddingPlanner.engagementFood.focus();
        }
        else
        {
                valEngagementFood = removeComma(valEngagementFood);
        		document.weddingPlanner.engagementFood.value = formatAmount(valEngagementFood);
        }
        if (isNaN(removeComma(valBridalShower)))
        {
                alert("Invalid figure entered for the 'Pre-wedding celebrations - Bridal Shower'");
                valBridalShower = 0;
                document.weddingPlanner.bridalShower.value = formatAmount(valBridalShower);
                document.weddingPlanner.bridalShower.focus();
        }
        else
        {
                valBridalShower = removeComma(valBridalShower);
        		document.weddingPlanner.bridalShower.value = formatAmount(valBridalShower);
        }
        if (isNaN(removeComma(valHensNight)))
        {
                alert("Invalid figure entered for the 'Pre-wedding celebrations - Hens Night'");
                valHensNight = 0;
                document.weddingPlanner.hensNight.value = formatAmount(valHensNight);
                document.weddingPlanner.hensNight.focus();
        }
        else
        {
                valHensNight = removeComma(valHensNight);
        	document.weddingPlanner.hensNight.value = formatAmount(valHensNight);
        }
        if (isNaN(removeComma(valBucksNight)))
        {
                alert("Invalid figure entered for the 'Pre-wedding celebrations - Bucks Night'");
                valBucksNight = 0;
                document.weddingPlanner.bucksNight.value = formatAmount(valBucksNight);
                document.weddingPlanner.bucksNight.focus();
        }
        else
        {
                valBucksNight = removeComma(valBucksNight);
                document.weddingPlanner.bucksNight.value = formatAmount(valBucksNight);
        }
        if (isNaN(removeComma(valBridesDress)))
        {
                alert("Invalid figure entered for the 'Fashion - Bride (dress, accessories, lingerie, shoes)'");
                valBridesDress = 0;
                document.weddingPlanner.bridesDress.value = formatAmount(valBridesDress);
                document.weddingPlanner.bridesDress.focus();
        }
        else
        {
                valBridesDress = removeComma(valBridesDress);
                document.weddingPlanner.bridesDress.value = formatAmount(valBridesDress);
        }
        if (isNaN(removeComma(valBridesmaidsDresses)))
        {
                alert("Invalid figure entered for the 'Fashion - Bridesmaids (dress, accessories, shoes)'");
                valBridesmaidsDresses = 0;
                document.weddingPlanner.bridesmaidsDresses.value = formatAmount(valBridesmaidsDresses);
                document.weddingPlanner.bridesmaidsDresses.focus();
        }
        else
        {
                valBridesmaidsDresses = removeComma(valBridesmaidsDresses);
                document.weddingPlanner.bridesmaidsDresses.value = formatAmount(valBridesmaidsDresses);
        }
        if (isNaN(removeComma(valGroomSuit)))
        {
                alert("Invalid figure entered for the 'Fashion - Groom (suit, shirt, accessories, shoes)'");
                valGroomSuit = 0;
                document.weddingPlanner.groomSuit.value = formatAmount(valGroomSuit);
                document.weddingPlanner.groomSuit.focus();
        }
        else
        {
                valGroomSuit = removeComma(valGroomSuit);
                document.weddingPlanner.groomSuit.value = formatAmount(valGroomSuit);
        }
        if (isNaN(removeComma(valGroomsmenSuits)))
        {
                alert("Invalid figure entered for the 'Fashion - Groomsmen (suit, accessories, shoes)'");
                valGroomsmenSuits = 0;
                document.weddingPlanner.groomsmenSuits.value = formatAmount(valGroomsmenSuits);
                document.weddingPlanner.groomsmenSuits.focus();
        }
        else
        {
                valGroomsmenSuits = removeComma(valGroomsmenSuits);
                document.weddingPlanner.groomsmenSuits.value = formatAmount(valGroomsmenSuits);
        }
        if (isNaN(removeComma(valFlowergirlDresses)))
        {
                alert("Invalid figure entered for the 'Fashion - Flowergirls (dress, accessories, shoes)'");
                valFlowergirlDresses = 0;
                document.weddingPlanner.flowergirlDresses.value = formatAmount(valFlowergirlDresses);
                document.weddingPlanner.flowergirlDresses.focus();
        }
        else
        {
                valFlowergirlDresses = removeComma(valFlowergirlDresses);
                document.weddingPlanner.flowergirlDresses.value = formatAmount(valFlowergirlDresses);
        }
        if (isNaN(removeComma(valPageboySuit)))
        {
                alert("Invalid figure entered for the 'Fashion - Pageboy (suit, shirt, accessories, shoes)'");
                valPageboySuit = 0;
                document.weddingPlanner.pageboySuit.value = formatAmount(valPageboySuit);
                document.weddingPlanner.pageboySuit.focus();
        }
        else
        {
                valPageboySuit = removeComma(valPageboySuit);
                document.weddingPlanner.pageboySuit.value = formatAmount(valPageboySuit);
        }
        if (isNaN(removeComma(valDrycleaning)))
        {
                alert("Invalid figure entered for the 'Fashion - Brides dress drycleaning and preservation'");
                valDrycleaning = 0;
                document.weddingPlanner.drycleaning.value = formatAmount(valDrycleaning);
                document.weddingPlanner.drycleaning.focus();
        }
        else
        {
                valDrycleaning = removeComma(valDrycleaning);
                document.weddingPlanner.drycleaning.value = formatAmount(valDrycleaning);
        }
        if (isNaN(removeComma(valCeremonyLocationHire)))
        {
                alert("Invalid figure entered for the 'Ceremony - Location hire/insurance'");
                valCeremonyLocationHire= 0;
                document.weddingPlanner.ceremonyLocationHire.value = formatAmount(valCeremonyLocationHire);
                document.weddingPlanner.ceremonyLocationHire.focus();
        }
        else
        {
                valCeremonyLocationHire = removeComma(valCeremonyLocationHire);
                document.weddingPlanner.ceremonyLocationHire.value = formatAmount(valCeremonyLocationHire);
        }
        if (isNaN(removeComma(valMinister)))
        {
                alert("Invalid figure entered for the 'Ceremony - Minister/celebrant'");
                valMinister = 0;
                document.weddingPlanner.minister.value = formatAmount(valMinister);
                document.weddingPlanner.minister.focus();
        }
        else
        {
                valMinister = removeComma(valMinister);
                document.weddingPlanner.minister.value = formatAmount(valMinister);
        }
        if (isNaN(removeComma(valMarriageLicence)))
        {
                alert("Invalid figure entered for the 'Ceremony - Marriage Licence");
                valMarriageLicence = 0;
                document.weddingPlanner.marriageLicence.value = formatAmount(valMarriageLicence);
                document.weddingPlanner.marriageLicence.focus();
        }
        else
        {
                valMarriageLicence = removeComma(valMarriageLicence);
                document.weddingPlanner.marriageLicence.value = formatAmount(valMarriageLicence);
        }
        if (isNaN(removeComma(valChurch)))
        {
                alert("Invalid figure entered for the 'Ceremony - Church'");
                valChurch = 0;
                document.weddingPlanner.church.value = formatAmount(valChurch);
                document.weddingPlanner.church.focus();
        }
        else
        {
                valChurch = removeComma(valChurch);
                document.weddingPlanner.church.value = formatAmount(valChurch);
        }
        if (isNaN(removeComma(valReceptionLocationHire)))
        {
                alert("Invalid figure entered for the 'Reception - Location Hire");
                valReceptionLocationHire = 0;
                document.weddingPlanner.receptionLocationHire.value = formatAmount(valReceptionLocationHire);
                document.weddingPlanner.receptionLocationHire.focus();
        }
        else
        {
                valReceptionLocationHire = removeComma(valReceptionLocationHire);
                document.weddingPlanner.receptionLocationHire.value = formatAmount(valReceptionLocationHire);
        }
        if (isNaN(removeComma(valReception)))
        {
                alert("Invalid figure entered for the 'Reception - Reception'");
                valReception = 0;
                document.weddingPlanner.reception.value = formatAmount(valReception);
                document.weddingPlanner.reception.focus();
        }
        else
        {
                valReception = removeComma(valReception);
                document.weddingPlanner.reception.value = formatAmount(valReception);
        }
        if (isNaN(removeComma(valFurnitureHire)))
        {
                alert("Invalid figure entered for the 'Reception - Furniture Hire'");
                valFurnitureHire = 0;
                document.weddingPlanner.furnitureHire.value = formatAmount(valFurnitureHire);
                document.weddingPlanner.furnitureHire.focus();
        }
        else
        {
                valFurnitureHire = removeComma(valFurnitureHire);
                document.weddingPlanner.furnitureHire.value = formatAmount(valFurnitureHire);
        }
		if (isNaN(removeComma(valUtensils)))
        {
                alert("Invalid figure entered for the 'Reception - Utensils'");
                valUtensils = 0;
                document.weddingPlanner.utensils.value = formatAmount(valUtensils);
                document.weddingPlanner.utensils.focus();
        }
        else
        {
                valUtensils = removeComma(valUtensils);
        		document.weddingPlanner.utensils.value = formatAmount(valUtensils);
        }
        if (isNaN(removeComma(valWaitingStaff)))
        {
                alert("Invalid figure entered for the 'Reception - Waiting Staff'");
                valWaitingStaff = 0;
                document.weddingPlanner.waitingStaff.value = formatAmount(valWaitingStaff);
                document.weddingPlanner.waitingStaff.focus();
        }
        else
        {
                valWaitingStaff = removeComma(valWaitingStaff);
        		document.weddingPlanner.waitingStaff.value = formatAmount(valWaitingStaff);
        }
        if (isNaN(removeComma(valReceptionFood)))
        {
                alert("Invalid figure entered for the 'Reception - Food'");
                valReceptionFood = 0;
                document.weddingPlanner.receptionFood.value = formatAmount(valReceptionFood);
                document.weddingPlanner.receptionFood.focus();
        }
        else
        {
                valReceptionFood = removeComma(valReceptionFood);
        		document.weddingPlanner.receptionFood.value = formatAmount(valReceptionFood);
        }
        if (isNaN(removeComma(valReceptionDrinks)))
        {
                alert("Invalid figure entered for the 'Reception - Drinks'");
                valReceptionDrinks = 0;
                document.weddingPlanner.receptionDrinks.value = formatAmount(valReceptionDrinks);
                document.weddingPlanner.receptionDrinks.focus();
        }
        else
        {
                valReceptionDrinks = removeComma(valReceptionDrinks);
        		document.weddingPlanner.receptionDrinks.value = formatAmount(valReceptionDrinks);
        }
        if (isNaN(removeComma(valEngagementInvites)))
        {
                alert("Invalid figure entered for the 'Invitations and bomboniere - Engagement (invitations, thank you notes, envelopes, postage)'");
                valEngagementInvites = 0;
                document.weddingPlanner.engagementInvites.value = formatAmount(valEngagementInvites);
                document.weddingPlanner.engagementInvites.focus();
        }
        else
        {
                valEngagementInvites = removeComma(valEngagementInvites);
        		document.weddingPlanner.engagementInvites.value = formatAmount(valEngagementInvites);
        }
        if (isNaN(removeComma(valWeddingInvites)))
        {
                alert("Invalid figure entered for the 'Invitations and bomboniere - Wedding (invitations, thank you notes, envelopes, postage)'");
                valWeddingInvites = 0;
                document.weddingPlanner.weddingInvites.value = formatAmount(valWeddingInvites);
                document.weddingPlanner.weddingInvites.focus();
        }
        else
        {
                valWeddingInvites = removeComma(valWeddingInvites);
        		document.weddingPlanner.weddingInvites.value = formatAmount(valWeddingInvites);
        }
        if (isNaN(removeComma(valReceptionPlacecards)))
        {
                alert("Invalid figure entered for the 'Invitations and bomboniere - Reception (placecards, bomboniere)'");
                valReceptionPlacecards = 0;
                document.weddingPlanner.receptionPlacecards.value = formatAmount(valReceptionPlacecards);
                document.weddingPlanner.receptionPlacecards.focus();
        }
        else
        {
                valReceptionPlacecards = removeComma(valReceptionPlacecards);
        		document.weddingPlanner.receptionPlacecards.value = formatAmount(valReceptionPlacecards);
        }
        if (isNaN(removeComma(valTransportCeremony)))
        {
                alert("Invalid figure entered for the 'Transport - To / From ceremony'");
                valTransportCeremony = 0;
                document.weddingPlanner.transportCeremony.value = formatAmount(valTransportCeremony);
                document.weddingPlanner.transportCeremony.focus();
        }
        else
        {
                valTransportCeremony = removeComma(valTransportCeremony);
        		document.weddingPlanner.transportCeremony.value = formatAmount(valTransportCeremony);
        }
        if (isNaN(removeComma(valTransportReception)))
        {
                alert("Invalid figure entered for the 'Transport - To / From reception'");
                valTransportReception = 0;
                document.weddingPlanner.transportReception.value = formatAmount(valTransportReception);
                document.weddingPlanner.transportReception.focus();
        }
        else
        {
                valTransportReception = removeComma(valTransportReception);
                document.weddingPlanner.transportReception.value = formatAmount(valTransportReception);
        }
        if (isNaN(removeComma(valBrideBouquet)))
        {
                alert("Invalid figure entered for the 'Flowers and decorations - Bride (bouquet, hairpiece, preserving)'");
                valBrideBouquet = 0;
                document.weddingPlanner.brideBouquet.value = formatAmount(valBrideBouquet);
                document.weddingPlanner.brideBouquet.focus();
        }
        else
        {
                valBrideBouquet = removeComma(valBrideBouquet);
                document.weddingPlanner.brideBouquet.value = formatAmount(valBrideBouquet);
        }
        if (isNaN(removeComma(valBridesmaidsBouquets)))
        {
                alert("Invalid figure entered for the 'Flowers and decorations - Bridesmaids (bouquets, hairpiece)'");
                valBridesmaidsBouquets = 0;
                document.weddingPlanner.bridesmaidsBouquets.value = formatAmount(valBridesmaidsBouquets);
                document.weddingPlanner.bridesmaidsBouquets.focus();
        }
        else
        {
                valBridesmaidsBouquets = removeComma(valBridesmaidsBouquets);
                document.weddingPlanner.bridesmaidsBouquets.value = formatAmount(valBridesmaidsBouquets);
        }
        if (isNaN(removeComma(valFlowergirlBouquets)))
        {
                alert("Invalid figure entered for the 'Flowers and decorations - Flowergirls (bouquets, hairpiece)'");
                valFlowergirlBouquets = 0;
                document.weddingPlanner.flowergirlBouquets.value = formatAmount(valFlowergirlBouquets);
                document.weddingPlanner.flowergirlBouquets.focus();
        }
        else
        {
                valFlowergirlBouquets = removeComma(valFlowergirlBouquets);
                document.weddingPlanner.flowergirlBouquets.value = formatAmount(valFlowergirlBouquets);
        }
        if (isNaN(removeComma(valButtonHoles)))
        {
                alert("Invalid figure entered for the 'Flowers and decorations - Groom, groomsmen, parents - button holes'");
                valButtonHoles = 0;
                document.weddingPlanner.buttonHoles.value = formatAmount(valButtonHoles);
                document.weddingPlanner.buttonHoles.focus();
        }
        else
        {
                valButtonHoles = removeComma(valButtonHoles);
                document.weddingPlanner.buttonHoles.value = formatAmount(valButtonHoles);
        }
        if (isNaN(removeComma(valCeremonyFlowers)))
        {
                alert("Invalid figure entered for the 'Flowers and decorations - Ceremony'");
                valCeremonyFlowers = 0;
                document.weddingPlanner.ceremonyFlowers.value = formatAmount(valCeremonyFlowers);
                document.weddingPlanner.ceremonyFlowers.focus();
        }
        else
        {
                valCeremonyFlowers = removeComma(valCeremonyFlowers);
                document.weddingPlanner.ceremonyFlowers.value = formatAmount(valCeremonyFlowers);
        }
        if (isNaN(removeComma(valReceptionFlowers)))
        {
                alert("Invalid figure entered for the 'Flowers and decorations - Ceremony'");
                valReceptionFlowers = 0;
                document.weddingPlanner.receptionFlowers.value = formatAmount(valReceptionFlowers);
                document.weddingPlanner.receptionFlowers.focus();
        }
        else
        {
                valReceptionFlowers = removeComma(valReceptionFlowers);
                document.weddingPlanner.receptionFlowers.value = formatAmount(valReceptionFlowers);
        }
        if (isNaN(removeComma(valCeremonyEntertainment)))
        {
                alert("Invalid figure entered for the 'Music and entertainment - Ceremony'");
                valCeremonyEntertainment = 0;
                document.weddingPlanner.ceremonyEntertainment.value = formatAmount(valCeremonyEntertainment);
                document.weddingPlanner.ceremonyEntertainment.focus();
        }
        else
        {
                valCeremonyEntertainment = removeComma(valCeremonyEntertainment);
                document.weddingPlanner.ceremonyEntertainment.value = formatAmount(valCeremonyEntertainment);
        }
        if (isNaN(removeComma(valReceptionEntertainment)))
        {
                alert("Invalid figure entered for the 'Music and entertainment - Reception'");
                valReceptionEntertainment= 0;
                document.weddingPlanner.receptionEntertainment.value = formatAmount(valReceptionEntertainment);
                document.weddingPlanner.receptionEntertainment.focus();
        }
        else
        {
                valReceptionEntertainment = removeComma(valReceptionEntertainment);
                document.weddingPlanner.receptionEntertainment.value = formatAmount(valReceptionEntertainment);
        }
        if (isNaN(removeComma(valPhotography)))
        {
                alert("Invalid figure entered for the 'Photography and video - Photography package'");
                valPhotography = 0;
                document.weddingPlanner.photography.value = formatAmount(valPhotography);
                document.weddingPlanner.photography.focus();
        }
        else
        {
                valPhotography = removeComma(valPhotography);
                document.weddingPlanner.photography.value = formatAmount(valPhotography);
        }
        if (isNaN(removeComma(valAlbums)))
        {
                alert("Invalid figure entered for the 'Photography and video - Albums");
                valAlbums = 0;
                document.weddingPlanner.albums.value = formatAmount(valAlbums);
                document.weddingPlanner.albums.focus();
        }
        else
        {
                valAlbums = removeComma(valAlbums);
                document.weddingPlanner.albums.value = formatAmount(valAlbums);
        }
        if (isNaN(removeComma(valVideographer)))
        {
                alert("Invalid figure entered for the 'Photography and video - Videographer'");
                valVideographer = 0;
                document.weddingPlanner.videographer.value = formatAmount(valVideographer);
                document.weddingPlanner.videographer.focus();
        }
        else
        {
                valVideographer = removeComma(valVideographer);
                document.weddingPlanner.videographer.value = formatAmount(valVideographer);
        }
        if (isNaN(removeComma(valCopies)))
        {
                alert("Invalid figure entered for the 'Photography and video - Copies");
                valCopies = 0;
                document.weddingPlanner.copies.value = formatAmount(valCopies);
                document.weddingPlanner.copies.focus();
        }
        else
        {
                valCopies = removeComma(valCopies);
                document.weddingPlanner.copies.value = formatAmount(valCopies);
        }
        if (isNaN(removeComma(valWeddingCake)))
        {
                alert("Invalid figure entered for the 'Wedding cake - Wedding cake'");
                valWeddingCake = 0;
                document.weddingPlanner.weddingCake.value = formatAmount(valWeddingCake);
                document.weddingPlanner.weddingCake.focus();
        }
        else
        {
                valWeddingCake = removeComma(valWeddingCake);
                document.weddingPlanner.weddingCake.value = formatAmount(valWeddingCake);
        }
        if (isNaN(removeComma(valServingCake)))
        {
                alert("Invalid figure entered for the 'Wedding cake - Serving Cake'");
                valServingCake = 0;
                document.weddingPlanner.servingCake.value = formatAmount(valServingCake);
                document.weddingPlanner.servingCake.focus();
        }
        else
        {
                valServingCake = removeComma(valServingCake);
                document.weddingPlanner.servingCake.value = formatAmount(valServingCake);
        }
		if (isNaN(removeComma(valCakeBoxes)))
        {
                alert("Invalid figure entered for the 'Wedding cake - Cake Boxes'");
                valCakeBoxes = 0;
                document.weddingPlanner.cakeBoxes.value = formatAmount(valCakeBoxes);
                document.weddingPlanner.cakeBoxes.focus();
        }
        else
        {
                valCakeBoxes = removeComma(valCakeBoxes);
                document.weddingPlanner.cakeBoxes.value = formatAmount(valCakeBoxes);
        }
        if (isNaN(removeComma(valHairdresser)))
        {
                alert("Invalid figure entered for the 'Beauty - Hairdresser'");
                valHairdresser = 0;
                document.weddingPlanner.hairdresser.value = formatAmount(valHairdresser);
                document.weddingPlanner.hairdresser.focus();
        }
        else
        {
                valHairdresser = removeComma(valHairdresser);
                document.weddingPlanner.hairdresser.value = formatAmount(valHairdresser);
        }
        if (isNaN(removeComma(valMakeup)))
        {
                alert("Invalid figure entered for the 'Beauty - Make-Up'");
                valMakeup = 0;
                document.weddingPlanner.makeup.value = formatAmount(valMakeup);
                document.weddingPlanner.makeup.focus();
        }
        else
        {
                valMakeup = removeComma(valMakeup);
                document.weddingPlanner.makeup.value = formatAmount(valMakeup);
        }
       if (isNaN(removeComma(valFacials)))
        {
                alert("Invalid figure entered for the 'Beauty - Facials'");
                valFacials= 0;
                document.weddingPlanner.facials.value = formatAmount(valFacials);
                document.weddingPlanner.facials.focus();
        }
        else
        {
                valFacials = removeComma(valFacials);
                document.weddingPlanner.facials.value = formatAmount(valFacials);
        }
        if (isNaN(removeComma(valManicures)))
        {
                alert("Invalid figure entered for the 'Beauty - Manicures'");
                valManicures = 0;
                document.weddingPlanner.manicures.value = formatAmount(valManicures);
                document.weddingPlanner.manicures.focus();
        }
        else
        {
                valManicures = removeComma(valManicures);
                document.weddingPlanner.manicures.value = formatAmount(valManicures);
        }
        if (isNaN(removeComma(valBridalParty)))
        {
                alert("Invalid figure entered for the 'Beauty - Bridal Party'");
                valBridalParty = 0;
                document.weddingPlanner.bridalParty.value = formatAmount(valBridalParty);
                document.weddingPlanner.bridalParty.focus();
        }
        else
        {
                valBridalParty = removeComma(valBridalParty);
                document.weddingPlanner.bridalParty.value = formatAmount(valBridalParty);
        }
        if (isNaN(removeComma(valFirstNight)))
        {
                alert("Invalid figure entered for the 'Honeymoon - First Night'");
                valFirstNight = 0;
                document.weddingPlanner.firstNight.value = formatAmount(valFirstNight);
                document.weddingPlanner.firstNight.focus();
        }
        else
        {
                valFirstNight = removeComma(valFirstNight);
                document.weddingPlanner.firstNight.value = formatAmount(valFirstNight);
        }
        if (isNaN(removeComma(valHolidays)))
        {
                alert("Invalid figure entered for the 'Honeymoon - Holiday");
                valHolidays = 0;
                document.weddingPlanner.holidays.value = formatAmount(valHolidays);
                document.weddingPlanner.holidays.focus();
        }
        else
        {
                valHolidays = removeComma(valHolidays);
                document.weddingPlanner.holidays.value = formatAmount(valHolidays);
        }
       
        
// Calculate the totals and display them to screen

        valGrandTotal = valBrideRing + valGroomRing + valRingInsurance + valAnnouncements + valEngagementVenue + valEngagementFood
                        + valBridalShower + valHensNight + valBucksNight + valBridesDress + valBridesmaidsDresses
						+ valGroomSuit + valGroomsmenSuits + valFlowergirlDresses + valPageboySuit + valDrycleaning + valCeremonyLocationHire
						+ valMinister + valMarriageLicence + valChurch + valReceptionLocationHire + valReception + valFurnitureHire
						+ valUtensils + valWaitingStaff + valReceptionFood + valReceptionDrinks + valEngagementInvites + valWeddingInvites
						+ valReceptionPlacecards + valTransportCeremony + valTransportReception + valBrideBouquet + valBridesmaidsBouquets
						+ valFlowergirlBouquets + valButtonHoles + valCeremonyFlowers + valReceptionFlowers + valCeremonyEntertainment
						+ valReceptionEntertainment + valPhotography + valAlbums + valVideographer + valCopies + valWeddingCake
						+ valServingCake + valCakeBoxes + valHairdresser + valMakeup + valFacials + valManicures + valBridalParty
						+ valFirstNight + valHolidays;
        document.weddingPlanner.grandTotal.value = formatAmount(valGrandTotal);
}

function calcBride()
{
	// All variables are decalared here

		var valDresses = document.brideCost.dresses.value;
        var valAccessories = document.brideCost.accessories.value;
		 var valLingerie = document.brideCost.lingerie.value;
        var valShoes = document.brideCost.shoes.value;

		var valBrideTotal;
        
		if (isNaN(removeComma(valDresses)))
        {
                alert("Invalid figure entered for the 'Brides Costs - Brides dress");
                valDresses = 0;
                document.brideCost.dresses.value = formatAmount(valDresses);
                document.brideCost.dresses.focus();
        }
        else
        {
                valDresses = removeComma(valDresses);
                document.brideCost.dresses.value = formatAmount(valDresses);
        }
        if (isNaN(removeComma(valAccessories)))
        {
                alert("Invalid figure entered for the 'Brides Costs - Brides accessories");
                valAccessories = 0;
                document.brideCost.accessories.value = formatAmount(valAccessories);
                document.brideCost.accessories.focus();
        }
        else
        {
                valAccessories = removeComma(valAccessories);
                document.brideCost.accessories.value = formatAmount(valAccessories);
        }
		if (isNaN(removeComma(valLingerie)))
        {
                alert("Invalid figure entered for the 'Brides Costs - Brides lingerie");
                valLingerie = 0;
                document.brideCost.lingerie.value = formatAmount(valLingerie);
                document.brideCost.lingerie.focus();
        }
        else
        {
                valLingerie = removeComma(valLingerie);
                document.brideCost.lingerie.value = formatAmount(valLingerie);
        }
		if (isNaN(removeComma(valShoes)))
        {
                alert("Invalid figure entered for the 'Brides Costs - Brides shoes");
                valShoes = 0;
                document.brideCost.shoes.value = formatAmount(valShoes);
                document.brideCost.shoes.focus();
        }
        else
        {
                valShoes = removeComma(valShoes);
                document.brideCost.shoes.value = formatAmount(valShoes);
        }

	// Calculate the totals and display them to screen

		valBrideTotal = valDresses + valAccessories + valLingerie + valShoes;
		document.brideCost.brideTotal.value = formatAmount(valBrideTotal);
}

function calcBridesmaids()
{
	// All variables are decalared here

		var valDresses = document.bridesmaidsCost.dresses.value;
        var valAccessories = document.bridesmaidsCost.accessories.value;
        var valShoes = document.bridesmaidsCost.shoes.value;

		var valBridesmaidTotal;
        
		 if (isNaN(removeComma(valDresses)))
        {
                alert("Invalid figure entered for the 'Bridesmaid Costs - Bridesmaid dresses");
                valDresses = 0;
                document.bridesmaidsCost.dresses.value = formatAmount(valDresses);
                document.bridesmaidsCost.dresses.focus();
        }
        else
        {
                valDresses = removeComma(valDresses);
                document.bridesmaidsCost.dresses.value = formatAmount(valDresses);
        }
        if (isNaN(removeComma(valAccessories)))
        {
                alert("Invalid figure entered for the 'Bridesmaid Costs - Bridesmaid accessories");
                valAccessories = 0;
                document.bridesmaidsCost.accessories.value = formatAmount(valAccessories);
                document.bridesmaidsCost.accessories.focus();
        }
        else
        {
                valAccessories = removeComma(valAccessories);
                document.bridesmaidsCost.accessories.value = formatAmount(valAccessories);
        }
		if (isNaN(removeComma(valShoes)))
        {
                alert("Invalid figure entered for the 'Bridesmaid Costs - Bridesmaid shoes");
                valShoes = 0;
                document.bridesmaidsCost.shoes.value = formatAmount(valShoes);
                document.bridesmaidsCost.shoes.focus();
        }
        else
        {
                valShoes = removeComma(valShoes);
                document.bridesmaidsCost.shoes.value = formatAmount(valShoes);
        }

	// Calculate the totals and display them to screen

		valBridesmaidTotal = valDresses + valAccessories + valShoes;
		document.bridesmaidsCost.bridesmaidTotal.value = formatAmount(valBridesmaidTotal);
}

function calcGroom()
{
	// All variables are decalared here

		var valSuit = document.groomCosts.suit.value;
		var valShirt = document.groomCosts.shirt.value;
        var valAccessories = document.groomCosts.accessories.value;
        var valShoes = document.groomCosts.shoes.value;

		var valGroomTotal;
        
		if (isNaN(removeComma(valSuit)))
        {
                alert("Invalid figure entered for the 'Groom Costs - Groom suit");
                valSuit = 0;
                document.groomCosts.suit.value = formatAmount(valSuit);
                document.groomCosts.suit.focus();
        }
        else
        {
                valSuit = removeComma(valSuit);
                document.groomCosts.suit.value = formatAmount(valSuit);
        }
		if (isNaN(removeComma(valShirt)))
        {
                alert("Invalid figure entered for the 'Groom Costs - Groom shirt");
                valShirt = 0;
                document.groomCosts.shirt.value = formatAmount(valShirt);
                document.groomCosts.shirt.focus();
        }
        else
        {
                valShirt = removeComma(valShirt);
                document.groomCosts.shirt.value = formatAmount(valShirt);
        }
        if (isNaN(removeComma(valAccessories)))
        {
                alert("Invalid figure entered for the 'Groom Costs - Groom accessories");
                valAccessories = 0;
                document.groomCosts.accessories.value = formatAmount(valAccessories);
                document.groomCosts.accessories.focus();
        }
        else
        {
                valAccessories = removeComma(valAccessories);
                document.groomCosts.accessories.value = formatAmount(valAccessories);
        }
		if (isNaN(removeComma(valShoes)))
        {
                alert("Invalid figure entered for the 'Groom Costs - Groom shoes");
                valShoes = 0;
                document.groomCosts.shoes.value = formatAmount(valShoes);
                document.groomCosts.shoes.focus();
        }
        else
        {
                valShoes = removeComma(valShoes);
                document.groomCosts.shoes.value = formatAmount(valShoes);
        }

	// Calculate the totals and display them to screen

		valGroomTotal = valSuit + valShirt + valAccessories + valShoes;
		document.groomCosts.groomTotal.value = formatAmount(valGroomTotal);
}

function calcGroomsmen()
{
	// All variables are decalared here

		var valSuit = document.groomsmenCosts.suit.value;
        var valAccessories = document.groomsmenCosts.accessories.value;
        var valShoes = document.groomsmenCosts.shoes.value;

		var valGroomsmenTotal;
        
		if (isNaN(removeComma(valSuit)))
        {
                alert("Invalid figure entered for the 'Groomsmen Costs - Groomsmen suit");
                valSuit = 0;
                document.groomsmenCosts.suit.value = formatAmount(valSuit);
                document.groomsmenCosts.suit.focus();
        }
        else
        {
                valSuit = removeComma(valSuit);
                document.groomsmenCosts.suit.value = formatAmount(valSuit);
        }
        if (isNaN(removeComma(valAccessories)))
        {
                alert("Invalid figure entered for the 'Groomsmen Costs - Groomsmen accessories");
                valAccessories = 0;
                document.groomsmenCosts.accessories.value = formatAmount(valAccessories);
                document.groomsmenCosts.accessories.focus();
        }
        else
        {
                valAccessories = removeComma(valAccessories);
                document.groomsmenCosts.accessories.value = formatAmount(valAccessories);
        }
		if (isNaN(removeComma(valShoes)))
        {
                alert("Invalid figure entered for the 'Groomsmen Costs - Groomsmen shoes");
                valShoes = 0;
                document.groomsmenCosts.shoes.value = formatAmount(valShoes);
                document.groomsmenCosts.shoes.focus();
        }
        else
        {
                valShoes = removeComma(valShoes);
                document.groomsmenCosts.shoes.value = formatAmount(valShoes);
        }

	// Calculate the totals and display them to screen

		valGroomsmenTotal = valSuit + valAccessories + valShoes;
		document.groomsmenCosts.groomsmenTotal.value = formatAmount(valGroomsmenTotal);
}

function calcReception()
{
	// All variables are decalared here

        var valNoGuests = document.receptionCosts.noGuests.value;
        var valCostGuest = document.receptionCosts.costGuest.value;

		var valReceptionTotal;
        
		if (isNaN(valNoGuests))
        {
                alert("Invalid figure entered for the 'Reception Center - No of guests'");
                valNoGuests = 0;
                document.receptionCosts.noGuests.value = valNoGuests;
                document.receptionCosts.noGuests.focus();
        }
        else
        {
                document.receptionCosts.noGuests.value = valNoGuests;
        }
        if (isNaN(removeComma(valCostGuest)))
        {
                alert("Invalid figure entered for the 'Reception Center - Cost per guest");
                valCostGuest = 0;
                document.receptionCosts.costGuest.value = formatAmount(valCostGuest);
                document.receptionCosts.costGuest.focus();
        }
        else
        {
                valCostGuest = removeComma(valCostGuest);
                document.receptionCosts.costGuest.value = formatAmount(valCostGuest);
        }

	// Calculate the totals and display them to screen

		valReceptionTotal = valNoGuests * valCostGuest;
		document.receptionCosts.receptionTotal.value = formatAmount(valReceptionTotal);
}

function popUpPage(page, width, height)
{

// All variables are decalared here
	var newWin;
	var windowProps;

        var yes = 1;
        var no = 0;
        var titlebar = no;
        var menubar = no; 
        var scrollbars = yes;
        var locationbar = no;
        var directories = no;
        var resizable = no;
        var statusbar = no;
        var toolbar = no;

// Open the window with the following variable listed above.

        windowProps = "width=" + width + ",height=" + height + ",top=" + (screen.height/2 - height/2) + ",left=" + (screen.width/2 - width/2);
        windowProps += (titlebar ? ",titlebar" : "") + (menubar ? ",menubars" : "") +
                        (scrollbars ? ",scrollbars" : "") + (locationbar ? ",location" : "") +
                        (directories ? ",directories" : "") + (resizable ? ",resizable" : "") +
                        (statusbar ? ",status" : "") + (toolbar ? ",toolbar" : "");
        newWin = window.open(page, "PopUp", windowProps);

	return newWin;
}

function brideCost()
{
	var bridePage = popUpPage('/Personal_Finance/0,,66736,00.html', 550, 420);

	bridePage.focus();
}

function bridesmaidsCost()
{
	var bridesmaidsPage = popUpPage('/Personal_Finance/0,,66737,00.html', 550, 420);

	bridesmaidsPage.focus();
}

function groomCost()
{
	var groomPage = popUpPage('/Personal_Finance/0,,66738,00.html', 550, 420);

	groomPage.focus();
}

function groomsmenCost()
{
	var groomsmenPage = popUpPage('/Personal_Finance/0,,66739,00.html', 550, 420);

	groomsmenPage.focus();
}

function receptionCost()
{
	var receptionPage = popUpPage('/Personal_Finance/0,,66740,00.html', 550, 420);

	receptionPage.focus();
}

function closeWindow(num)
{
// This function closes the current (pop-up) window.
	
	if (num == 1) {  // Bride Calc  0,,66736,00.html
		opener.document.weddingPlanner.bridesDress.value = document.brideCost.brideTotal.value;
	} else if (num == 2) {  // Bridesmaid Calc   0,,66737,00.html
		opener.document.weddingPlanner.bridesmaidsDresses.value = document.bridesmaidsCost.bridesmaidTotal.value;
	} else if (num == 3) {  // Groom Calc        0,,66738,00.html
		opener.document.weddingPlanner.groomSuit.value = document.groomCosts.groomTotal.value;
	} else if (num == 4) {  // Groomsmen Calc    0,,66739,00.html
		opener.document.weddingPlanner.groomsmenSuits.value = document.groomsmenCosts.groomsmenTotal.value;
	} else if (num == 5) {  // Reception Calc    0,,66740,00.html
		opener.document.weddingPlanner.reception.value = document.receptionCosts.receptionTotal.value;
	} 

	opener.calculate();
	window.close();
}
