

function generateform() {

var formdiv,content,nameU,emailU,sname,fname;
sname=""; fname="";
var theForm = document.form1;
formdiv=document.getElementById("multipleform");

content="<div id='Warning_mess'  style='display:none;'><table cellSpacing=0 cellPadding=0 align=center bgColor=#ffffff  border=0><tr><td  borderColor=#ffffff class='stylewarn'>Please correct the highlighted items to continue</td></tr></table></div>";
				
content+="<form id=form1 name=form1  method=post action='../proc_files/process1210.php5'>";

// -------Step1 Loan Details--------
content+="<div id='step1'  style='display:block'>";

	content+="<table cellSpacing=0 cellPadding=5 align=center bgColor=#ffffff  border=0><tr><td  borderColor=#ffffff>";
	content+="<table align=center bgColor=#ffffff collspanning=0 cellspaning=0>";
	content+="<tr><td  align='center' colspan=2 height=25px background='images/bggrey.gif' bgcolor='#ffffff'><div class='heading1' background='images/bggrey.gif'>Step 1 : &nbsp; How much do you need to borrow for your Buy to Let </div></td></tr>";

    content+="<tr><td height=5px> </td></tr>";
	content+="<tr><td height=30px><div class='middleR'>  Loan Amount &nbsp&pound;&nbsp;</div></td><td  valign='middle'  align=left><input name='LoanAmount' id='LoanAmount' type='text' value='' size='10'  onChange=this.style.background='#FFFFFF'></td></tr>";
//	content+="<tr><td  height=30px><div class='middleform'>  When is the Loan required &nbsp;</div></td><td  valign='middle' align=left><select name='HowSoonDoYouNeedTheMoney' id='HowSoonDoYouNeedTheMoney'><option value='Not Set'></option><option value='ASAP'>ASAP</option><option value='Within Next Month'>Within Next Month</option><option value='Within Next 3 Months'>Within Next 3 Months</option><option value='Not Urgent'>Not Urgent</option></select></td></tr>";
	content+="<input name='HowSoonDoYouNeedTheMoney' type='hidden' value='Not Set'>";
	content+="<tr><td height=30px><div class='middleR'>  Repayment Period(years) &nbsp;</div></td><td  valign='middle'  align=left><input name='OverHowManyYears' id='OverHowManyYears' ='text' value='' size='10'  onChange=this.style.background='#FFFFFF'></td></tr>";
	content+="<input name='PurposeOfLoan' type='hidden' value='Buy to Let'>";
	content+="<input name='OwnerShipStatus' type='hidden' value='Not Set'>";
    content+="<input name='PropertyConstruction' type='hidden' value='Not Set'>";
	content+="<input name='DateOfPurchase' type='hidden' value='Not Set'>";
	content+="<tr><td height=20px>&nbsp; </td></tr>";
	content+="<tr><td height=30px><div style='font-size:12px;text-align:left;font-weight:normal;padding-left:10px;' valign=middle> </td><td align='left'><input type='button' value='Click to proceed to Step 2' style='margin-right:20px;' class='button' onclick='step1()'></td></tr>";
//	content+="<tr><td  colspan=2 height='30px'><div style='background:#ffffff;height:30px;line-height:30px;letter-spacing: 0px;font-size:11px;color:#6793d4;text-align:center;font-weight:normal;'> Privacy Policy: <font color=#000000;>Unless instructed to do so, we will not share your details with any other third parties.</div></td></tr>";
	content+="</table>"
	content+="</td></tr></table>";
content+="</div>";




//-- Step 2 Personal Details --------
content+="<div id='step2'  style='display:none'>";
	content+="<table cellSpacing=0 cellPadding=5 align=center bgColor=#ffffff  border=0><tr><td  borderColor=#ffffff>";
	content+="<table align=center bgColor=#ffffff collspanning=0 cellspaning=0>";
	content+="<tr><td  align='center' colspan='2' height='25px' background='images/bggrey.gif'><div class='heading1'>Step 2: &nbsp; Your Personal Details (to determine how much you can borrow)</div></td></tr>";
    content+="<tr><td height=5px> </td></tr>";
	content+="<tr><td height=30px><div class='middleR'>  Date of Birth &nbsp;</div></td><td   valign='top'  align=left><div class='middleL'><select name='DOBd' id='DOBd' class='middleL' onChange=this.style.background='#ffffff'>";
	content+="<option value='0'>dd</option><option value='1'>1</option><option value='02'>2</option><option value='03'>3</option><option value='04'>4</option><option value='05'>5</option><option value='06'>6</option><option value='07'>7</option><option value='08'>8</option><option value='09'>9</option><option value='10'>10</option><option value='11'>11</option><option value='12'>12</option><option value='13'>13</option><option value='14'>14</option><option value='15'>15</option><option value='16'>16</option><option value='17'>17</option><option value='18'>18</option><option value='19'>19</option><option value='20'>20</option><option value='21'>21</option><option value='22'>22</option><option value='23'>23</option><option value='24'>24</option><option value='25'>25</option><option value='26'>26</option><option value='27'>27</option><option value='28'>28</option><option value='29'>29</option><option value='30'>30</option><option value='31'>31</option></select>";
	content+="&nbsp;<select name='DOBm' id='DOBm' class='middleL' onChange=this.style.background='#ffffff'>";
	content+="<option value='0'>mm</option><option value='01'>Jan</option><option value='02'>Feb</option><option value='03'>Mar</option><option value='04'>Apr</option><option value='05'>May</option><option value='06'>Jun</option><option value='07'>Jul</option><option value='08'>Aug</option><option value='09'>Sep</option><option value='10'>Oct</option><option value='11'>Nov</option><option value='12'>Dec</option></select>";
	content+="&nbsp;<select name='DOBy' id='DOBy' class='middleL' onChange=this.style.background='#ffffff'>";
	content+="<option value='0'>yyyy</option><option value='1937'>1937</option><option value='1938'>1938</option><option value='1939'>1939</option><option value='1940'>1940</option><option value='1941'>1941</option><option value='1942'>1942</option><option value='1943'>1943</option><option value='1944'>1944</option><option value='1945'>1945</option><option value='1946'>1946</option><option value='1947'>1947</option><option value='1948'>1948</option><option value='1949'>1949</option><option value='1950'>1950</option><option value='1951'>1951</option><option value='1952'>1952</option><option value='1953'>1953</option><option value='1954'>1954</option><option value='1955'>1955</option><option value='1956'>1956</option><option value='1957'>1957</option><option value='1958'>1958</option><option value='1959'>1959</option><option value='1960'>1960</option><option value='1961'>1961</option><option value='1962'>1962</option><option value='1963'>1963</option><option value='1964'>1964</option><option value='1965'>1965</option><option value='1966'>1966</option><option value='1967'>1967</option><option value='1968'>1968</option><option value='1969'>1969</option><option value='1970'>1970</option><option value='1971'>1971</option><option value='1972'>1972</option><option value='1973'>1973</option><option value='1974'>1974</option><option value='1975'>1975</option><option value='1976'>1976</option><option value='1977'>1977</option><option value='1978'>1978</option><option value='1979'>1979</option><option value='1980'>1980</option><option value='1981'>1981</option><option value='1982'>1982</option><option value='1983'>1983</option><option value='1984'>1984</option><option value='1985'>1985</option><option value='1986'>1986</option><option value='1987'>1987</option><option value='1988'>1988</option><option value='1989'>1989</option><option value='1990'>1990</option></select></div></td></tr>";
	content+="<input name='JobTitle' type='hidden' value=''>";
	content+="<tr><td height=30px><div class='middleR'>  Monthly Salary &pound;&nbsp;</div></td><td   valign='top'  align=left><input name='MonthlySalary' id='MonthlySalary' type='text' maxlength='30' style='margin:0;padding:0;font-size:12px;'  onChange=this.style.background='#ffffff'></td></tr>";
	content+="<input name='MonthlyBonus' type='hidden' value=''>";
	content+="<input name='PensionsOrBenefits' type='hidden' value=''>";
    content+="<tr><td height=20px>&nbsp; </td></tr>";
	content+="<tr><td  valign=middle align=left style='padding-left:10px;'   height=30px><input type='button' value='Back' class='button' onclick='step2back()'> </td><td align='right'><input type='button' value='Click to proceed to Final Step ' style='margin-right:20px;' class='button' onclick='step2()'></td></tr>";

//	content+="<tr><td  colspan=2 height='30px'><div style='background:#f5f5f5;height:30px;line-height:30px;letter-spacing: 0px;font-size:11px;color:#666666;text-align:center;font-weight:normal;'> Privacy Policy: Unless instructed to do so, we will not share your details with any other third parties.</div></td></tr>";
	content+="</table>"
	content+="</td></tr></table>";
content+="</div>";

//-- Final Step Contact Details -----------
content+="<div id='finalstep'  style='display:none;'>";
	content+="<table cellSpacing=0 cellPadding=5 align=center bgColor=#ffffff  border=0><tr><td  borderColor=#ffffff>";
	content+="<table align=center bgColor=#ffffff collspanning=0 cellspaning=0>";
	content+="<tr><td  align='center' colspan='2' height='25px' background='images/bggrey.gif'><div class='heading1'>Final Step: &nbsp; Where should we send your Rate Comparison to ?</div></td></tr>";
	content+="<tr><td height='5px'> </td></tr>";
	content+="<tr><td height=30px><div class='middleR'>   First Name &nbsp;</div></td><td  valign='middle' align=left><input name='Firstname' type='text' size='30' style='margin:0;padding:0;font-size:12px;' onChange=this.style.background='#FFFFFF'></td></tr>";
	content+="<tr><td height=30px><div class='middleR'>   Surname &nbsp;</div></td><td  valign='middle' align=left> <input maxLength=255 size='30' name='Surname' style='margin:0;padding:0;font-size:12px;' onChange=this.style.background='#FFFFFF'></td></tr>";
	content+="<tr><td height=30px><div class='middleR'>   Email Address &nbsp;</div></td><td  valign='middle' align=left><input name='EmailAddress' type='text' size='30' style='margin:0;padding:0;font-size:12px;' onChange=this.style.background='#ffffff'></td></tr>";
	content+="<tr><td height=30px><div class='middleR'>   Telephone number &nbsp;</div></td><td  valign='middle' align=left><input name='DaytimePhone' type='text'  size='30' style='margin:0;padding:0;font-size:12px;' onChange=this.style.background='#FFFFFF'></td></tr>";
	content+="<input name='EveningPhone' type='hidden' value=''>";
	content+="<input name='MobilePhone'  type='hidden' value=''>";
	content+="<tr><td height=30px><div class='middleR'>   Address Line 1 &nbsp;</div></td><td  valign='middle' align=left><input name='Address1' type='text' value=''  size='30' style='margin:0;padding:0;font-size:12px;' onChange=this.style.background='#FFFFFF'></td></tr>";
content+="<input name='Address2' type='hidden' value=''>";
//content+="<tr><td height=30px><div style='font-size:12px;color:#969696;text-align:right;font-weight:normal;padding-left:10px;'>   Address Line 2 &nbsp;</div></td><td  valign='middle' align=left><input name='Address2' type='text' value=''  size='30' style='margin:0;padding:0;font-size:12px;'> </td></tr>";
	content+="<input name='merchID2' id='merchID2' type='hidden' value=''>";
	content+="<tr><td height=30px><div class='middleR'>   Town &nbsp;</div></td><td  valign='middle' align=left><input name='Town' type='text' value=''  size='30' style='margin:0;padding:0;font-size:12px;' onChange=this.style.background='#ffffff'></td></tr>";
	content+="<tr><td height=30px><div class='middleR'>   County &nbsp;</div></td><td  valign='middle' align=left><input name='County' type='text' value=''  size='30' style='margin:0;padding:0;font-size:12px;' onChange=this.style.background='#ffffff'></td></tr>";
	content+="<tr><td height=30px><div class='middleR'>   Post Code &nbsp;</div></td><td  valign='middle' align=left><input name='Postcode' type='text' value=''  size='30' style='margin:0;padding:0;font-size:12px;' onChange=this.style.background='#FFFFFF'></td></tr>";
	content+="<tr><td height=30px><div class='middleR'>   Best time to call you &nbsp;</div></td><td  valign='middle' align=left><input name='BestTimeToCall' type='text' size='30' style='margin:0;padding:0;font-size:12px;' onChange=this.style.background='#FFFFFF'></td></tr>";
    content+="<tr><td height=20px>&nbsp; </td></tr>";
	content+="<tr><td height=30px align='left'><input type='button' value='Back' class='button' onclick='finalstepback()'> </td><td align='right' valign=middle><input type='button' value='Click to Compare Buy to Let Rates' style='margin-right:20px;' class='button' onclick='submit_form()'></td></tr>";
//	content+="<tr><td colspan=2 height='30px'><div style='background:#f5f5f5;height:30px;line-height:30px;letter-spacing: 0px;font-size:11px;color:#666666;text-align:center;font-weight:normal;'>Privacy Policy: Unless instructed to do so, we will not share your details with any other third parties.</div></td></tr>";
	
<!--- REMOVE AFTER TESTING SUBMIT make above button submit------->	
//content+="<tr><td colspan=2 height=30px align='left'><input name='SubmitForm' value='Test Submit Form' class='button' type='button' onclick='submit_form()'></td></tr>";
<!-------------------------------------->	
	content+="</table>"
	content+="</td></tr></table>";

content+="</div>";



content+="</form>";
formdiv.innerHTML=content;
//showltv();
}

var msg = 'Please correct the highlighted items before continuing ...\n';
var field;var alpha = /\w/;
var numeric = /[^0-9^\s]/;var invalid = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
var valid = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
var dateformat1=/^\d{4}\-\d{2}\-\d{2}$/; var dateformat2=/^\d{4}\ \d{2}\ \d{2}$/;
var alphanumeric = /^[a-zA-Z 0-9\-\/\,\n\r\&\.\']+$/;
var elem = document.getElementById(field);
var err1 = false;var err2=false;var errSubmit=false;
var theForm = document.form1;
var paaemail=/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;


// -------step 1 verification--------
function step1(){
var theForm = document.form1;
err1=false;
var msg = 'Please correct the following to continue ...\n';var field;var alpha = /\w/;var numeric = /[^0-9^\s]/;var invalid = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;var valid = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;

if (checkNumber("LoanAmount")){
	msg += '\n\"Loan Amount\" must be a valid number. Please do not enter commas, letters or pound signs.';
	field=theForm.LoanAmount;
	highlite(field);
	//theForm.LoanAmount.style.background="#FFB3B3";
	//document.getElementById("LoanAmount").style.background="#FFB3B3";
	err1 = true;
	}

if (checkNumber("OverHowManyYears")){
	msg += '\n\"Payment Period\" must be a valid number. Please do not enter commas or letters.';
	field=theForm.OverHowManyYears;
	highlite(field);
	//theForm.OverHowManyYears.style.background="#FFB3B3";
	//document.getElementById("OverHowManyYears").style.background="#FFB3B3";
	err1=true;
		}
	if(err1==true)  {
		show("Warning_mess");
		alert(msg);
		field.focus();
		
	}else {
	
	hide("step1");
	show("step2");		
	hide("Warning_mess");
	if(err2==true) {show("Warning_mess");
	}else{
		hide("Warning_mess");}
	
	
	
	}

}
// -------step2 verification--------


function step2(){
var theForm = document.form1;
err2=false;
var msg = 'Please correct the following to continue ...\n';var field;var alpha = /\w/;var numeric = /[^0-9^\s]/;var invalid = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;var valid = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;

theForm.MonthlySalary.value=trimInput(theForm.MonthlySalary.value);

if (checkNumber("DOBd") || (theForm.DOBd.value >31) || (theForm.DOBd.value <1)){
	msg += '\n\"Day\" must be a valid number.';
	field=theForm.DOBd;
	highlite(field);
	//theForm.DOBd.style.background="#FFB3B3";
	//document.getElementById("DOBd").style.background="#FFB3B3";
	err2 = true;
		}	

if (checkNumber("DOBm") || (theForm.DOBm.value >12) || (theForm.DOBm.value <1)){
	msg += '\n\"Month\" must be a valid number.';
	field=theForm.DOBm;
	highlite(field);
	//theForm.DOBm.style.background="#FFB3B3";
	//document.getElementById("DOBm").style.background="#FFB3B3";
	err2 = true;
		}	

if (checkNumber("DOBy") || (theForm.DOBy.value >2000) || (theForm.DOBy.value <1900)){
	msg += '\n\"Year\" must be a valid number.';
	field=theForm.DOBy;
	highlite(field);
	//theForm.DOBy.style.background="#FFB3B3";
	
	//document.getElementById("DOBy").style.background="#FFB3B3";
	err2 = true;
		}	

if (checkNumber("MonthlySalary")){
	msg += '\n\"Monthly Salary\" must be a valid number. Please do not enter commas, letters or pound signs.';
	//theForm.MonthlySalary.style.background="#FFB3B3";
	//document.getElementById("MonthlySalary").style.background="#FFB3B3";
	field=theForm.MonthlySalary;
	highlite(field);
	err2 = true;
		}

if(err2==true)  {
			alert(msg);
			field.focus();
			show("Warning_mess");
		}else {
		hide("step2");
		show("finalstep");
			if(errSubmit==true) {show("Warning_mess");
			}else{
			hide("Warning_mess");
			}
		}
}


function submit_form(){
	errSubmit = false;
	var theForm = document.form1;
	var msg = 'Please correct the highlighted items before continuing ...\n';

			for (var i=0; i< theForm.length; i+=1){
			if (theForm[i].type=="text"){
				//alert(i+"  "+theForm[i].name+" : "+ theForm[i].value);
				theForm[i].value=trimInput(theForm[i].value);
					if(!strPresent(theForm[i].value)){
						field = theForm[i];
						if(field.name!="EmailAddress"){
							highlite(field);
							msg += '\n\ '+ field.name;
									errSubmit = true;}	   
																   
										   }
								}
			}





if (strPresent(theForm.EmailAddress.value) && (!paaemail.test(theForm.EmailAddress.value))){
	field = theForm.EmailAddress;
	highlite(field);
	msg += '\n\Valid email address (name@domain.com/co.uk etc)';
	errSubmit = true;
		}	




if (checkPostCode(theForm.Postcode.value)){
theForm.Postcode.value=checkPostCode(theForm.Postcode.value);	
}else{
field = theForm.Postcode;
highlite(field);
	msg += '\n\Valid UK Postcode';
	errSubmit = true;
}

if (strPresent(theForm.DaytimePhone.value) && !checktelNo(theForm.DaytimePhone.value)){
field = theForm.DaytimePhone;
highlite(field);
	msg += '\n\Valid Telephone No.';
	errSubmit = true;
}


if (strPresent(theForm.Firstname.value) && !alphanumeric.test(theForm.Firstname.value)){
field = theForm.Firstname;
highlite(field);
	msg += '\n\Firstname';
	errSubmit = true;
}

if (strPresent(theForm.Surname.value) && !alphanumeric.test(theForm.Surname.value)){
field = theForm.Surname;
highlite(field);
	msg += '\n\Surname';
	errSubmit = true;
}

if (strPresent(theForm.Address1.value) && !alphanumeric.test(theForm.Address1.value)){
field = theForm.Address1;
highlite(field);
	msg += '\n\Address1';
	errSubmit = true;
}

if (strPresent(theForm.Town.value) && !alphanumeric.test(theForm.Town.value)){
field = theForm.Town;
highlite(field);
	msg += '\n\Town';
	errSubmit = true;
}

if (strPresent(theForm.County.value) && !alphanumeric.test(theForm.County.value)){
field = theForm.County;
highlite(field);
	msg += '\n\County';
	errSubmit = true;
}
if (strPresent(theForm.BestTimeToCall.value) && !alphanumeric.test(theForm.BestTimeToCall.value)){
field = theForm.BestTimeToCall;
highlite(field);
	msg += '\n\BestTimeToCall';
	errSubmit = true;
}


		if(errSubmit==true)  {
			show("Warning_mess");
			alert(msg);
			field.focus();
		}else {
		hide("Warning_mess");	
		//alert("Form would have been submitted OK");
		//Strip numbers
		theForm.DaytimePhone.value=stripInput(theForm.DaytimePhone.value,"-");
		theForm.DaytimePhone.value=stripInput(theForm.DaytimePhone.value," ");		
		if (theForm.EmailAddress.value==""){theForm.EmailAddress.value="no@email.com";}
		var elem=document.getElementById("merchID").value;
		document.getElementById("merchID2").value=elem;
		var elem2=document.getElementById("merchID2").value;
		//alert (elem2);
		theForm.submit();
		}
}//end of submit





function finalstepback(){
		hide("finalstep");
		show("step2");
		hide("Warning_mess");
}
function step2back(){
		hide("step2");
		show("step1");
		hide("Warning_mess");
}



function showltv()
{
	var display_text = '' ;
	var theForm = document.form1;

	if (document.all || document.layers) {
		MM_setTextOfLayer(window.ltvdesc,'',display_text);

	} else {
		MM_setTextOfLayer("ltvdesc",'',display_text);
	}
}

function KeyPress(iField,e,max,action) {
	if(document.layers){	if(e.target.value.length >= max) eval(action);}
		else if(document.all){ if(iField.value.length > (max-1)) eval(action);}
			else if(document.getElementById){if(iField.value.length >= max)	eval(action);}
}

function formatnum(amount,X) {
	// rounds number to X decimal places, defaults to 2
	//X = (!X ? 2 : X);
	//return Math.round(amount*Math.pow(10,X))/Math.pow(10,X);
	return Math.ceil(amount)
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	var ck = name+"="+value+expires+"; path=/";
	// if (days != -1) alert('Cookie\n' + ck + '\ncreated');
	document.cookie = ck;
}


function trimInput(sStr)
{
//return str.replace(/^\s*|\s*$/,"");

while (sStr.substring(0,1) == ' ')
{
sStr = sStr.substring(1, sStr.length);
}
while (sStr.substring(sStr.length-1, sStr.length) == ' ')
{
sStr = sStr.substring(0,sStr.length-1);
}
return sStr;
}

function stripInput(Str,sStr){
	sStr=eval("/"+sStr+"/gi");
	Str=Str.replace(sStr, "");
	//tmpStr=tmpStr.replace(/-/gi, "");
	return Str;
	}


function checkNumber(field){

var elem = document.getElementById(field);

if ((isNaN(elem.value)) || (!alpha.test(elem.value))){
	return true;
		}else{
	return false;
		}
}

function checkPostCode (toCheck) {

  // Permitted letters depend upon their position in the postcode.
  var alpha1 = "[abcdefghijklmnoprstuwyz]";                       // Character 1
  var alpha2 = "[abcdefghklmnopqrstuvwxy]";                       // Character 2
  var alpha3 = "[abcdefghjkstuw]";                                // Character 3
  var alpha4 = "[abehmnprvwxy]";                                  // Character 4
  var alpha5 = "[abdefghjlnpqrstuwxyz]";                          // Character 5
  

  // Array holds the regular expressions for the valid postcodes
  var pcexp = new Array ();

  // Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA
  pcexp.push (new RegExp ("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1,2})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i"));
  
  // Expression for postcodes: ANA NAA
  pcexp.push (new RegExp ("^(" + alpha1 + "{1}[0-9]{1}" + alpha3 + "{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i"));

  // Expression for postcodes: AANA  NAA
  pcexp.push (new RegExp ("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1}" + alpha4 +"{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i"));
  
  // Exception for the special postcode GIR 0AA
  pcexp.push (/^(GIR)(\s*)(0AA)$/i);
  
  // Standard BFPO numbers
  pcexp.push (/^(bfpo)(\s*)([0-9]{1,4})$/i);
  
  // c/o BFPO numbers
  pcexp.push (/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i);

  // Load up the string to check
  var postCode = toCheck;

  // Assume we're not going to find a valid postcode
  var validPC = false;
  
  // Check the string against the types of post codes
  for ( var i=0; i<pcexp.length; i++) {
    if (pcexp[i].test(postCode)) {
    
      // The post code is valid - split the post code into component parts
      pcexp[i].exec(postCode);
      
      // Copy it back into the original string, converting it to uppercase and
      // inserting a space between the inward and outward codes
      postCode = RegExp.$1.toUpperCase() + " " + RegExp.$3.toUpperCase();
      
      // If it is a BFPO c/o type postcode, tidy up the "c/o" part
      postCode = postCode.replace (/C\/O\s*/,"c/o ");
      
      // Load new postcode back into the form element
      validPC = true;
      
      // Remember that we have found that the code is valid and break from loop
      break;
    }
  }
  
  // Return with either the reformatted valid postcode or the original invalid 
  // postcode
  if (validPC) {return postCode;} else return false;
}

function strPresent(toCheck){
	var emptyString = /^\s*$/ ;
	
	if((toCheck!='') || (!emptyString.test(toCheck))){
	return true;
	}else{
	return false;
	}
}

function checktelNo(toCheck){
    var telnr = /^\+?[0-9 ()-]+[0-9]$/  ;
	var tmpStr;
	tmpStr=stripInput(toCheck," ");
	tmpStr=stripInput(tmpStr,"-");
	
	if (telnr.test(toCheck)&& tmpStr.length>3 && tmpStr.length<21) {
	return true;		
	}else{return false;}
}


function highlite(field){
field.style.background="#FFB3B3";
}

function hide(id){
	elem=document.getElementById(id);
    if(elem)
    	elem.style.display='none';
}
function show(id){
    elem=document.getElementById(id);
    if(elem)
    	elem.style.display='block';
}
