//<!--
// e-gadget factory 2006  - Form Field Check Script
function checkMailSafe( str){
	if (str=="" || str == null)return false;
	var nono = new Array("content-type:", "mime-version:", "content-transfer-encoding:", "subject:", "bcc:", "charset=");
	var txt = str.toLowerCase();
	
	for (var i = 0; i < nono.length ; i++ ){
		if ( txt.indexOf( nono[ i ] )  != -1 || txt == "" ){
			return false;
		}
	}
	return true;
}

function isEmailAddr( email )
{
  var result = false
  var theStr = new String(email)
  // @ ; , " "
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

/*
	STARTER PACK DLOAD FORM CHECKER
*/
function starterPack_FormValidator( theForm ){
	// name
	if ( !checkMailSafe( theForm.dl_nam.value ) )
	{

	alert("Please enter your name");
	theForm.dl_nam.focus();
	return false;

	}
	// institution
	if ( !checkMailSafe( theForm.dl_ins.value ) )
	{

	alert("Please enter the name of your institution");
	theForm.dl_ins.focus();
	return false;

	}
	// email
	if ( !checkMailSafe( theForm.dl_ema.value ) || !isEmailAddr( theForm.dl_ema.value ) || theForm.dl_ema.value.length < 3 ){

	alert("Please enter a valid email address");
	theForm.dl_ema.focus();
	return false;

	}
	// form ok 
	return true;
}
	
/*

*/
function FormValidator(theForm)
{

   if ( !checkMailSafe( theForm.cont_nam.value ) )
  {
    alert("Please enter your name");
    document.form.cont_nam.focus();
    return false;
  }	

if ( !checkMailSafe( theForm.cont_ins.value ) )
  {
    alert("Please enter your institution");
    document.form.cont_ins.focus();
    return false;
  }	
  
  if ( !checkMailSafe(  theForm.cont_ema.value) )
  {
    alert("Please enter a valid email address");
    document.form.cont_ema.focus();
    return false;
  }
  
  if (!isEmailAddr(theForm.cont_ema.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    document.form.cont_ema.focus();
    return false;
  }
   
  if (theForm.cont_ema.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"contact email\" field.");
    document.form.cont_ema.focus();
    return false;
  }

 if ( !checkMailSafe( theForm.cont_que.value ) )
  {
    alert("Please enter a comment");
    document.form.cont_que.focus();
    return false;
  }	
    
  return true;

 }
 /* D&T Week e-gadget challenge form */
function challengeValidator(theForm)
{

   if ( !checkMailSafe( theForm.cont_nam.value ) )
  {
    alert("Please enter your name");
    document.form.cont_nam.focus();
    return false;
  }	

if ( !checkMailSafe( theForm.cont_ins.value ) )
  {
    alert("Please enter your institution");
    document.form.cont_ins.focus();
    return false;
  }	
  
  if ( !checkMailSafe(  theForm.cont_ema.value) )
  {
    alert("Please enter a valid email address");
    document.form.cont_ema.focus();
    return false;
  }
  
  if (!isEmailAddr(theForm.cont_ema.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    document.form.cont_ema.focus();
    return false;
  }
   
  if (theForm.cont_ema.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"contact email\" field.");
    document.form.cont_ema.focus();
    return false;
  }
    
  return true;

 }
//
function DloadValidator(theForm)
{

   if ( !checkMailSafe( theForm.cont_nam.value ) )
  {
    alert("Please enter your name");
    document.form.cont_nam.focus();
    return false;
  }	

if ( !checkMailSafe( theForm.cont_ins.value ) )
  {
    alert("Please enter your organisation");
    document.form.cont_ins.focus();
    return false;
  }	
  
  
  if (!isEmailAddr(theForm.cont_ema.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    document.form.cont_ema.focus();
    return false;
  }
   
  if (theForm.cont_ema.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"contact email\" field.");
    document.form.cont_ema.focus();
    return false;
  }
    
  return true;

};
// trial page form checker
function trialValidator( theForm ){


   if ( !checkMailSafe( theForm.cont_nam.value ) ){
    alert("Please enter your name");
    theForm.cont_nam.focus();
    return false;
  }

  if ( !checkMailSafe( theForm.cont_title.value ) )
  {
    alert("Please enter your job title");
    theForm.cont_title.focus();
    return false;
  }	

if ( !checkMailSafe( theForm.cont_ins.value ) )
  {
    alert("Please enter your organisation");
    theForm.cont_ins.focus();
    return false;
  }	

  if ( !checkMailSafe( theForm.cont_loc.value) )
  {
    alert("Please enter your location");
    theForm.cont_loc.focus();
    return false;
  }	
  
  if ( !checkMailSafe( theForm.cont_ema.value ) )
  {
    alert("Please enter a valid email address");
    theForm.cont_ema.focus();
    return false;
  }
  
  if (!isEmailAddr(theForm.cont_ema.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.cont_ema.focus();
    return false;
  }
   
  if (theForm.cont_ema.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"contact email\" field.");
    theForm.cont_ema.focus();
    return false;
  }

 if ( !theForm.cont_tnc.checked )
 {
	 alert("You must accept the e-gadget trial pack terms & conditions in order to download.");
	 return false;
 } 
  return true;

 }
 // offer form checker
function offerValidator( theForm ){

  // name
  if ( !checkMailSafe( theForm.cont_nam.value ) ){
    alert("Please enter your name");
    theForm.cont_nam.focus();
    return false;
  }

 // email address
  if ( !checkMailSafe( theForm.cont_ema.value ) ){
    alert("Please enter a valid email address");
    theForm.cont_ema.focus();
    return false;
  }

  if (!isEmailAddr(theForm.cont_ema.value)){
    alert("Please enter a complete email address in the form: \n\nyourname@yourdomain.com");
    theForm.cont_ema.focus();
    return false;
  }

  if (theForm.cont_ema.value.length < 3){
    alert("Please enter at least 3 characters in the \"contact email\" field.");
    theForm.cont_ema.focus();
    return false;
  }

    // position
  if ( !checkMailSafe( theForm.cont_pos.value ) ){
    alert("Please enter your position.");
    theForm.cont_pos.focus();
    return false;
  }

  // school
  if ( !checkMailSafe( theForm.cont_sch.value ) ){
    alert("Please enter your school.");
    theForm.cont_sch.focus();
    return false;
  }
  
 // postcode
  if ( !checkMailSafe( theForm.cont_pco.value ) ){
    alert("Please enter your postcode.");
    theForm.cont_pco.focus();
    return false;
  }
   // whiteboard
  if ( !checkMailSafe( theForm.cont_boa.value ) ){
    alert("Please enter your brand of electronic whiteboard.");
    theForm.cont_boa.focus();
    return false;
  }

	// e-learning credits 
 if ( !theForm.cont_cre.checked )
 {
	var temp = window.confirm('Are you sure you want to order without using e-learning credits?');
	if (!temp){
		theForm.cont_cre.focus();
		return false;
	}
	
 } 
  return true;

 }

 // PDA offer form checker
function PDAofferValidator( theForm ){
	// offer checkbox
 if ( !theForm.cont_offer.checked )
 {
	alert('You must tick the check box to receive the \nDesign & Technology e-gadget pack at the special offer price.');
	theForm.cont_offer.focus();
	return false;
	
 } 

  // name
  if ( !checkMailSafe( theForm.cont_nam.value ) ){
    alert("Please enter your name");
    theForm.cont_nam.focus();
    return false;
  }

 // email address
  if ( !checkMailSafe( theForm.cont_ema.value ) ){
    alert("Please enter a valid email address");
    theForm.cont_ema.focus();
    return false;
  }

  if ( !checkMailSafe( theForm.cont_pho.value ) ){
    alert("Please enter a valid telephone number");
    theForm.cont_pho.focus();
    return false;
  }

  if (!isEmailAddr(theForm.cont_ema.value)){
    alert("Please enter a complete email address in the form: \n\nyourname@yourdomain.com");
    theForm.cont_ema.focus();
    return false;
  }

  if (theForm.cont_ema.value.length < 3){
    alert("Please enter at least 3 characters in the \"contact email\" field.");
    theForm.cont_ema.focus();
    return false;
  }

    // position
  if ( !checkMailSafe( theForm.cont_pos.value ) ){
    alert("Please enter your position.");
    theForm.cont_pos.focus();
    return false;
  }

  // school
  if ( !checkMailSafe( theForm.cont_sch.value ) ){
    alert("Please enter your school.");
    theForm.cont_sch.focus();
    return false;
  }
  
 // postcode
  if ( !checkMailSafe( theForm.cont_pco.value ) ){
    alert("Please enter your postcode.");
    theForm.cont_pco.focus();
    return false;
  }
   // whiteboard
  if ( !checkMailSafe( theForm.cont_boa.value ) ){
    alert("Please enter your brand of electronic whiteboard.");
    theForm.cont_boa.focus();
    return false;
  }

	// e-learning credits 
 if ( !theForm.cont_cre.checked )
 {
	var temp = window.confirm('Are you sure you want to order without using e-learning credits?');
	if (!temp){
		theForm.cont_cre.focus();
		return false;
	}
	
 } 
  return true;

 }

  // Password change form check
function PasswordFormValidator( theForm ){
	
 if (theForm.curr_pass.value.length < 6){
    alert("Please enter at least 6 characters in the \"current password\" field.");
    theForm.curr_pass.focus();
    return false;
  }
 if (theForm.new_pass.value.length < 6){
    alert("Please enter at least 6 characters in the \"new password\" field.");
    theForm.new_pass.focus();
    return false;
  }
 if (theForm.new_pass.value != theForm.new_pass2.value){
    alert("New password and retype new password fields do not match.");
    theForm.new_pass.focus();
    return false;
  }
  return true;

 }


 function PasswordRetrievalForm( theForm){

	if (theForm.user_nam.value.length < 4){
	  alert("Please enter at least 4 characters in the \"username\" field.");
	   theForm.user_nam.focus();
	  return false;
   }

// email address
  if ( !checkMailSafe( theForm.cont_ema.value ) ){
    alert("Please enter a valid email address");
    theForm.cont_ema.focus();
    return false;
  }

  if (!isEmailAddr(theForm.cont_ema.value)){
    alert("Please enter a complete email address in the form: \n\nyourname@yourdomain.com");
    theForm.cont_ema.focus();
    return false;
  }

  if (theForm.cont_ema.value.length < 3){
    alert("Please enter at least 3 characters in the \"contact email\" field.");
    theForm.cont_ema.focus();
    return false;
  }

    return true;
 }
 /*
 *	Check trial form
 *  @note: checkMailSafe() is in js_form-validate.js
 */
 function checkTrial( theForm ){
	// username
	if ( !checkMailSafe( theForm.username.value ) ){
		alert("Please enter your requested username");
		theForm.username.focus();
		return false;
	}
	// check is alphanumeric
	if( !isAlphaNumeric( theForm.username.value ) ){
		alert("Your username must be alphanumeric.");
		theForm.username.focus();
		return false;
	}
	// password
	if ( !checkMailSafe( theForm.password.value ) ){
		alert("Please enter your password");
		theForm.password.focus();
		return false;
	}
	// password2
	if ( !checkMailSafe( theForm.password2.value ) ){
		alert("Please confirm your password");
		theForm.password2.focus();
		return false;
	}
	// password2 == password
	if ( theForm.password.value != theForm.password2.value ){
		alert("Passwords do not match. Please re-enter and confirm your password");
		theForm.password.value = "";;
		theForm.password2.value = "";;
		theForm.password.focus();
		return false;
	}
	// fName
	if ( !checkMailSafe( theForm.fName.value ) ){
		alert("Please enter your first name");
		theForm.fName.focus();
		return false;
	}
	// lName
	if ( !checkMailSafe( theForm.lName.value ) ){
		alert("Please enter your last name");
		theForm.lName.focus();
		return false;
	}
	// role
	if ( !checkMailSafe( theForm.role.value ) ){
		alert("Please enter your role.");
		theForm.role.focus();
		return false;
	}
	// organisation
	if ( !checkMailSafe( theForm.org.value ) ){
		alert("Please enter your School, Authority or Grid.");
		theForm.org.focus();
		return false;
	}
	// postcode
	if ( !checkMailSafe( theForm.postcode.value ) ){
		alert("Please enter your postcode");
		theForm.postcode.focus();
		return false;
	}
	// email
	if ( !checkMailSafe(  theForm.email.value) )
	{
	alert("Please enter a valid email address");
	theForm.email.focus();
	return false;
	}
	if (!isEmailAddr(theForm.email.value))
	{
	alert("Please enter a complete email address in the form: yourname@yourdomain.com");
	theForm.email.focus();
	return false;
	}
	if (theForm.email.value.length < 3)
	{
	alert("Please enter at least 3 characters in the \"contact email\" field.");
	theForm.email.focus();
	return false;
	}
	// number
	if ( !checkMailSafe( theForm.telephone.value ) ){
		alert("Please enter your telephone number");
		theForm.telephone.focus();
		return false;
	}	
	// security
	if ( !checkMailSafe( theForm.security.value ) ){
		alert("Please enter the security number");
		theForm.security.focus();
		return false;
	}
	var el = document.getElementById( 'keycode' );
	var code = el.name;
	if(theForm.security.value != code){
		alert("The security number you entered is incorrect. Please re-enter the security number.");
		theForm.security.focus();
		return false;
	}
	//
	if( !theForm.tnc.checked ){
		alert("You must accept the terms and conditions.");
		theForm.tnc.focus();
		return false;
	}
	// returns true if no error
	return true;
 }
 /*
 *	Check submission form
 *  @note: checkMailSafe() is in js_form-validate.js
 */
 function checkSubmission( theForm ){
	// username
	if ( !checkMailSafe( theForm.title.value ) ){
		alert("Please enter an e-gadget title");
		theForm.title.focus();
		return false;
	}
	// subject
	if ( !checkMailSafe( theForm.subject.value ) ){
		alert("Please enter a subject");
		theForm.subject.focus();
		return false;
	}
	// unit
	if ( !checkMailSafe( theForm.unit.value ) ){
		alert("Please enter a unit");
		theForm.unit.focus();
		return false;
	}
	// description
	if ( !checkMailSafe( theForm.description.value ) ){
		alert("Please enter a description");
		theForm.description.focus();
		return false;
	}
	// benefits
	if ( !checkMailSafe( theForm.benefits.value ) ){
		alert("Please enter benefits");
		theForm.benefits.focus();
		return false;
	}
	// name
	if ( !checkMailSafe( theForm.name.value ) ){
		alert("Please enter your name");
		theForm.name.focus();
		return false;
	}
	// email
	if ( !checkMailSafe(  theForm.email.value) ){
		alert("Please enter a valid email address");
		theForm.email.focus();
		return false;
	}
	if (!isEmailAddr(theForm.email.value)){
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		theForm.email.focus();
		return false;
	}
	if (theForm.email.value.length < 3){
		alert("Please enter at least 3 characters in the \"email address\" field.");
		theForm.email.focus();
		return false;
	}
	// school
	if ( !checkMailSafe( theForm.school.value ) ){
		alert("Please enter your school");
		theForm.school.focus();
		return false;
	}
	// returns true if no error
	return true;
 }
  /*
 *	Check offer trial form
 *  @note: checkMailSafe() is in js_form-validate.js
 */
 function checkOfferTrial( theForm ){
	// username
	if ( !checkMailSafe( theForm.username.value ) ){
		alert("Please enter your requested username");
		theForm.username.focus();
		return false;
	}
	// check is alphanumeric
	if( !isAlphaNumeric( theForm.username.value ) ){
		alert("Your username must be alphanumeric.");
		theForm.username.focus();
		return false;
	}
	// password
	if ( !checkMailSafe( theForm.password.value ) ){
		alert("Please enter your password");
		theForm.password.focus();
		return false;
	}
	// password2
	if ( !checkMailSafe( theForm.password2.value ) ){
		alert("Please confirm your password");
		theForm.password2.focus();
		return false;
	}
	// password2 == password
	if ( theForm.password.value != theForm.password2.value ){
		alert("Passwords do not match. Please re-enter and confirm your password");
		theForm.password.value = "";;
		theForm.password2.value = "";;
		theForm.password.focus();
		return false;
	}
	// fName
	if ( !checkMailSafe( theForm.fName.value ) ){
		alert("Please enter your first name");
		theForm.fName.focus();
		return false;
	}
	// lName
	if ( !checkMailSafe( theForm.lName.value ) ){
		alert("Please enter your last name");
		theForm.lName.focus();
		return false;
	}
	// role
	if ( !checkMailSafe( theForm.role.value ) ){
		alert("Please enter your role.");
		theForm.role.focus();
		return false;
	}
	// organisation
	if ( !checkMailSafe( theForm.org.value ) ){
		alert("Please enter your School, Authority or Grid.");
		theForm.org.focus();
		return false;
	}
	// postcode
	if ( !checkMailSafe( theForm.postcode.value ) ){
		alert("Please enter your postcode");
		theForm.postcode.focus();
		return false;
	}
	// email
	if ( !checkMailSafe(  theForm.email.value) )
	{
	alert("Please enter a valid email address");
	theForm.email.focus();
	return false;
	}
	if (!isEmailAddr(theForm.email.value))
	{
	alert("Please enter a complete email address in the form: yourname@yourdomain.com");
	theForm.email.focus();
	return false;
	}
	if (theForm.email.value.length < 3)
	{
	alert("Please enter at least 3 characters in the \"contact email\" field.");
	theForm.email.focus();
	return false;
	}
	/*
	// number
	if ( !checkMailSafe( theForm.telephone.value ) ){
		alert("Please enter your telephone number");
		theForm.telephone.focus();
		return false;
	}	*/
	// security
	if ( !checkMailSafe( theForm.security.value ) ){
		alert("Please enter the security number");
		theForm.security.focus();
		return false;
	}
	var el = document.getElementById( 'keycode' );
	var code = el.name;
	if(theForm.security.value != code){
		alert("The security number you entered is incorrect. Please re-enter the security number.");
		theForm.security.focus();
		return false;
	}
	//
	if( !theForm.tnc.checked ){
		alert("You must accept the terms and conditions.");
		theForm.tnc.focus();
		return false;
	}
	// returns true if no error
	return true;
 }
   /*
    *	Check request for order form
    */
 function checkOrderRequest( theForm ){

	// name
	if ( !checkMailSafe( theForm.nam_fld.value ) ){
		alert("Please enter your name");
		theForm.nam_fld.focus();
		return false;
	}

	// email
	if ( !checkMailSafe(  theForm.ema_fld.value) ){
		alert("Please enter a valid email address");
		theForm.ema_fld.focus();
		return false;
	}else if (!isEmailAddr(theForm.ema_fld.value)){
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		theForm.ema_fld.focus();
		return false;
	}else if (theForm.ema_fld.value.length < 3){
		alert("Please enter at least 3 characters in the \"Contact email\" field.");
		theForm.ema_fld.focus();
		return false;
	}

	// institution
	if ( !checkMailSafe( theForm.inst_fld.value ) ){
		alert("Please enter your institutions name");
		theForm.inst_fld.focus();
		return false;
	}

	// address
	if ( !checkMailSafe( theForm.add_fld.value ) ){
		alert("Please enter your address");
		theForm.add_fld.focus();
		return false;
	}

	// region/state
	if ( !checkMailSafe( theForm.reg_fld.value ) ){
		alert("Please enter a region/state");
		theForm.reg_fld.focus();
		return false;
	}

	// country
	if ( !checkMailSafe( theForm.cou_fld.value ) ){
		alert("Please enter the country your institution is in");
		theForm.cou_fld.focus();
		return false;
	}
	// returns true if no error
	return true;
 }
 //-->