<!--



function moveOnMax(field,nextFieldID){

  if(field.value.length >= field.maxLength){

    document.getElementById(nextFieldID).focus();

	document.getElementById(nextFieldID).select();

  }

}

function checkContactForm(l) 
{
  var exp = /^[0-9 ]{6,13}$/
  if(l.custName.value=="")
  {
    window.alert("Please enter your name");
	l.custName.focus();
    return false;
  }
  else if(l.custTel.value=="")
  {
    window.alert("Please enter a telephone number into the box so we can get back in touch with you");
	l.custTel.focus();
    return false;
  }
  else if(l.custEmail.value=="")
  {
    window.alert("Please enter an email address into the box so we can get back in touch with you");
	l.custEmail.focus();
    return false;
  }
  else if(exp.test(l.custTel.value) != true)
  {
	window.alert("Please enter a valid telephone number");
	l.custTel.focus();
	return false;
	  
  }
  else if(emailCheck(l.custEmail.value) == false) {
	l.custEmail.focus();
	return false;
  }
  
  else if(l.custMsg.value=="")
  {
    window.alert("Please enter a message");
	l.custMsg.focus();
    return false;
  }
  else
  {
	return true;
  }
}


function checkCallBackForm(l) 
{
  var exp = /^[0-9 ]{6,13}$/
  if(l.custName.value=="")
  {
    window.alert("Please enter your name");
	l.custName.focus();
    return false;
  }
  else if(exp.test(l.custTel.value) != true) {
	window.alert("Please enter a valid telephone number");
	l.custTel.focus();
	return false;
  }
  else
  {
	return true;
  }
}


function checkBookingForm(l) 

{

  if((l.location.value=="") && (l.postCode.value=="Please Enter Your Postcode Here..."))

  {

    window.alert("Please either select a location from the map, select a location from the drop-down menu or enter your post code!");

    return false;

  }

  else

  {

    return true;

  }

}



function checkPersonalDetails1(l) 

{

  if((l.anyImplants[0].checked==false) && (l.anyImplants[1].checked==false))

  {

    window.alert("Please select whether or not you have any implants");

    return false;

  }

  else if(l.anyImplants[0].checked==true)

  {

    window.alert("Sorry but we are unable to offer scans to anyone with any implants");

    return false;

  }

  if((l.anyKidneyDisease[0].checked==false) && (l.anyKidneyDisease[1].checked==false))

  {

    window.alert("Please select whether or not you have any kidney disease or renal disorder");

    return false;

  }

  else if(l.anyKidneyDisease[0].checked==true)

  {

    window.alert("Sorry but we are unable to offer scans to anyone with kidney disease or renal disorder");

    return false;

  }

  else if((l.agreeTOS[0].checked==false) && (l.agreeTOS[1].checked==false))

  {

    window.alert("Please select whether or not you agree with the terms of agreement");

    return false;

  }

  else if(l.agreeTOS[1].checked==true)

  {

    window.alert("Sorry but we are unable to offer scans to anyone who does not agree with the terms of agreement");

    return false;

  }

  else

  {

    return true;

  }

}



function checkRegistration(l) 

{

  var exp = /^[0-9 ]{6,13}$/
  if(l.titleID.value=="")

  {

    window.alert("Please select your title");

    return false;

  }
  
  
  else if(l.firstName.value=="")

  {

    window.alert("Your first name cannot be blank");

    return false;

  }

  else if(l.surName.value=="")

  {

    window.alert("Your last name cannot be blank");

    return false;

  }

  else if((l.dobD.value=="") || (l.dobM.value=="") || (l.dobY.value==""))

  {

    window.alert("Your Date of Birth cannot be blank");

    return false;

  }

  else if ((l.dobD.value < 1) || (l.dobD.value > 31) || (l.dobM.value < 1) || (l.dobM.value > 12) || (l.dobY.value < 1000) || (l.dobY.value > 3000))

  {

    window.alert("Your Date of Birth is not valid");

    return false;

  }

  else if(l.address.value=="")

  {

    window.alert("Your address cannot be blank");

    return false;

  }

  else if(l.postCode.value=="")

  {

    window.alert("Your postcode cannot be blank");

    return false;

  }

  else if(l.contactTel.value=="")

  {

    window.alert("Your contact telephone number cannot be blank");

    return false;

  }

  else if(exp.test(l.contactTel.value) != true)

  {

    window.alert("Your contact telephone number appears to be invalid");

    return false;

  }

  else if(l.emailAddress.value=="")

  {

    window.alert("Your email address cannot be blank");

    return false;

  }

  else if(emailCheck(l.emailAddress.value) == false) {

	return false;

  }

   else if(l.username.value=="")

  {

    window.alert("Your username cannot be blank");

    return false;

  }

  else if(l.username.value.length < 6)

  {

    window.alert("Your username must be at least 6 characters");

    return false;

  }

  else if(l.password.value=="")

  {

    window.alert("Your password cannot be blank");

    return false;

  }

  else if(l.password.value.length < 6)

  {

    window.alert("Your password must be at least 6 characters");

    return false;

  }

  else if(l.password.value != l.password2.value)

  {

    window.alert("Your passwords do not match\nPlease re-enter them");

    return false;

  }

  else if(l.username.value == l.password.value)

  {

    window.alert("Your password cannot be the same as your username");

    return false;

  }

  else

  {

    return true;

  }

}



function checkRegistration2(l) 

{

  var exp = /^[0-9 ]{6,13}$/
  if(l.titleID.value=="")

  {

    window.alert("Please select your title");

    return false;

  }
  
  else if(l.firstName.value=="")

  {

    window.alert("Your first name cannot be blank");

    return false;

  }

  else if(l.surName.value=="")

  {

    window.alert("Your last name cannot be blank");

    return false;

  }

  else if((l.dobD.value=="") || (l.dobM.value=="") || (l.dobY.value==""))

  {

    window.alert("Your Date of Birth cannot be blank");

    return false;

  }

  else if ((l.dobD.value < 1) || (l.dobD.value > 31) || (l.dobM.value < 1) || (l.dobM.value > 12) || (l.dobY.value < 1000) || (l.dobY.value > 3000))

  {

    window.alert("Your Date of Birth is not valid");

    return false;

  }

  else if(l.address.value=="")

  {

    window.alert("Your address cannot be blank");

    return false;

  }

  else if(l.postCode.value=="")

  {

    window.alert("Your postcode cannot be blank");

    return false;

  }

  else if(l.contactTel.value=="")

  {

    window.alert("Your contact telephone number cannot be blank");

    return false;

  }

  else if(exp.test(l.contactTel.value) != true)

  {

    window.alert("Your contact telephone number appears to be invalid");

    return false;

  }

  else if(l.emailAddress.value=="")

  {

    window.alert("Your email address cannot be blank");

    return false;

  }

  else if(emailCheck(l.emailAddress.value) == false) {

	return false;

  }

   else if(l.username.value=="")

  {

    window.alert("Your username cannot be blank");

    return false;

  }

  else if(l.username.value.length < 6)

  {

    window.alert("Your username must be at least 6 characters");

    return false;

  }

   else if(l.password.value != l.password2.value)

  {

    window.alert("Your passwords do not match\nPlease re-enter them");

    return false;

  }

  else

  {

    return true;

  }

}



function checkCat(l) 

{

  if(l.adminCatName.value=="")

  {

    window.alert("You must enter a category name!");

    return false;

  }

  else

  {

	  if(l.adminAvailable.checked==false) {

		window.alert("You have selected that the category should be disabled.\nTo view disabled categories please tick the box at the bottom of the page to show disabled items");

	  }

    return true;

  }

}

  

function checkProd(l) 

{

  var exp = /^[0-9]{1,10}$/

  if(l.adminProdName.value=="")

  {

    window.alert("You must enter a product name!");

    return false;

  }

  else {

	  if(l.elements["prodWidth[]"]){

		  if(l.elements["prodWidth[]"].length){

			  for(i=0; i<l.elements["prodWidth[]"].length; i++) {

				if(exp.test(l.elements["prodWidth[]"][i].value) != true) {

					window.alert("You must enter a valid width for the product in box " + (i+1) + " using only numbers!");

					return false;

				}

			  }

		  }

		  else {

			if(exp.test(l.elements["prodWidth[]"].value) != true) {

				window.alert("You must enter a valid width for the product in the box using only numbers!");

				return false;

			}

		  }

	  }

	  

	  if(l.elements["prodHeight[]"]){

		  if(l.elements["prodHeight[]"].length){

			  for(i=0; i<l.elements["prodHeight[]"].length; i++) {

				if(exp.test(l.elements["prodHeight[]"][i].value) != true) {

					window.alert("You must enter a valid height for the product in box " + (i+1) + " using only numbers!");

					return false;

				}

			  }

		  }

		  else {

			if(exp.test(l.elements["prodHeight[]"].value) != true) {

				window.alert("You must enter a valid height for the product in the box using only numbers!");

				return false;

			}

		  }

	  }

	  

	  if(l.elements["prodCost[]"]){

		  if(l.elements["prodCost[]"].length){

			  for(i=0; i<l.elements["prodCost[]"].length; i++) {

				if(exp.test(l.elements["prodCost[]"][i].value) != true) {

					window.alert("You must enter a valid cost for the product in box " + (i+1) + " using only numbers!");

					return false;

				}

			  }

		  }

		  else {

			if(exp.test(l.elements["prodCost[]"].value) != true) {

				window.alert("You must enter a valid cost for the product in the box using only numbers!");

				return false;

			}

		  }

	  }

	  

	  if(l.adminAvailable.checked==false) {

		window.alert("You have selected that the product should be disabled.\nTo view disabled products please tick the box at the bottom of the page to show disabled items");

	  }

	return true; 

  }

}



function adminCheckEditClinics(l) 

{

  var exp = /^[0-9]{1,4}$/

  if(l.clinicName.value == "")

  {

    window.alert("You must enter a name for the clinic!");

    return false;

  }

  else if(exp.test(l.sessionCost.value) != true)

  {

    window.alert("You must enter a valid session cost using only numbers!");

    return false;

  }

  else if((l.startBookingTime1.value=="00") && (l.startBookingTime2.value=="00"))

  {

    window.alert("You must select a valid start time for bookings!");

    return false;

  }

  else if((l.endBookingTime1.value=="00") && (l.endBookingTime2.value=="00"))

  {

    window.alert("You must select a valid end time for bookings!");

    return false;

  }

  else if((l.startTime1.value + l.startTime2.value) > (l.endTime1.value + l.endTime2.value))

  {

    window.alert("The start time for bookings is later than the end time. Please correct this before continuing!");

    return false;

  }

  else

  {

    return true;

  }

}



function adminCheckPromotions(l) 

{

  var exp = /^[0-9]{1,4}$/

  if(l.promoCode.value == "")

  {

    window.alert("You must enter a promotional code!");

    return false;

  }

  else if(exp.test(l.deduction.value) != true)

  {

    window.alert("You must enter a valid deduction using only numbers!");

    return false;

  }

  else if((l.startTime1.value=="00") && (l.startTime2.value=="00"))

  {

    window.alert("You must select a valid start time for this promotion!");

    return false;

  }

  else if((l.endTime1.value=="00") && (l.endTime2.value=="00"))

  {

    window.alert("You must select a valid end time for this promotion!");

    return false;

  }

  else if((l.startTime1.value + l.startTime2.value) > (l.endTime1.value + l.endTime2.value))

  {

    window.alert("The start time for this promotion is later than the end time. Please correct this before continuing!");

    return false;

  }

  else

  {

    return true;

  }

}



function setcookie(user, pass)

{

  var username = user;

  var pword = pass;

  var all=username+"/"+pword;

  var user_cookie = "username="+escape(username);

  var pass_cookie = "password="+escape(pword);

  document.cookie = user_cookie;

  document.cookie = pass_cookie;

}

  

function delcookie()

{

  var user_cookie = "username=";

  var pass_cookie = "password=";

  document.cookie = user_cookie;

  document.cookie = pass_cookie;

}



function noUser()

{      

  window.alert($noUserMsg);

  htmlMsg($noUserMsg);

}



function noPass()

{

  window.alert($noPassMsg);

  htmlMsg($noPassMsg);

}



function noForename()

{

  window.alert($blankForename);

  htmlMsg($blankForename);

}



function noSurname()

{

  window.alert($blankSurname);

  htmlMsg($blankSurname);

}



function noAddress()

{

  window.alert($blankAddress);

  htmlMsg($blankAddress);

}



function passMismatch()

{

  window.alert($passNoMatch);

  htmlMsg($passNoMatch);

}

  

function htmlMsg(msg)

{

  loginError.innerText = msg;

}



function emailCheck (emailStr) {



/* 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("Your email address appears to be incorrect");

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("Your email address appears to be incorrect (before the '@')");

return false;

   }

}

for (i=0; i<domain.length; i++) {

if (domain.charCodeAt(i)>127) {

alert("Your email address appears to be incorrect (after the '@')");

return false;

   }

}



// See if "user" is valid 



if (user.match(userPat)==null) {



// user is not valid



alert("Your email address appears to be incorrect (before the '@')");

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("Destination IP address is invalid!");

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 email address appears to be incorrect (after the '@')");

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("The email address must end in a well-known domain or two letter " + "country.");

return false;

}



// Make sure there's a host name preceding the domain.



if (len<2) {

alert("The email address is missing a hostname!");

return false;

}



// If we've gotten this far, everything's valid!

return true;

}



//  End 

-->