
function clearText(thefield){
 if (thefield.defaultValue==thefield.value)
 thefield.value = ""
} 


function postitfull(){ //check postcode format is valid
 test =  document.bookonline.booking_postcode.value; size = test.length
 test = test.toUpperCase(); //Change to uppercase
 
 document.bookonline.booking_postcode.value = test; //write back to form field
 

 if (size < 6){ //Code length rule
  alert(test + " is not a valid postcode - wrong length");
  document.bookonline.booking_postcode.focus();
  return false;
  }
 
 if (size > 8){ //Code length rule
  alert(test + " is not a valid postcode - wrong length");
  document.bookonline.booking_postcode.focus();
  return false;
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   alert(test + " is not a valid postcode - cannot start with a number");
   document.bookonline.booking_postcode.focus();
   return false;
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
   alert(test + " is not a valid postcode - alpha character in wrong position");
   document.bookonline.booking_postcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   document.bookonline.booking_postcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   document.bookonline.booking_postcode.focus();
   return false;
  }

 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
   alert(test + " is not a valid postcode - only one space allowed");
   document.bookonline.booking_postcode.focus();
   return false;
  }
  
  
  
}

function postit(){ //check postcode format is valid
 test = document.search.postcode.value; size = test.length
 test = test.toUpperCase(); //Change to uppercase
 
 while (test.slice(0,1) == " ") //Strip leading spaces
  {test = test.substr(1,size-1);size = test.length
  }
 while(test.slice(size-1,size)== " ") //Strip trailing spaces
  {test = test.substr(0,size-1);size = test.length
  }
 document.search.postcode.value = test; //write back to form field
 
 
 
if (size < 6) {
 
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   alert(test + " is not a valid postcode - cannot start with a number");
   document.search.postcode.focus();
   return false;
  }
  
 
 } else {
 
 if (size > 8){ //Code length rule
  alert(test + " is not a valid postcode - wrong length");
  document.search.postcode.focus();
  return false;
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   alert(test + " is not a valid postcode - cannot start with a number");
   document.search.postcode.focus();
   return false;
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
   alert(test + " is not a valid postcode - alpha character in wrong position");
   document.search.postcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   document.search.postcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   document.search.postcode.focus();
   return false;
  }

 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
   alert(test + " is not a valid postcode - only one space allowed");
   document.search.postcode.focus();
   return false;
  }
  
  }
  
}

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function setClassName(objDivID, changeclass) {
    	document.getElementById(objDivID).className = changeclass;
}

function changeCssClass(objDivID, selected)
        
        {
                document.getElementById(objDivID).className = selected;

        }


