/*
FFW Script.

*/

function initMail(form) {
Text = "<div align=center>";
Text = Text + "<center>";
Text = Text + "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#111111 width=602>";
Text = Text + "<tr>";
Text = Text + "<td width=600 align=center valign=top bgcolor=#E6ECF7>" + "<FONT face=Verdana, Arial, Helvetica, sans-serif size=4>" + "<B>" + "ONLINE QUOTE" + "</B>" + "</FONT>";
Text = Text + "<p align=left>Your Name: " + form.name.value + "</p>";
Text = Text + "<p align=left>Email Address: " + form.email_address.value + "</p>";
Text = Text + "<p align=left>Post Code: " +  form.pcode.value + "</p>";
Text = Text + "<p align=left>Home Phone: " +  form.home_phone.value + "</p>";
Text = Text + "<p align=left>Work Phone: " +  form.work_phone.value + "</p>";
Text = Text + "<p align=left>Mobile Phone: " +  form.mobile.value + "</p>";
Text = Text + "<p align=left>Best Time to Call: " +  form.best_time.value + "</p>";
Text = Text + "<p align=left>Pick-up Address: " +  form.PU_address.value + "</p>";
Text = Text + "<p align=left>Destination Address: " +  form.D_address.value + "</p>";
Text = Text + "<p align=left>Resential or Commercial Customer: " + form.action.value + "</p>";
Text = Text + "<p align=left>Pickup Date: " +  form.pu_date.value + "</p>";
Text = Text + "<p align=left>Access at pick up address: " +  form.pu_access.value + "</p>";
Text = Text + "<p align=left>Access at destination address: " +  form.d_access.value + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=center>" + "<FONT face=Verdana, Arial, Helvetica, sans-serif size=2>" + "<B>" + "FAMILY ROOM:" + "</B>" + "</FONT>" + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=left>Billiard Table: " +  form.q_billiard_table_1.value + "</p>";
Text = Text + "<p align=left>Bookcase: " +  form.q_bookcase_1.value + "</p>";
Text = Text + "<p align=left>Chair: " +  form.q_chair_1.value + "</p>";
Text = Text + "<p align=left>Divan: " +  form.q_divan_1.value + "</p>";
Text = Text + "<p align=left>Table: " +  form.q_table_1.value + "</p>";
Text = Text + "<p align=left>Stereo: " +  form.q_stereo_1.value + "</p>";
Text = Text + "<p align=left>Video Recorder: " +  form.q_video_recorder_1.value + "</p>";
Text = Text + "<p align=left>Television: " +  form.q_television_1.value + "</p>";
Text = Text + "<p align=left>3 Seater Couch: " +  form.q_3_seater_couch_1.value + "</p>";
Text = Text + "<p align=left>2 Seater Couch: " +  form.q_2_seater_couch_1.value + "</p>";
Text = Text + "<p align=left>2.5 Seater Couch: " +  form.q_2_half_seater_couch_1.value + "</p>";
Text = Text + "<p align=left>Armchair: " +  form.q_armchair_1.value + "</p>";
Text = Text + "<p align=left>Standard Carton: " +  form.q_standard_carton_1.value + "</p>";
Text = Text + "<p align=left>Book & Wine Carton: " +  form.q_book_wine_carton_1.value + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=center>" + "<FONT face=Verdana, Arial, Helvetica, sans-serif size=2>" + "<B>" + "DINING ROOM:" + "</B>" + "</FONT>" + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=left>Bookshelf: " +  form.q_bookshelf_1.value + "</p>";
Text = Text + "<p align=left>Buffet/Sideboard: " +  form.q_buffetsideboard_1.value + "</p>";
Text = Text + "<p align=left>Crystal Cabinet: " +  form.q_crystal_cabinet_1.value + "</p>";
Text = Text + "<p align=left>Dining Chair: " +  form.q_dining_chair_1.value + "</p>";
Text = Text + "<p align=left>Dining Table: " +  form.q_dining_table_1.value + "</p>";
Text = Text + "<p align=left>Other Chair: " +  form.q_other_chair_1.value + "</p>";
Text = Text + "<p align=left>Auto Trolley: " +  form.q_auto_trolley_1.value + "</p>";
Text = Text + "<p align=left>Whatnot: " +  form.q_whatnot_1.value + "</p>";
Text = Text + "<p align=left>Standart Carton: " +  form.q_standard_carton_2.value + "</p>";
Text = Text + "<p align=left>Book & Wine Carton: " +  form.q_book_wine_carton_2.value + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=center>" + "<FONT face=Verdana, Arial, Helvetica, sans-serif size=2>" + "<B>" + "LOUNGE ROOM:" + "</B>" + "</FONT>" + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=left>Bar: " +  form.q_bar_1.value + "</p>";
Text = Text + "<p align=left>Bookcase: " +  form.q_bookcase_1.value + "</p>";
Text = Text + "<p align=left>Bookshelf: " +  form.q_bookshelf_1.value + "</p>";
Text = Text + "<p align=left>Bureau: " +  form.q_bureau_1.value + "</p>";
Text = Text + "<p align=left>Chair Arm: " +  form.q_chair_arm_1.value + "</p>";
Text = Text + "<p align=left>Chair Other: " +  form.q_chair_other_1.value + "</p>";
Text = Text + "<p align=left>China Cabinet: " +  form.q_china_cabinet_1.value + "</p>";
Text = Text + "<p align=left>Coffee Table: " +  form.q_coffee_table_1.value + "</p>";
Text = Text + "<p align=left>Desk: " +  form.q_desk_1.value + "</p>";
Text = Text + "<p align=left>Heater: " +  form.q_heater_1.value + "</p>";
Text = Text + "<p align=left>Lampshade: " +  form.q_lampshade_1.value + "</p>";
Text = Text + "<p align=left>Organ: " +  form.q_organ_1.value + "</p>";
Text = Text + "<p align=left>Piano-Baby Grand: " +  form.q_piano_baby_grand_1.value + "</p>";
Text = Text + "<p align=left>Piano-Upright: " +  form.q_piano_upright_1.value + "</p>";
Text = Text + "<p align=left>3 Seater Couch: " +  form.q_3_seater_couch_2.value + "</p>";
Text = Text + "<p align=left>2 Seater Couch: " +  form.q_2_seater_couch_2.value + "</p>";
Text = Text + "<p align=left>2.5 Seater Couch: " +  form.q_2_half_seater_couch_2.value + "</p>";
Text = Text + "<p align=left>Stereo: " +  form.q_stereo_1.value + "</p>";
Text = Text + "<p align=left>TV: " +  form.q_tv_1.value + "</p>";
Text = Text + "<p align=left>Video Recorder: " +  form.q_video_recorder_1.value + "</p>";
Text = Text + "<p align=left>Wall Unit: " +  form.q_wall_unit_1.value + "</p>";
Text = Text + "<p align=left>Standard Carton: " +  form.q_standard_carton_3.value + "</p>";
Text = Text + "<p align=left>Book & Wine Carton: " +  form.q_book_wine_carton_3.value + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=center>" + "<FONT face=Verdana, Arial, Helvetica, sans-serif size=2>" + "<B>" + "LAUNDRY:" + "</B>" + "</FONT>" + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=left>Clothes Airer: " +  form.q_clothes_airer_1.value + "</p>";
Text = Text + "<p align=left>Clothes Dryer: " +  form.q_clothes_dryer_1.value + "</p>";
Text = Text + "<p align=left>Small Laundry Cupboard: " +  form.q_small_laundry_cupboard_1.value + "</p>";
Text = Text + "<p align=left>Ironing Board: " +  form.q_ironing_board_1.value + "</p>";
Text = Text + "<p align=left>Laundry Basket: " +  form.q_laundry_basket_1.value + "</p>";
Text = Text + "<p align=left>Laundry Trolley: " +  form.q_laundry_trolley_1.value + "</p>";
Text = Text + "<p align=left>Washing Machine: " +  form.q_washing_machine_1.value + "</p>";
Text = Text + "<p align=left>Vacuum Cleaner: " +  form.q_vacuum_cleaner_1.value + "</p>";
Text = Text + "<p align=left>Standard Carton: " +  form.q_standard_carton_4.value + "</p>";
Text = Text + "<p align=left>Book & Wine Carton: " +  form.q_book_wine_carton_4.value + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=center>" + "<FONT face=Verdana, Arial, Helvetica, sans-serif size=2>" + "<B>" + "SUNDRIES:" + "</B>" + "</FONT>" + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=left>Cupboard: " +  form.q_cupboard_1.value + "</p>";
Text = Text + "<p align=left>Filing Cabinet 2 Drawer: " +  form.q_2dr_filing_cabinet_1.value + "</p>";
Text = Text + "<p align=left>Filing Cabinet 3 Drawer: " +  form.q_3dr_filing_cabinet_1.value + "</p>";
Text = Text + "<p align=left>Filing Cabinet 4 Drawer: " +  form.q_4dr_filing_cabinet_1.value + "</p>";
Text = Text + "<p align=left>Golf Bag: " +  form.q_golf_bag_1.value + "</p>";
Text = Text + "<p align=left>Sewing Machine: " +  form.q_sewing_machine_1.value + "</p>";
Text = Text + "<p align=left>Sewing Cabinet: " +  form.q_sewing_cabinet_1.value + "</p>";
Text = Text + "<p align=left>Trestle Table: " +  form.q_trestle_table_1.value + "</p>";
Text = Text + "<p align=left>Swing (dismantled): " +  form.q_swing_dismantled_1.value + "</p>";
Text = Text + "<p align=left>Bench: " +  form.q_bench_1.value + "</p>";
Text = Text + "<p align=left>Exercise Bike: " +  form.q_exercise_bike_1.value + "</p>";
Text = Text + "<p align=left>Mats & Rugs: " +  form.q_mats_rugs_1.value + "</p>";
Text = Text + "<p align=left>Pram: " +  form.q_pram_1.value + "</p>";
Text = Text + "<p align=left>Suitcase: " +  form.q_suitcase_1.value + "</p>";
Text = Text + "<p align=left>Folding Chairs: " +  form.q_folding_chairs_1.value + "</p>";
Text = Text + "<p align=left>Occasional Table: " +  form.q_occasional_table_1.value + "</p>";
Text = Text + "<p align=left>Standard Carton: " +  form.q_standard_carton_5.value + "</p>";
Text = Text + "<p align=left>Book & Wine Carton: " +  form.q_book_wine_carton_5.value + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=center>" + "<FONT face=Verdana, Arial, Helvetica, sans-serif size=2>" + "<B>" + "OUTSIDE:" + "</B>" + "</FONT>" + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=left>B.B.Q: " +  form.q_bbq_1.value + "</p>";
Text = Text + "<p align=left>Bicycle: " +  form.q_bicycle_1.value + "</p>";
Text = Text + "<p align=left>Chair: " +  form.q_chair_1.value + "</p>";
Text = Text + "<p align=left>Esky: " +  form.q_esky_1.value + "</p>";
Text = Text + "<p align=left>Fold Chairs: " +  form.q_fold_chairs_1.value + "</p>";
Text = Text + "<p align=left>Fold Lounge: " +  form.q_fold_lounge_1.value + "</p>";
Text = Text + "<p align=left>Garder Setting: " +  form.q_garden_setting_1.value + "</p>";
Text = Text + "<p align=left>Ladder: " +  form.q_ladder_1.value + "</p>";
Text = Text + "<p align=left>Motor Mower: " +  form.q_motor_mower_1.value + "</p>";
Text = Text + "<p align=left>Child's ride-on Toy: " +  form.q_childs_rideon_toy_1.value + "</p>";
Text = Text + "<p align=left>Pot Plants: " +  form.q_pot_plants_1.value + "</p>";
Text = Text + "<p align=left>Wheel Barrow: " +  form.q_wheel_barrow_1.value + "</p>";
Text = Text + "<p align=left>Whipper Snipper: " +  form.q_whipper_snipper_1.value + "</p>";
Text = Text + "<p align=left>Large Bin: " +  form.q_large_bin_1.value + "</p>";
Text = Text + "<p align=left>Table Tennis Table: " +  form.q_table_tennis_table_1.value + "</p>";
Text = Text + "<p align=left>Trampoline (dismantled): " +  form.q_trampoline_dismantled_1.value + "</p>";
Text = Text + "<p align=left>Large Umbrella: " +  form.q_large_umbrella_1.value + "</p>";
Text = Text + "<p align=left>Standard Carton: " +  form.q_standard_carton_6.value + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=center>" + "<FONT face=Verdana, Arial, Helvetica, sans-serif size=2>" + "<B>" + "BEDROOM:" + "</B>" + "</FONT>" + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=left>Double Bed & Mattress: " +  form.q_double_bed_mattress_1.value + "</p>";
Text = Text + "<p align=left>Single Bed & Mattress: " +  form.q_single_bed_mattress_1.value + "</p>";
Text = Text + "<p align=left>King Bed & Mattress: " +  form.q_king_bed_mattress_1.value + "</p>";
Text = Text + "<p align=left>Queen Bed & Mattress: " +  form.q_queen_bed_mattress_1.value + "</p>";
Text = Text + "<p align=left>Folding Bed: " +  form.q_folding_bed_1.value + "</p>";
Text = Text + "<p align=left>Bedside Table/Drawers: " +  form.q_bedside_tabledrawers_1.value + "</p>";
Text = Text + "<p align=left>Bookcase: " +  form.q_bookcase_1.value + "</p>";
Text = Text + "<p align=left>Chest: " +  form.q_chest_1.value + "</p>";
Text = Text + "<p align=left>Chair: " +  form.q_chair_1.value + "</p>";
Text = Text + "<p align=left>Chest Drawers Large: " +  form.q_chest_drawers_large_1.value + "</p>";
Text = Text + "<p align=left>Cot: " +  form.q_cot_1.value + "</p>";
Text = Text + "<p align=left>Dressing Table: " +  form.q_dressing_table_1.value + "</p>";
Text = Text + "<p align=left>Bedhead: " +  form.q_bedhead_1.value + "</p>";
Text = Text + "<p align=left>Mattress Double: " +  form.q_mattress_double_1.value + "</p>";
Text = Text + "<p align=left>Mattress Single: " +  form.q_mattress_single_1.value + "</p>";
Text = Text + "<p align=left>Wardrobe: " +  form.q_wardrobe_1.value + "</p>";
Text = Text + "<p align=left>Portable Robe: " +  form.q_portable_robe_1.value + "</p>";
Text = Text + "<p align=left>Desk: " +  form.q_desk_1.value + "</p>";
Text = Text + "<p align=left>Dressing Table & Mirror: " +  form.q_dressing_table_mirror_1.value + "</p>";
Text = Text + "<p align=left>Cheval Mirror: " +  form.q_cheval_mirror_1.value + "</p>";
Text = Text + "<p align=left>Chair: " +  form.q_chair_1.value + "</p>";
Text = Text + "<p align=left>Standard Carton: " +  form.q_standard_carton_7.value + "</p>";
Text = Text + "<p align=left>Book & Wine Carton: " +  form.q_book_wine_carton_6.value + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=center>" + "<FONT face=Verdana, Arial, Helvetica, sans-serif size=2>" + "<B>" + "KITCHEN:" + "</B>" + "</FONT>" + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=left>Cabinet Dresser: " +  form.q_cabinet_dresser_1.value + "</p>";
Text = Text + "<p align=left>Freezer: " +  form.q_freezer_1.value + "</p>";
Text = Text + "<p align=left>Fridge: " +  form.q_fridge_1.value + "</p>";
Text = Text + "<p align=left>Table: " +  form.q_table_1.value + "</p>";
Text = Text + "<p align=left>Kitchen Chair: " +  form.q_kitchen_chair_1.value + "</p>";
Text = Text + "<p align=left>Microwave: " +  form.q_microwave_1.value + "</p>";
Text = Text + "<p align=left>Chopping Block: " +  form.q_chopping_block_1.value + "</p>";
Text = Text + "<p align=left>High Chair: " +  form.q_high_chair_1.value + "</p>";
Text = Text + "<p align=left>Stool: " +  form.q_stool_1.value + "</p>";
Text = Text + "<p align=left>Cupboard: " +  form.q_cupboard_1.value + "</p>";
Text = Text + "<p align=left>Standard Carton: " +  form.q_standard_carton_8.value + "</p>";
Text = Text + "<p align=left>Book & Wine Carton: " +  form.q_book_wine_carton_7.value + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=center>" + "<FONT face=Verdana, Arial, Helvetica, sans-serif size=2>" + "<B>" + "HALL:" + "</B>" + "</FONT>" + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=left>Dropside Table: " +  form.q_dropside_table_1.value + "</p>";
Text = Text + "<p align=left>Coat Stand: " +  form.q_coat_stand_1.value + "</p>";
Text = Text + "<p align=left>Hall Table: " +  form.q_hall_table_1.value + "</p>";
Text = Text + "<p align=left>Hat Stand: " +  form.q_hat_stand_1.value + "</p>";
Text = Text + "<p align=left>Standard Carton: " +  form.q_standard_carton_9.value + "</p>";
Text = Text + "<p align=left>Book & Wine Carton: " +  form.q_book_wine_carton_8.value + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=left>CUBIC METRES TOTAL: " +  form.total.value + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=center>" + "<FONT face=Verdana, Arial, Helvetica, sans-serif size=2>" + "<B>" + "Additional Items:" + "</B>" + "</FONT>" + "</p>";
Text = Text + "<hr noshade color=#0000FF>";
Text = Text + "<p align=left>List of Additional Items: " +  form.listofadditionalitems.value + "</p>";
Text = Text + "<p>" + "</td>" + "</tr>" + "</table>" + "</center>" + "</div>";
// form._recipients.value = "bmorgan@bmcdata.com.au" + "," + form.senderemail.value;
//form._recipents.value != "";
//form.message.value !=  "";
form.message.value = Text;
return (form.email_address.value != "");
}



function update(name)
{
	sizeField = "s_" + name;
	size = eval("document.forms[0]." + sizeField + ".value");
	
	qtyField = "q_" + name;
	qty = eval("document.forms[0]." + qtyField + ".value");

	totalField = "t_" + name;
	
	// Check up on the qty field to check that it is a number
	if (!isInteger(qty))
	{
		alert ("You must enter a number for the quantity");
		
		eval("document.forms[0]." + totalField + ".value = 0");
	}
	else
	{
		totalSize = qty * size;
		
		totalSize = roundOff(totalSize, 2);
		
		eval("document.forms[0]." + totalField + ".value = " + totalSize);
		
		updateGrandTotal();
	}
}


function updateGrandTotal()
{
	numberTotals = document.forms[0].elements.length;
	grandTotal = 0;
	
	for (i = 0; i < numberTotals; i++)
	{
		if (document.forms[0].elements[i].name.substr(0,2) == "t_")
		{
			grandTotal += eval(document.forms[0].elements[i].value);
		}
	}

	grandTotal = roundOff(grandTotal, 2);
	document.forms[0].total.value = grandTotal;

}


function getIndex(input)
{
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
	{
		if (input.form[i] == input)
		{
			index = i;
		}
		else
		{
			i++;
		}
	}
	return index;
}


function nextFocus(element)
{
	formIndex = (getIndex(element) + 2) % element.form.length;
	element.form[formIndex].focus();	
}

function skipFocus(element)
{
	formIndex = (getIndex(element) + 2) % element.form.length;
	element.form[formIndex + 1].focus();	
}

//-------------------------------------------------------------------
// isInteger(value)
//   Returns true if value contains all digits
//-------------------------------------------------------------------
function isInteger(val) {
	for (var i=0; i < val.length; i++) {
		if (!isDigit(val.charAt(i))) { return false; }
		}
	return true;
	}

//-------------------------------------------------------------------
// isDigit(value)
//   Returns true if value is a 1-character digit
//-------------------------------------------------------------------
function isDigit(num) {
	var string="1234567890";
	if (string.indexOf(num) != -1) {
		return true;
		}
	return false;
	}


function roundOff(value, precision)
{
        value = "" + value //convert value to string
        precision = parseInt(precision);

        var whole = "" + Math.round(value * Math.pow(10, precision));

        var decPoint = whole.length - precision;

        result = whole.substring(0, decPoint);
        result += ".";
        result += whole.substring(decPoint, whole.length);

        return result;
}

