<!--

function validate_form ( )
{
		
	var rads = document.callmebackform.resstatus;
	var res='';
	  for(var i=0;i<rads.length;i++) 
	  {
		if(rads[i].checked) 
		{
		  	res=rads[i].value;
			break;
		}
	  }	

	valid = true;
		
		if (res == "" )
		{
               alert ( "Please enter your residential status." );
				document.getElementById('statuslabel').style.color = "#FF0000";
                valid = false;
				return false;
        }
		document.getElementById('statuslabel').style.color = "#366AB4";
		
		if ( document.callmebackform.loanamount.value == "" )
        {
                alert ( "Please enter the amount you would like to borrow." );
				document.getElementById('loanamountlabel').style.color = "#FF0000";
                valid = false;
				return false;
        }

		document.getElementById('loanamountlabel').style.color = "#366AB4";		
		if ( document.callmebackform.loanterm.selectedIndex == 0 )
        {
                alert ( "Please choose the term of the loan." );
				document.getElementById('loantermlabel').style.color = "#FF0000";
                valid = false;
				return false;
        }
		document.getElementById('loantermlabel').style.color = "#366AB4";
        if ( document.callmebackform.loanpurpose.selectedIndex == 0 )
        {
                alert ( "Please choose the purpose of the loan." );
				document.getElementById('loanpurposelabel').style.color = "#FF0000";
                valid = false;
				return false
        }
		document.getElementById('loanpurposelabel').style.color = "#366AB4";
		if ( document.callmebackform.name.value == "" )
        {
                alert ( "Please enter your name." );
				document.getElementById('namelabel').style.color = "#FF0000";
                valid = false;
				return false;
        }
		document.getElementById('namelabel').style.color = "#366AB4";
		if ( document.callmebackform.address1.value == "" )
        {
                alert ( "Please enter the first line of your address." );
				document.getElementById('address1label').style.color = "#FF0000";
                valid = false;
				return false;
        }
		document.getElementById('address1label').style.color = "#366AB4";
		if ( document.callmebackform.town.value == "" )
        {
                alert ( "Please enter your town/city." );
				document.getElementById('townlabel').style.color = "#FF0000";
                valid = false;
				return false;
        }
		document.getElementById('townlabel').style.color = "#366AB4";
		if ( document.callmebackform.postcode.value == "" )
        {
                alert ( "Please enter your postcode." );
				document.getElementById('postcodelabel').style.color = "#FF0000";
                valid = false;
				return false;
        }


/*

  // 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 = document.callmebackform.postcode.value;

  // Assume we're not going to find a valid postcode
  var valid = false;
  
  // Check the string against the types of post codes
  for ( var i=0; i<pcexp.length; i++) {
    if (pcexp[i].test(postCode)) {
      break;
    }
	else
	{
	                alert ( "Please enter a valid postcode." );
				document.getElementById('postcodelabel').style.color = "#FF0000";
                valid = false;
				return false;
	}
  }

*/

		document.getElementById('postcodelabel').style.color = "#366AB4";
		if ( document.callmebackform.phone.value == "" )
        {
                alert ( "Please enter your home telephone number." );
				document.getElementById('phonelabel').style.color = "#FF0000";
                valid = false;
				return false;
        }  		
		if ( document.callmebackform.phone.value == "" )
        {
                alert ( "Please enter the your telephone number." );
				document.getElementById('phonelabel').style.color = "#FF0000";
                valid = false;
				return false;
        }
		document.getElementById('phonelabel').style.color = "#366AB4";
		if ( document.callmebackform.email.value == "" )
        {
                alert ( "Please enter your email address." );
				document.getElementById('emaillabel').style.color = "#FF0000";
                valid = false;
				return false;
        }
		document.getElementById('emaillabel').style.color = "#366AB4";
		if ( document.callmebackform.adversecredit.value == "-1" )
        {
                alert ( "Please indicate whether you have adverse credit." );
				document.getElementById('adversecreditlabel').style.color = "#FF0000";
                valid = false;
				return false;
        }
		document.getElementById('adversecreditlabel').style.color = "#366AB4";

		  var telephoneNumber = document.callmebackform.phone.value;
		  // Convert into a string and check that we were provided with something
		  var telnum = telephoneNumber + " ";
		  if (telnum.length == 1)  {
			 alert ( "Telephone number not provided" );
				document.getElementById('phonelabel').style.color = "#FF0000";
			 return false
		  }
		  telnum.length = telnum.length - 1;
		  
		  // Don't allow country codes to be included (assumes a leading "+")
		  var exp = /^(\+)[\s]*(.*)$/;
		  if (exp.test(telnum) == true) {
			 alert ( "UK telephone number includes the country code, please remove." );
				document.getElementById('phonelabel').style.color = "#FF0000";
			 return false;
		  }
		  
		  // Remove spaces from the telephone number to help validation
		  while (telnum.indexOf(" ")!= -1)  {
			telnum = telnum.slice (0,telnum.indexOf(" ")) + telnum.slice (telnum.indexOf(" ")+1)
		  }
		  
		  // Remove hyphens from the telephone number to help validation
		  while (telnum.indexOf("-")!= -1)  {
			telnum = telnum.slice (0,telnum.indexOf("-")) + telnum.slice (telnum.indexOf("-")+1)
		  }  
		  
		  // Now check that all the characters are digits
		  exp = /^[0-9]{10,11}$/
		  if (exp.test(telnum) != true) {
			 alert ( "UK telephone numbers should contain 10 or 11 digits" );
				document.getElementById('phonelabel').style.color = "#FF0000";
			 return false;
		  }
		  
		  // Now check that the first digit is 0
		  exp = /^0[0-9]{9,10}$/
		  if (exp.test(telnum) != true) {
			 alert ( "The telephone number should start with a 0" );
				document.getElementById('phonelabel').style.color = "#FF0000";
			 return false;
		  }
		  
		  // Finally check that the telephone number is appropriate.
		  exp = /^(01|02|03|05|070|077|078|079)[0-9]+$/;
		  if (exp.test(telnum) != true) {
			 alert ( "The alternate telephone number is either invalid or inappropriate" );
				document.getElementById('phonelabel').style.color = "#FF0000";
			 return false;
		  }
		  
		document.getElementById('phonelabel').style.color = "#366AB4";
		if ( document.callmebackform.alternatephone.value !== "" )
        {
			  var alternateTelephoneNumber = document.callmebackform.alternatephone.value;
			  // Convert into a string and check that we were provided with something
			  var telnum = alternateTelephoneNumber + " ";
	//		  if (telnum.length == 1)  {
	//			 alert ( "elephone number not provided" );
	//			 return false
	//		  }
			  telnum.length = telnum.length - 1;
			  
			  // Don't allow country codes to be included (assumes a leading "+")
			  var exp = /^(\+)[\s]*(.*)$/;
			  if (exp.test(telnum) == true) {
				 alert ( "Alternate UK telephone number includes the country code, please remove." );
				document.getElementById('alternatephonelabel').style.color = "#FF0000";
				 return false;
			  }
			  
			  // Remove spaces from the telephone number to help validation
			  while (telnum.indexOf(" ")!= -1)  {
				telnum = telnum.slice (0,telnum.indexOf(" ")) + telnum.slice (telnum.indexOf(" ")+1)
			  }
			  
			  // Remove hyphens from the telephone number to help validation
			  while (telnum.indexOf("-")!= -1)  {
				telnum = telnum.slice (0,telnum.indexOf("-")) + telnum.slice (telnum.indexOf("-")+1)
			  }  
			  
			  // Now check that all the characters are digits
			  exp = /^[0-9]{10,11}$/
			  if (exp.test(telnum) != true) {
				 alert ( "Alternate UK telephone number should contain 10 or 11 digits" );
				document.getElementById('alternatephonelabel').style.color = "#FF0000";
				 return false;
			  }
			  
			  // Now check that the first digit is 0
			  exp = /^0[0-9]{9,10}$/
			  if (exp.test(telnum) != true) {
				 alert ( "The alternate telephone number should start with a 0" );
				document.getElementById('alternatephonelabel').style.color = "#FF0000";
				 return false;
			  }
			  
			  // Finally check that the telephone number is appropriate.
			  exp = /^(01|02|03|05|070|077|078|079)[0-9]+$/;
			  if (exp.test(telnum) != true) {

				 alert ( "The telephone number is either invalid or inappropriate" );
				document.getElementById('alternatephonelabel').style.color = "#FF0000";
				 return false;
			  }
		}
		document.getElementById('alternatephonelabel').style.color = "#366AB4";
		var emailStr = document.callmebackform.email.value;
		
		/* The following variable tells the rest of the function whether or not
		to verify that the address ends in a two-letter country or well-known
		TLD.  1 means check it, 0 means don't. */
		
		var checkTLD=1;
		
		/* The following is the list of known TLDs that an e-mail address must end with. */
		
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
		
		/* The following pattern is used to check if the entered e-mail address
		fits the user@domain format.  It also is used to separate the username
		from the domain. */
		
		var emailPat=/^(.+)@(.+)$/;
		
		/* The following string represents the pattern for matching all special
		characters.  We don't want to allow special characters in the address. 
		These characters include ( ) < > @ , ; : \ " . [ ] */
		
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		
		/* The following string represents the range of characters allowed in a 
		username or domainname.  It really states which chars aren't allowed.*/
		
		var validChars="\[^\\s" + specialChars + "\]";
		
		/* The following pattern applies if the "user" is a quoted string (in
		which case, there are no rules about which characters are allowed
		and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
		is a legal e-mail address. */
		
		var quotedUser="(\"[^\"]*\")";
		
		/* The following pattern applies for domains that are IP addresses,
		rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
		e-mail address. NOTE: The square brackets are required. */
		
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		
		/* The following string represents an atom (basically a series of non-special characters.) */
		
		var atom=validChars + '+';
		
		/* The following string represents one word in the typical username.
		For example, in john.doe@somewhere.com, john and doe are words.
		Basically, a word is either an atom or quoted string. */
		
		var word="(" + atom + "|" + quotedUser + ")";
		
		// The following pattern describes the structure of the user
		
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		
		/* The following pattern describes the structure of a normal symbolic
		domain, as opposed to ipDomainPat, shown above. */
		
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		
		/* Finally, let's start trying to figure out if the supplied address is valid. */
		
		/* Begin with the coarse pattern to simply break up user@domain into
		different pieces that are easy to analyze. */
		
		var matchArray=emailStr.match(emailPat);
		
		if (matchArray==null) {
		
		/* Too many/few @'s or something; basically, this address doesn't
		even fit the general mould of a valid e-mail address. */
		
		alert("Email address seems incorrect (check @ and .'s)");
				document.getElementById('emaillabel').style.color = "#FF0000";
		return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];
		
		// Start by checking that only basic ASCII characters are in the strings (0-127).
		
		for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
		alert("Ths first part of your e-mail address contains invalid characters.");
				document.getElementById('emaillabel').style.color = "#FF0000";
		return false;
		   }
		}
		for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
		alert("Ths domain name contains invalid characters.");
				document.getElementById('emaillabel').style.color = "#FF0000";
		return false;
		   }
		}
		
		// See if "user" is valid 
		
		if (user.match(userPat)==null) {
		
		// user is not valid
		
		alert("The first part of your e-mail address doesn't seem to be valid.");
				document.getElementById('emaillabel').style.color = "#FF0000";
		return false;
		}
		
		/* if the e-mail address is at an IP address (as opposed to a symbolic
		host name) make sure the IP address is valid. */
		
		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) {
		
		// this is an IP address
		
		for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
		alert("Your e-mail address does not appear to be valid!");
				document.getElementById('emaillabel').style.color = "#FF0000";
		return false;
		   }
		}
		return true;
		}
		
		// Domain is symbolic name.  Check if it's valid.
		 
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
		alert("Your e-mail address does not seem to be valid!");
				document.getElementById('emaillabel').style.color = "#FF0000";
		return false;
		   }
		}
		
		/* domain name seems valid, but now make sure that it ends in a
		known top-level domain (like com, edu, gov) or a two-letter word,
		representing country (uk, nl), and that there's a hostname preceding 
		the domain or country. */
		
		if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("Your e-mail address is incomplete!");
				document.getElementById('emaillabel').style.color = "#FF0000";
		return false;
		}
		
		// Make sure there's a host name preceding the domain.
		
		if (len<2) {
		alert("Your e-mail address is incomplete!");
				document.getElementById('emaillabel').style.color = "#FF0000";
		return false;
		}
		document.getElementById('emaillabel').style.color = "#366AB4";

        return valid;
}
// -->