function plus(id) {	var ele = "#productquantity-" + id;	var qty = Number($(ele).text());	$(ele).text(qty + 1);		calculateLineTotal(id);	calculateTotal();		if (qty >= 0) {		$("#product-" + id).removeClass("hiddenrow");	}}function minus(id) {	var ele = "#productquantity-" + id;	var qty = Number($(ele).text());	$(ele).text(qty - 1);		calculateLineTotal(id);	calculateTotal();		if (qty <= 1) {		$("#product-" + id).addClass("hiddenrow");	}		}function calculateLineTotal(id) {	var cost = Number($("#productcost-" + id).text().replace("£",""));	var qty = Number($("#productquantity-" + id).text()); 	$("#producttotal-" + id).text(cost * qty);}function addProduct() {	var id = $("#productSelector").val();	plus(id);}function selectShoot(id) {		// set selected shoot	var count = 0;	$(".shootrow").each( function() {		if (count == id)			$(this).addClass("selectedrow");		else			$(this).removeClass("selectedrow");				count++;	});		$("#shoots-" + id).attr("checked", true);		showHideMakeup(id);	calculateTotal();}function selectMakeup(id) {		// set selected shoot	var count = 0;	$(".makeuprow").each( function() {		if (count == id)			$(this).addClass("selectedrow");		else			$(this).removeClass("selectedrow");				count++;	});		$("#makeups-" + id).attr("checked", true);		calculateTotal();}function showHideMakeup(id) {		var showforstring = $("#shootid-" + id).text();	var showforarray;	var match;		var count = 0;	$(".makeuprow").each( function() {		showforarray = $("#makeupshowfor-" + count).text().split(",");		match = jQuery.inArray(showforstring, showforarray);				if (match > -1)			$(this).removeClass("invalidmakeupforthisshoot");		else			$(this).addClass("invalidmakeupforthisshoot");				count++;	});	}function calculateTotal() {		// make arrays for the shipping costs	var shippingnames = Array();	var shippingcosts = Array();		var count = 0;	$("#shippingcosts tr").each(function() {		shippingnames[count] = $("#shippingcostname-" + count).text();		shippingcosts[count] = $("#shippingcostcost-" + count).text().replace("£","");		count++;	});		// get the shipping cost	var shippingcost = 0;	var s;	var index;	var ss, sc, sq;	count = 0;	if ($("#setting-showshipping").text() == "yes") {		$("#producttable .productrow").each(function() {			ss = $("#productshippingsize-" + count).text();			sq = $("#productquantity-" + count).text();						if (Number(sq) > 0) {				index = jQuery.inArray(ss, shippingnames);				sc = shippingcosts[index];				//alert("shippingsize: " + ss + ", shippingquantity: " + sq + ", index: " + index + ", cost: " + sc + ", shippingcost: " + shippingcost);								if (Number(sc) > Number(shippingcost)) {					shippingcost = sc;				}			}						count++;		});				$("#shippingtotal").text("£" + shippingcost);	}			// get the product costs	var productcost = 0;	count = 0;	$("#producttable tr").each(function() {		productcost = productcost + Number($("#producttotal-" + count).text());		count++;	});	// get the shoot and makeup costs	var selectedshoot = $(".shoots:checked").val();	var selectedmakeup = $(".makeups:checked").val();	var shootcost = $("#shootcost-" + selectedshoot).text().replace("£","");	var makeupcost = $("#makeupcost-" + selectedmakeup).text().replace("£","");	// calculate total and update the subtotals	var total = Number(shootcost) + Number(makeupcost) + Number(productcost) + Number(shippingcost);	$("#shoottotal").text("£" + shootcost);	$("#makeuptotal").text("£" + makeupcost);	$("#productstotal").text("£" + productcost);		$("#total").text("£" + total);}function packageGeneratorConfirm() {	var name = $("#confirmationname").val();	var date = $("#confirmationdate").val();	var email = $("#confirmationemail").val();	var phone = $("#confirmationphone").val();	var selectedshoot = $(".shoots:checked").val();	var selectedmakeup = $(".makeups:checked").val();	if (!(selectedshoot >= 0)) {		alert("Please select a Shoot");		return;	}	if (!(selectedmakeup >= 0)) {		alert("Please select your Makeup Type");		return;	}	if (name == "") {		alert("Please enter your name");		return;	}	if (email == "" && phone == "") {		alert("Please enter your email address and/or a phone number");		return;	}	name = '&name='+name;	date = '&date='+date;	email = '&email='+email;	phone = '&phone='+phone;	selectedshoot = '&selectedshoot='+selectedshoot;	selectedmakeup = '&selectedmakeup='+selectedmakeup;		var shoottotal = '&shoottotal='+$("#shoottotal").text();	var makeuptotal = '&makeuptotal='+$("#makeuptotal").text();	var productstotal = '&productstotal='+$("#productstotal").text();	var total = '&total='+$("#total").text();	var products = '&products=';	var count = 0;	var qty;	$("#producttable .productrow").each(function() {		qty = $("#productquantity-"+count).text();		if (qty > 0)			products = products + count + "," + qty + ".";		count++;	});	var request = '/packagegenerator/packagegeneratoremail.php?submit=true'+name+date+email+phone+selectedshoot+selectedmakeup+products+shoottotal+makeuptotal+productstotal+total;	new Ajax.Request(request, {	  onSuccess: function(transport) {		  alert("Thank you " + $("#confirmationname").val() + ", your Package has been successfully submitted!");	  },	  onFailure: function(transport) {		  alert("Sorry. Your Package could not be submitted right now, please try again in a few seconds");	  }	});}