/*set focus on firstname field*/
	function firstField() {
		document.getElementById('name').focus();
	}

	/*check if field has been left blank*/		
	function validateNonEmpty(inputField, helpText) {
        // See if the input value contains any text
        if (inputField.value.length == 0) {
          // The data is invalid, so set the help message
          if (helpText != null)
            helpText.innerHTML = "Required Field";
			doSelection(inputField);
		//setTimeout(function (){inputField.focus(), 0});

		  return false;
        }
        else {
          // The data is OK, so clear the help message
          if (helpText != null)
            helpText.innerHTML = "";
          return true;
        }
     }
	
	/*postcode field has to be between 6 and 8 characters*/	
	function postLength(minLength, maxLength, inputField, helpText) {
        // See if the input value contains at least minLength but no more than maxLength characters
        if (inputField.value.length < minLength || inputField.value.length > maxLength) {
          // The data is invalid, so set the help message
          if (helpText != null)
            helpText.innerHTML = "Invalid Postcode";
			//setTimeout(function (){inputField.focus(), 0});
		  return false;
        }
        else {
          // The data is OK, so clear the help message
          if (helpText != null)
            helpText.innerHTML = "";
          return true;
        }
      }
	/*checks email field making sure it has an @, less than 3 . and no spaces*/
	function validateEmail (inputField, helpText) {

	 if ((inputField.value.indexOf(".")<3) || 
		(inputField.value.indexOf("@")<1) || 
		(inputField.value.indexOf(" ")!='-1'))   //checks for a dot after position 3, an @ after the first place and no spaces
		{
          if (helpText != null)
            helpText.innerHTML = "Invalid Email";
			//document.my_form.inputField.focus();
          return false;
        }
        else {
          // The data is OK, so clear the help message
          if (helpText != null)
            helpText.innerHTML = "";
          return true;
        }
	}
	
	function addLoadEvent(func) { 
	  var oldonload = window.onload; 
	  if (typeof window.onload != 'function') { 
	    window.onload = func; 
	  } else { 
	    window.onload = function() { 
	      if (oldonload) { 
	        oldonload(); 
	      } 
	      func(); 
	    } 
	  } 
	} 
	 
	addLoadEvent(firstField);
	addLoadEvent(setName);

	
	


	
	

