//fullPrice is set by $bookingfee in formsinit.php (near top of page)
//The 3 numbers below are the discounted booking prices which can be edited. Only change the numbers.
var cutPrice1=    55	// Discounted some
var cutPrice2=    30	// Discounted lots
var freePrice =    0	// Free

	//Promo codes can be up to 10 letters and/or numbers with NO SPACES or other characters.
	//Codes MUST be entered here in UPPERCASE and in inverted commas (users may input upper or lowercase).
	//Don't edit anything other than the 3 words below in inverted commas.
var cutPrice1Coupon =	'SCHOOL SELECT' // Discounted some - promocode 
var cutPrice2Coupon =	'RAREHELP' // Discounted lots - promo code
var freePriceCoupon =	'VLUCKY1'  // Free 100% off promo code






//-------------------DO NOT EDIT BELOW HERE----------------------------


function showDiscountedPrice() {

var fullCell = document.getElementById ('fullPriceCell');
var codeInput = document.getElementById ('coupon');
var applyCell = document.getElementById ('couponApplyCell');
var promoInstruct = document.getElementById ('promoTag');
var defCode=document.forms[0].coupon.defaultValue.toUpperCase();
var couponCode=document.forms[0].coupon.value.toUpperCase();

switch (couponCode) {
 case cutPrice1Coupon:
	fullCell.innerHTML='<div style="font-weight:normal; padding-bottom:5px">&pound;'+fullPrice + '&nbsp; less promo discount = <strong><span style="font-size:105%">&pound;'+cutPrice1+'</span></strong></div>';
	codeInput.style.display="none";
	applyCell.innerHTML='<a href ="javascript:;" onClick="resetCoupon()" style="font-weight:normal; line-height:1.5em; font-size:80%">Remove Discount</a>';
	promoInstruct.style.display="none";
	discountedPrice = cutPrice1;

  	break;

  case cutPrice2Coupon:
	fullCell.innerHTML='<div style="font-weight:normal; padding-bottom:5px">&pound;'+fullPrice + '&nbsp; less promo discount = <strong><span style="font-size:105%">&pound;'+cutPrice2+'</span></strong></div>';
	codeInput.style.display="none";
	applyCell.innerHTML='<a href ="javascript:;" onClick="resetCoupon()" style="font-weight:normal; font-size:80%">Remove Discount</a>';
	promoInstruct.style.display="none";
	discountedPrice = cutPrice2;
  	break;

  case freePriceCoupon:
	fullCell.innerHTML='<div style="font-weight:normal; padding-bottom:5px;">&pound;'+fullPrice + '&nbsp; less promo discount = <strong><span style="font-size:105%">&pound;'+freePrice+'</span></strong></div>';
	codeInput.style.display="none";
	applyCell.innerHTML='<a href ="javascript:;" onClick="resetCoupon()" style="font-weight:normal; font-size:80%">Remove Discount</a>';
	promoInstruct.style.display="none";
	discountedPrice = freePrice;
  	break;

  case '':
	document.forms[0].coupon.value=document.forms[0].coupon.defaultValue;
	break;

  case defCode:
  	break;

  default:
  	document.forms[0].coupon.value="Invalid code";
  }

document.forms[0].discount.value = fullPrice - discountedPrice; //sets hidden field in dcentry
}


function resetCoupon () {
var fullCell = document.getElementById ('fullPriceCell');
var codeInput = document.getElementById ('coupon');
var applyCell = document.getElementById ('couponApplyCell');
var promoInstruct = document.getElementById ('promoTag');
	promoInstruct.style.display="inline";
	document.forms[0].coupon.value=document.forms[0].coupon.defaultValue;
	discountedPrice = fullPrice;
document.forms[0].discount.value = fullPrice - discountedPrice; //sets hidden field in dcentry

	fullCell.innerHTML='&pound;'+fullPrice.toFixed(2);//2 decimal places
	codeInput.style.display="inline";
	applyCell.innerHTML='<input type="button" value=" Apply" onClick="showDiscountedPrice()" class=smallbutton style="position:relative; top:-5px; font-size:90%;">';
}

function clearField(theField) {
	if (theField.defaultValue==theField.value || theField.value=="Invalid code") theField.value=""
}
