	/********************************
		BALANCE PAYMENT FUNCTIONS
	********************************/

	function CheckLogin(theform) {
		if (theform.uniquebookingID.value=="")  {
			alert("Your Booking Reference Code is either absent ot has the wrong number of characters...   \n");
			return false;
			}
		else return true;
		}

	function CheckPay(theform) {
		var msg="";
		if (theform.cardtype.selectedIndex==0) msg = "The Credit Card Type..\n";
		if (theform.cardholdersname.value=="") msg = msg + "The Credit Card Holder's Name..\n";
		if (theform.cardnumber.value=="") msg = msg + "The Credit Card Number..\n";
		if (theform.securitycode.value=="") msg = msg + "The Security Code..\n";
		if (theform.cardholdersaddress1.value=="") msg = msg + "The first line of the Card Holder's Address..\n";
		if (theform.cardholderstowncity.value=="") msg = msg + "The Credit Card Holder's Town/City..\n";
		if (theform.cardholderscounty.value=="") msg = msg + "The Credit Card Holder's County..\n";
		if (theform.cardholderscountry.value=="") msg = msg + "The Credit Card Holder's Country..\n";
		if (theform.cardholderspostcode.value=="") msg = msg + "The Credit Card Holder's Post Code..\n";
		if (msg!="")  {
			alert("Some detail are missing..\n\n" + msg);
			return false;
			}
		else return true;
		}

	function update_surcharge(ccselect,paymentcase,choosepaydamagedeposit)   {
		var selval, gtotal;
		selval = ccselect.selectedIndex;
		switch (paymentcase)  {
			case "1": 
					gtotal = Number(document.getElementById("osBalanceInit").innerHTML);
					add3percent(selval,gtotal,document.balpayform.monoutstandingbalance,"osBalance0");
					break;
			case "4": 
					if (choosepaydamagedeposit == "1")   {
						gtotal = Number(document.getElementById("osBalanceInit").innerHTML);
						add3percent(selval,gtotal,document.balpayform.monoutstandingbalance,"osBalance1");
						gtotal = Number(document.getElementById("damageDepInit").innerHTML);
						add3percent(selval,gtotal,document.balpayform.mondamagedeposit,"DamDeposit0");
						}
					else  {
						gtotal = Number(document.getElementById("osBalanceInit").innerHTML);
						add3percent(selval,gtotal,document.balpayform.monoutstandingbalance,"osBalance2");
						}
					break;
			}
		if (paymentcase==5 || paymentcase==6 )  {
			gtotal = Number(document.getElementById("damageDepInit").innerHTML);
			add3percent(selval,gtotal,document.balpayform.mondamagedeposit,"DamDeposit1");
			}
		}

	function add3percent(selval,gtotal,targetHiddenObject,displayValue)  {
		var gtotal, gtotal3, gtotalf, gtotaltext;
		// if selected card carries 3% surcharge 
		if (selval==4||selval==6||selval==1)   {
			gtotal3=(Math.round(gtotal * 3))/100;
			gtotalf=gtotal + gtotal3;
			gtotaltext="\u00A3" + sanitize_num(gtotal) + " + \u00A3" + sanitize_num(gtotal3) + " (3%) = \u00A3" + sanitize_num(gtotalf);
			targetHiddenObject.value=sanitize_num(gtotalf);
			}
		else   {
			gtotaltext="\u00A3" + sanitize_num(gtotal);
			targetHiddenObject.value=gtotal;
			}
		document.getElementById(displayValue).innerHTML=gtotaltext;
		}


	function sanitize_num(thenum)  {
		var strnum, pospos;
		strnum=thenum.toString();
		pospos=strnum.indexOf(".");
		if (pospos>-1)   {
			lenstr=strnum.length;
			if (lenstr-pospos==2) strnum=strnum+"0";
			else  {
				if (lenstr-pospos>3) strnum=strnum.substring(0,pospos+3);
				}
			}
		return strnum;
		}			


