<!--

//----------------------------------------------------
// Script functions for DS
//----------------------------------------------------
function checkPostCode(postcode){
  var postCodeValue = postcode.value;
  var isValidPostCode = 1;

  //If the field has nothing in it, then return
  if(postCodeValue == '')
    return isValidPostCode;
		  
  //If the postcode has a length of 6 then the space should be in position 3
  if(postCodeValue.length == 6){
    if(postCodeValue.indexOf(' ') != 2)
      isValidPostCode = 0;
  }
  else{
    if(postCodeValue.length == 7){
      if(postCodeValue.indexOf(' ') != 3)
        isValidPostCode = 0;
    }
    else{
      //If the postcode has a length of 8, then the space should be in position 5
      if(postCodeValue.length == 8){
        if(postCodeValue.indexOf(' ') != 4)
          isValidPostCode = 0;
      }
    }
  }
        
  //If the postcode is invalid, display an error showing the correct format
  if(isValidPostCode == 0){
    alert('The postcode is incorrect, the format should be LU3 9KJ or BA45 7DR');
    postcode.focus();
  }

  return isValidPostCode;
}


function checkTelephoneNo(telephoneNo){
  var telephoneNoValue = telephoneNo.value;
  var isValidNumber = 1
                
  //Make sure that the Telephone Number is not more than 15 characters
  if(telephoneNoValue.length > 15){
    alert('Please enter less than 15 characters for your Land Phone Number. E.g 01923 232323');
    telephoneNo.focus();
    return;
  }
        
  //Make sure that the Telephone Number is numeric by checking that each character is either 
  //a number of a space        
  for(var i=0; i<telephoneNoValue.length; i++){
    if(isNaN(telephoneNoValue.charAt(i))){
      if(telephoneNoValue.charAt(i) != ' '){
        isValidNumber = 0;
      }
    }
  }
  //If there was a character in the number, then display an error
  if(isValidNumber == 0){
    alert('Please enter a numerical telephone number');
    telephoneNo.focus();
  }
}
function checkEmail(emailAddress){
  var emailAddressValue = emailAddress.value;
  var isValidEmailAddress = 1
        
  //If the Email address is blank, then simply do nothing
  if(emailAddressValue == '')
    return;
          
  //Make sure that the length of the Email address is less than 50 characters
  if(emailAddressValue.length > 50){
    alert('Please enter less than 50 characters for your email address. E.g. johndoe@depserateseller.co.uk');  
    emailAddress.focus();
    return;
  }
        
  //Check for the @ symbol
  if(emailAddressValue.indexOf('@') < 0)
    isValidEmailAddress = 0;
  //Check for the '.'
  if(emailAddressValue.indexOf('.') < 0)
    isValidEmailAddress = 0;
  //If the Email address is invalid, then produce an error
  if(isValidEmailAddress == 0){
    alert('Please enter a valid Email address. E.g. johndoe@depserateseller.co.uk');
    emailAddress.focus();          
  }
}
  

//-->