jQuery(document).ready(function() {

	jQuery("#bill_country").change(function(){
		if(jQuery("#bill_country").val() == "United Kingdom") {
			jQuery("#PP").val("2.5");
		} else {
			jQuery("#PP").val("3.5");						
		}
	});

if(jQuery("a[rel='epromo']")) {
	jQuery("a[rel='epromo']").colorbox({iframe:true, width:"848", height:"650"});
}

if(jQuery("a[rel='example1']")) {
	jQuery("a[rel='example1']").colorbox();
}
	var austDay = new Date();
	austDay = new Date(2012, 6 - 1, 30, 8, 0, 0);
	
if(jQuery('#defaultCountdown')) {
	jQuery('#defaultCountdown').countdown({until: austDay});
}


if(jQuery('#year')) {
	jQuery('#year').text(austDay.getFullYear());
}
    jQuery('#slideshow').ulslide({
                                 width: 443,
                                 height: 'auto',
                                 bnext: '#e1_next',
                                 bprev: '#e1_prev',
                                 axis: 'x',
                                 autoslide: 20000
                              });

			jQuery('#homeimageroll').innerfade({
				speed: 'slow',
				timeout: 4000,
				type: 'sequence',
				containerheight: '250px'
			});
	
	jQuery(".grandstand-plan a").click(function() {
		var seatsChosen = []
		
		// Try to book
		jQuery(this).addClass("provisional-booking");

		seatSelected = formatSeatText(jQuery(this).attr("id"));				
		//jQuery("#seats-chosen-saturday").val(seatsChosen);
		return false;
	});
	
if(jQuery(".day-ticket-option").length > 0) {
	jQuery(".day-ticket-option").change(changeTicketQuantity);
}
if(jQuery("#deposit_choice").length > 0) {
	jQuery("#deposit_choice").change(changeTicketQuantity);
}
if(jQuery("#balance_to_pay").length > 0) {
	jQuery("#balance_to_pay").change(changeBalanceSummary);
}
if(jQuery("#next-check-seats").length > 0) {
	jQuery("#next-check-seats").click(checkGrandstands);
}
	function checkGrandstands() {
		var satSeatsTotal = 0;
		var sunSeatsTotal = 0;		
	
		satSeats1 = jQuery(".saturday-seats #option-ticket-0").val();
		satSeats2 = jQuery(".saturday-seats #option-ticket-1").val();
		satSeats3 = jQuery(".saturday-seats #option-ticket-2").val();
		satSeats4 = jQuery(".saturday-seats #option-ticket-3").val();
		satSeatsTotal = parseInt(satSeats1) + parseInt(satSeats2) + parseInt(satSeats3) + parseInt(satSeats4)

		sunSeats1 = jQuery(".sunday-seats #option-ticket-4").val();
		sunSeats2 = jQuery(".sunday-seats #option-ticket-5").val();
		sunSeats3 = jQuery(".sunday-seats #option-ticket-6").val();
		sunSeats4 = jQuery(".sunday-seats #option-ticket-7").val();
		sunSeatsTotal = parseInt(sunSeats1) + parseInt(sunSeats2) + parseInt(sunSeats3) + parseInt(sunSeats4)

	//jQuery("#seats-chosen-saturday").val(satSeatsTotal + " seats requested for Saturday, 2 July");
	//jQuery("#seats-chosen-sunday").val(sunSeatsTotal + " seats requested for Saturday, 2 July");	
	
/* Don't remove sat/sun grandstands at all */

	if(satSeatsTotal < 1) {
		// remove sat option
//		jQuery("#seat-selection-saturday").css({'display' : 'none'});
	} else {
		// restore sat option
//		jQuery("#seat-selection-saturday").css({'display' : 'block'});	
	}
	if(sunSeatsTotal < 1) {
		// remove sun option
//		jQuery("#seat-selection-sunday").css({'display' : 'none'});
	} else {
		// remove sun option
//		jQuery("#seat-selection-sunday").css({'display' : 'block'});	
	}

	}
	
	if(jQuery("ul#ticker01").length > 0) {
	    jQuery("ul#ticker01").liScroll({travelocity: 0.05});
	}	

	function changeBalanceSummary() {
	
	jQuery("#amount").val(jQuery("#balance_to_pay").val());
	jQuery("#bookingFieldTotal").val(jQuery("#balance_to_pay").val());
		
	var runningTotal = jQuery("#balance_to_pay").val();
	jQuery('.booking-total-field').val(runningTotal);
	jQuery('#abs-total').val(runningTotal);
	var runningOrderDescription = "";
if(jQuery("#booking_reference").val()) {
	runningOrderDescription += "prod=Balance for booking reference " + jQuery("#booking_reference").val() + ",item_amount=" + jQuery("#balance_to_pay").val() + "x" + 1 + ";"
} else {
	runningOrderDescription += "prod=Balance,item_amount=" + jQuery("#balance_to_pay").val() + "x" + 1 + ";"
}
	totalquantities = 1;

	jQuery('#confirm-order-summary').val("Payment of balance");
	jQuery('#order').val(runningOrderDescription);
	bookingCost = parseFloat(jQuery("#balance_to_pay").val().toFixed(2));
	jQuery("#T").val(parseFloat(jQuery("#balance_to_pay").val()).toFixed(2));
			
	}
	
	function changeTicketQuantity() {
	
	var deposit_chosen = false;
	var depositchosen = false;

if(jQuery("#deposit_choice").length > 0) {
	dc = jQuery("#deposit_choice").val();
	if(dc=="deposit") {
	 depositchosen = true;
	 deposit_chosen = true;
//	 jQuery();
	} else {
	 depositchosen = false;
	 deposit_chosen = false;
//	 jQuery();
	}
}

	var runningTotal = 0;
	var total1 = 0; var total2 = 0; var total3 = 0; var total4 = 0; var total5 = 0; var total6 = 0; var total7 = 0; var total8 = 0; var total9 = 0; var total10 = 0; var  ototal1 = 0; var ototal2 = 0; var ototal3 = 0; var ototal4 = 0; var ototal5 = 0; var ototal6 = 0; var ototal7 = 0; var ototal8 = 0; var ototal9 = 0; var ototal10 = 0;
	
if(jQuery("#price-ticket-0").length > 0) {
	price1 = jQuery("#price-ticket-0").attr("value")
	quantity1 = jQuery("#option-ticket-0").val()
	name1 = jQuery("#option-ticket-0").attr("name")
	total1 = price1*quantity1
	if(deposit_chosen) {
		total1 = 0;	
	}
}

if(jQuery("#price-ticket-1").length > 0) {
	price2 = jQuery("#price-ticket-1").attr("value")
	quantity2 = jQuery("#option-ticket-1").val()
	name2 = jQuery("#option-ticket-1").attr("name")
	total2 = price2*quantity2
	if(deposit_chosen) {
		total2 = 0;	
	}
}

if(jQuery("#price-ticket-2").length > 0) {
	price3 = jQuery("#price-ticket-2").attr("value")
	quantity3 = jQuery("#option-ticket-2").val()
	name3 = jQuery("#option-ticket-2").attr("name")
	total3 = price3*quantity3
	if(deposit_chosen) {
		total3 = 0;	
	}
}

if(jQuery("#price-ticket-3").length > 0) {
	price4 = jQuery("#price-ticket-3").attr("value")
	quantity4 = jQuery("#option-ticket-3").val()
	name4 = jQuery("#option-ticket-3").attr("name")
	total4 = price4*quantity4
	if(deposit_chosen) {
		total4 = 0;
	}
}

if(jQuery("#price-ticket-4").length > 0) {
	price5 = jQuery("#price-ticket-4").attr("value")
	quantity5 = jQuery("#option-ticket-4").val()
	name5 = jQuery("#option-ticket-4").attr("name")
	total5 = price5*quantity5
	if(deposit_chosen) {
		total5 = 0;	
	}
}

if(jQuery("#price-ticket-5").length > 0) {
	price6 = jQuery("#price-ticket-5").attr("value")
	quantity6 = jQuery("#option-ticket-5").val()
	name6 = jQuery("#option-ticket-5").attr("name")
	total6 = price6*quantity6
	if(deposit_chosen) {
		total6 = 0;	
	}
}

if(jQuery("#price-ticket-6").length > 0) {
	price7 = jQuery("#price-ticket-6").attr("value")
	quantity7 = jQuery("#option-ticket-6").val()
	name7 = jQuery("#option-ticket-6").attr("name")
	total7 = price7*quantity7
	if(deposit_chosen) {
		total7 = 0;	
	}
}

if(jQuery("#price-ticket-7").length > 0) {
	price8 = jQuery("#price-ticket-7").attr("value")
	quantity8 = jQuery("#option-ticket-7").val()
	name8 = jQuery("#option-ticket-7").attr("name")
	total8 = price8*quantity8
	if(deposit_chosen) {
		total8 = 0;	
	}
}

if(jQuery("#price-ticket-8").length > 0) {
	price9 = jQuery("#price-ticket-8").attr("value")
	quantity9 = jQuery("#option-ticket-8").val()
	name9 = jQuery("#option-ticket-8").attr("name")
	total9 = price9*quantity9
	if(deposit_chosen) {
		total9 = 0;	
	}
}

if(jQuery("#price-ticket-9").length > 0) {
	price10 = jQuery("#price-ticket-9").attr("value")
	quantity10 = jQuery("#option-ticket-9").val()
	name10 = jQuery("#option-ticket-9").attr("name")
	total10 = price10*quantity10
	if(deposit_chosen) {
		total10 = 0;	
	}
}

if(jQuery("#admission-price-ticket-0").length > 0) {
	oprice1    = jQuery("#admission-price-ticket-0").attr("value")
	oname1     = jQuery("#admission-option-ticket-0").attr("name")
	oquantity1 = jQuery("#admission-option-ticket-0").val()
	ototal1    = oprice1*oquantity1
}
if(jQuery("#admission-price-ticket-1").length > 0) {
	oprice2    = jQuery("#admission-price-ticket-1").attr("value")
	oname2     = jQuery("#admission-option-ticket-1").attr("name")
	oquantity2 = jQuery("#admission-option-ticket-1").val()
	ototal2    = oprice2*oquantity2
}
if(jQuery("#admission-price-ticket-2").length > 0) {
	oprice3    = jQuery("#admission-price-ticket-2").attr("value")
	oname3     = jQuery("#admission-option-ticket-2").attr("name")
	oquantity3 = jQuery("#admission-option-ticket-2").val()
	ototal3    = oprice3*oquantity3
}
if(jQuery("#admission-price-ticket-3").length > 0) {
	oprice4    = jQuery("#admission-price-ticket-3").attr("value")
	oname4     = jQuery("#admission-option-ticket-3").attr("name")
	oquantity4 = jQuery("#admission-option-ticket-3").val()
	ototal4    = oprice4*oquantity4
}
if(jQuery("#admission-price-ticket-4").length > 0) {
	oprice5    = jQuery("#admission-price-ticket-4").attr("value")
	oname5     = jQuery("#admission-option-ticket-4").attr("name")
	oquantity5 = jQuery("#admission-option-ticket-4").val()
	ototal5    = oprice5*oquantity5
}
if(jQuery("#admission-price-ticket-5").length > 0) {
	oprice6    = jQuery("#admission-price-ticket-5").attr("value")
	oname6     = jQuery("#admission-option-ticket-5").attr("name")
	oquantity6 = jQuery("#admission-option-ticket-5").val()
	ototal6    = oprice6*oquantity6
}
if(jQuery("#admission-price-ticket-6").length > 0) {
	oprice7    = jQuery("#admission-price-ticket-6").attr("value")
	oname7     = jQuery("#admission-option-ticket-6").attr("name")
	oquantity7 = jQuery("#admission-option-ticket-6").val()
	ototal7    = oprice7*oquantity7
}
if(jQuery("#admission-price-ticket-7").length > 0) {
	oprice8    = jQuery("#admission-price-ticket-7").attr("value")
	oname8     = jQuery("#admission-option-ticket-7").attr("name")
	oquantity8 = jQuery("#admission-option-ticket-7").val()
	ototal8    = oprice8*oquantity8
}
if(jQuery("#admission-price-ticket-8").length > 0) {
	oprice9    = jQuery("#admission-price-ticket-8").attr("value")
	oname9     = jQuery("#admission-option-ticket-8").attr("name")
	oquantity9 = jQuery("#admission-option-ticket-8").val()
	ototal9    = oprice9*oquantity9
}
if(jQuery("#admission-price-ticket-9").length > 0) {
	oprice10    = jQuery("#admission-price-ticket-9").attr("value")
	oname10     = jQuery("#admission-option-ticket-9").attr("name")
	oquantity10 = jQuery("#admission-option-ticket-9").val()
	ototal10    = oprice10*oquantity10
}
	runningTotal = (total1 + total2 + total3 + total4 + total5 + total6 + total7 + total8 + total9 + total10 + ototal1 + ototal2 + ototal3 + ototal4 + ototal5 + ototal6 + ototal7 + ototal8 + ototal9 + ototal10);	
	
	
	jQuery('.booking-total-field').val(runningTotal);
	jQuery('#abs-total').val(runningTotal);
	
	var runningDescription = "";
	var runningOrderDescription = "";
	var enclosurename = jQuery('#enclosure_name').val();
	var totalquantities = 0;
	
	if(ototal1 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(oquantity1 > 1) isMultiple = "s";
		runningDescription += oquantity1 + " " + oname1;
		runningDescription += "\n";
		
		runningOrderDescription += "prod=" + oname1 + ",item_amount=" + oprice1 + "x" + oquantity1 + ";"	
		totalquantities = (parseInt(totalquantities) + parseInt(oquantity1));
	}
	if(ototal2 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(oquantity2 > 1) isMultiple = "s";
		runningDescription += oquantity2 + " " + oname2;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + oname2 + ",item_amount=" + oprice2 + "x" + oquantity2 + ";"
		totalquantities = (parseInt(totalquantities) + parseInt(oquantity2));
	}
	if(ototal3 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(oquantity3 > 1) isMultiple = "s";
		runningDescription += oquantity3 + " " + oname3;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + oname3 + ",item_amount=" + oprice3 + "x" + oquantity3 + ";"
		totalquantities = (parseInt(totalquantities) + parseInt(oquantity3));
	}
	if(ototal4 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(oquantity4 > 1) isMultiple = "s";
		runningDescription += oquantity4 + " " + oname4;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + oname4 + ",item_amount=" + oprice4 + "x" + oquantity4 + ";"
		totalquantities = (parseInt(totalquantities) + parseInt(oquantity4));
	}
	if(ototal5 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(oquantity5 > 1) isMultiple = "s";
		runningDescription += oquantity5 + " " + oname5;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + oname5 + ",item_amount=" + oprice5 + "x" + oquantity5 + ";"
		totalquantities = (parseInt(totalquantities) + parseInt(oquantity5));
	}
	if(ototal6 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(oquantity6 > 1) isMultiple = "s";
		runningDescription += oquantity6 + " " + oname6;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + oname6 + ",item_amount=" + oprice6 + "x" + oquantity6 + ";"
		totalquantities = (parseInt(totalquantities) + parseInt(oquantity6));
	}
	if(ototal7 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(oquantity7 > 1) isMultiple = "s";
		runningDescription += oquantity7 + " " + oname7;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + oname7 + ",item_amount=" + oprice7 + "x" + oquantity7 + ";"
		totalquantities = (parseInt(totalquantities) + parseInt(oquantity7));
	}
	if(ototal8 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(oquantity8 > 1) isMultiple = "s";
		runningDescription += oquantity8 + " " + oname8;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + oname8 + ",item_amount=" + oprice8 + "x" + oquantity8 + ";"
		totalquantities = (parseInt(totalquantities) + parseInt(oquantity8));
	}
	if(ototal9 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(oquantity9 > 1) isMultiple = "s";
		runningDescription += oquantity9 + " " + oname9;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + oname9 + ",item_amount=" + oprice9 + "x" + oquantity9 + ";"
		totalquantities = (parseInt(totalquantities) + parseInt(oquantity9));
	}
	if(ototal10 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(oquantity10 > 1) isMultiple = "s";
		runningDescription += oquantity10 + " " + oname10;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + oname10 + ",item_amount=" + oprice10 + "x" + oquantity10 + ";"
		totalquantities = (parseInt(totalquantities) + parseInt(oquantity10));
	}
	
	/* Regular totals */
	
	if(total1 > 0) {	
	// Add to for each
	    var isMultiple = "";
	    if(quantity1 > 1) isMultiple = "s";
		runningDescription += quantity1 + " " + name1;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + name1 + ",item_amount=" + price1 + "x" + quantity1 + ";"

		totalquantities = (parseInt(totalquantities) + parseInt(quantity1));
	}

	if(total2 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(quantity2 > 1) isMultiple = "s";
		runningDescription += quantity2 + " " + name2;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + name2 + ",item_amount=" + price2 + "x" + quantity2 + ";"

		totalquantities = (parseInt(totalquantities) + parseInt(quantity2));
	}

	if(total3 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(quantity3 > 1) isMultiple = "s";
		runningDescription += quantity3 + " " + name3;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + name3 + ",item_amount=" + price3 + "x" + quantity3 + ";"

		totalquantities = (parseInt(totalquantities) + parseInt(quantity3));
	}

	if(total4 > 0) {	
	// Add to for each
	    var isMultiple = "";
	    if(quantity4 > 1) isMultiple = "s";
		runningDescription += quantity4 + " " + name4;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + name4 + ",item_amount=" + price4 + "x" + quantity4 + ";"

		totalquantities = (parseInt(totalquantities) + parseInt(quantity4));
	}

	if(total5 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(quantity5 > 1) isMultiple = "s";
		runningDescription += quantity5 + " " + name5;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + name5 + ",item_amount=" + price5 + "x" + quantity5 + ";"

		totalquantities = (parseInt(totalquantities) + parseInt(quantity5));
	}

	if(total6 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(quantity6 > 1) isMultiple = "s";
		runningDescription += quantity6 + " " + name6;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + name6 + ",item_amount=" + price6 + "x" + quantity6 + ";"

		totalquantities = (parseInt(totalquantities) + parseInt(quantity6));
	}

	if(total7 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(quantity7 > 1) isMultiple = "s";
		runningDescription += quantity7 + " " + name7;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + name7 + ",item_amount=" + price7 + "x" + quantity7 + ";"

		totalquantities = (parseInt(totalquantities) + parseInt(quantity7));
	}

	if(total8 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(quantity8 > 1) isMultiple = "s";
		runningDescription += quantity8 + " " + name8;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + name8 + ",item_amount=" + price8 + "x" + quantity8 + ";"

		totalquantities = (parseInt(totalquantities) + parseInt(quantity8));
	}

	if(total9 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(quantity9 > 1) isMultiple = "s";
		runningDescription += quantity9 + " " + name9;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + name9 + ",item_amount=" + price9 + "x" + quantity9 + ";"

		totalquantities = (parseInt(totalquantities) + parseInt(quantity9));
	}

	if(total10 > 0) {
	// Add to for each
	    var isMultiple = "";
	    if(quantity10 > 1) isMultiple = "s";
		runningDescription += quantity10 + " " + name10;
		runningDescription += "\n";

		runningOrderDescription += "prod=" + name10 + ",item_amount=" + price10 + "x" + quantity10 + ";"

		totalquantities = (parseInt(totalquantities) + parseInt(quantity10));
	}	
	
	
	if(jQuery("table#grandstandSaturdayPlan").length > 0) {
	
		spitfireSeatPrice = 22;
		satSeats     = jQuery("#totalSeatsSat").val();
		satSeatsList = jQuery("#satSeatsList").val();

		runningOrderDescription += "prod=" + "Spitfire Grandstand 3 (Saturday 2nd July): " + satSeats + " seat(s): " + satSeatsList + ",item_amount=" + spitfireSeatPrice + "x" + satSeats + ";"
		
/* 		runningOrderDescription += "prod=" + "Spitfire Grandstand 2 (Saturday 2nd July): " + satSeats + " seat(s),item_amount=" + spitfireSeatPrice + "x" + satSeats + ";" */
		
		satSeatsTotal = satSeats * spitfireSeatPrice;
		
		runningTotal  = runningTotal + satSeatsTotal;
		
		//Sunday	
		sunSeats = jQuery("#totalSeatsSun").val();
		sunSeatsList = jQuery("#sunSeatsList").val();

/* 		runningOrderDescription += "prod=" + "Spitfire Grandstand 2 (Sunday 3rd July): " + sunSeats + " seat(s),item_amount=" + spitfireSeatPrice + "x" + sunSeats + ";" */

		runningOrderDescription += "prod=" + "Spitfire Grandstand 3 (Sunday 3rd July): " + sunSeats + " seat(s): " + sunSeatsList + ",item_amount=" + spitfireSeatPrice + "x" + sunSeats + ";"
		
		sunSeatsTotal = sunSeats * spitfireSeatPrice;
		
		runningTotal  = runningTotal + sunSeatsTotal;
		
	}

	
	if(depositchosen == true) {
	//console.log("Deposit option chosen");
		runningOrderDescription += "prod=deposit,item_amount=" + 40 + "x" + totalquantities + ";" // Aargh, a magic number!
		deposittotalprice = (40 * parseInt(totalquantities));
		jQuery("#deposittotal").val(deposittotalprice);
	}
	
	if(jQuery("#PP").length > 0) {
		if(jQuery("#PP").val()) { runningOrderDescription += "prod=SHIPPING,item_amount=" + parseFloat(jQuery("#PP").val()).toFixed(2); }
	}
		
	jQuery('#confirm-order-summary').val(runningDescription);
	
	jQuery('#order').val(runningOrderDescription);
	
	if(jQuery("#PP").length > 0) {
		if(jQuery("#PP").val()) { runningOrderDescription += "prod=SHIPPING,item_amount=" + parseFloat(jQuery("#PP").val()).toFixed(2); }
	}
		
	jQuery("#T").val(parseFloat(runningTotal) + parseFloat(jQuery("#PP").val()));
	// Final total T

	if(jQuery("#deposittotal").length > 0) {
	if(jQuery("#deposittotal").val() > 0) { jQuery("#T").val( jQuery("#deposittotal").val()); }
	}

	finVal = parseFloat(jQuery("#T").val());
	jQuery('#amount').val(finVal);

	}
	
	jQuery("#agreetosbutton").click(function() {
		jQuery("#addressconfirmation").val(jQuery("#bill_name").val()+"\n"+jQuery("#bill_addr_1").val()+"\n"+jQuery("#bill_addr_2").val()+"\n"+jQuery("#bill_city").val()+"\n"+jQuery("#bill_post_code").val());

	// Copy Shipping=billing
	jQuery("#ship_name").val(jQuery("#bill_name").val());
	jQuery("#ship_addr_1").val(jQuery("#bill_addr_1").val());
	jQuery("#ship_addr_2").val(jQuery("#bill_addr_2").val());
	jQuery("#ship_city").val(jQuery("#bill_city").val());
	jQuery("#ship_country").val(jQuery("#bill_country").val());
	jQuery("#ship_tel").val(jQuery("#bill_tel").val());
	jQuery("#ship_post_code").val(jQuery("#bill_post_code").val());
	jQuery("#ship_email").val(jQuery("#bill_email").val());
	});
		
	//jQuery("#last_confirm_email").val(jQuery('#bill_email').val());
	
	jQuery("ul.sf-menu").superfish();
	
    var root = jQuery("#wizard").scrollable();


/* Validation js for paging */

	jQuery(".gofinalpage").click(function() {
		if(!jQuery("#agree_to_tos:checked").length) {
			alert("Please tick the box to show that you accept our terms and conditions");
			return false
		} else {
			return true;
		}
	});
	
function formatSeatText(seat) {
	formattedSeat = seat.replace("row-", "")
	formattedSeat2 = formattedSeat.replace("seat-", "")	
	return formattedSeat2
}
	

	jQuery(".grandstandNext").click(function(){
		
		changeTicketQuantity(); // Update seats in hidden field
	
/*
		selectedSeatsSat = jQuery("table#grandstandSaturdayPlan").find("div.selected");
		jQuery("#numSelectedSeatsSaturday").val(selectedSeatsSat.length + " seats selected for Saturday 2nd July");

		selectedSeatsSun = jQuery("table#grandstandSundayPlan").find("div.selected");
		jQuery("#numSelectedSeatsSunday").val(selectedSeatsSun.length + " seats selected for Sunday 3rd July");
*/

	});


	jQuery("#saveContactDetails").click(function(){
	   $.ajax({
	   	   type: "POST",
	   	   url: "/booking_save_details",
	   	   data: "booking=" + jQuery("#trans_id").val() + "&name=" + jQuery("#bill_name").val() + "&address=" + jQuery("#bill_addr_1").val() + ", " + jQuery("#bill_addr_2").val() + "&city=" + jQuery("#bill_city").val() + "&postcode=" + jQuery("#bill_post_code").val() + "&country=" + jQuery("#bill_country").val() + "&email=" + jQuery("#bill_email").val() + "&telephone=" + jQuery("#bill_tel").val(),
	   	   success: function(msg){
	   	   }
	   });
	});

//	jQuery("a[rel='promo1']").colorbox({iframe:true, width:"848", height:"650"});
	jQuery("a[rel='promo2']").colorbox({iframe:true, width:"854", height:"754"});
	
	
});
