<!--

function wrongPostcode(){
  alert("Please enter your correct postcode!")
  document.form1.postcode.focus()
}

function validatePostcode(doWhat){

var okSoFar = 1
var nextone = 0
var postcode= document.form1.postcode.value
postcode = postcode.replace(" ", "")
var numChars = postcode.length

if (!((postcode.substr(0,2) == "BT") || (postcode.substr(0,2) == "bt") || (postcode.substr(0,2) == "Bt") || (postcode.substr(0,2) == "bT"))) {
  okSoFar = 0
}

if (!((postcode.substr(2,1) > 0) || (postcode.substr(2,1) < 10))){
  okSoFar = 0
}

if (!((postcode.substr(3,1) > 0) || (postcode.substr(3,1) < 10))){
  okSoFar = 0
}

if ((numChars == 6) && (okSoFar == 1)){
  nextone = postcode.substring(4,5)
  if ( (nextone < "a" || "z" < nextone) && (nextone < "A" || "Z" < nextone)) {
    okSoFar = 0
  }
}
else if ((numChars == 7) && (okSoFar == 1)){
  if (!((postcode.substr(4,1) > 0) || (postcode.substr(4,1) < 10))){
    okSoFar = 0
  }
  nextone = postcode.substring(6,7)
  if ( (nextone < "a" || "z" < nextone) && (nextone < "A" || "Z" < nextone)) {
    okSoFar = 0
  }
} 

nextone = postcode.substring(5,6)
if ( (nextone < "a" || "z" < nextone) && (nextone < "A" || "Z" < nextone)) {
  okSoFar = 0
} 

if (okSoFar == 1) {
  if (doWhat == 'submit') {
    parent.buttons.location.href = "buttons.asp?action=reset";
    document.form1.submit()
  }
  else if (doWhat == 'print'){
    window.open('print.asp','print','width=360,height=60')
    document.form1.target = 'print'
    document.form1.action = "print.asp"
    document.form1.submit()
  }
  else {
    parent.buttons.location.href = "buttons.asp?action=reset";
    return(true)
  }
}
else {
  wrongPostcode()
  if ((doWhat != 'submit') && (doWhat != 'print')) {
    return(false)
  }
}

}

//-->
