// #@(#)register_account.js	1.1 17:30:15,07/02/08 (yy/mm/dd)

function create_form_check(theform) {
     var number_clicked = 0;
     for (var i = 0; i < theform.elements.length; i++)
     {
       if (theform.elements[i].name == "emp_mkt_cd")
       {
	   	if(theform.elements[i].type == "checked")
		{
          if (theform.elements[i].checked == true)
           {
             number_clicked++;
           }
		 }
		 else
		 {
		 	number_clicked = 1;
		 }
        }
     }
     if (number_clicked == 0)
     {
          alert("Please select an industry sector");
          return false;
     }
     if (number_clicked > 4)
     {
          alert("Please select 4 or fewer industry sectors");
          return false;
     }

  if (theform.firstname.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theform.firstname.focus();
    return (false);
  }


  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_-.@";
  var checkStr = theform.email.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, digit and \"_-.@\" characters in the \"email\" field.");
    theform.email.focus();
    return (false);
  }

  if (theform.surname.value == "")
  {
    alert("Please enter a value for the \"Surname\" field.");
    theform.surname.focus();
    return (false);
  }

  if (theform.email.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theform.email.focus();
    return (false);
  }
  
  if (theform.cc.value == "")
  {
    alert("Please select a Country of Residence.");
    theform.cc.focus();
    return (false);
  }

  if (theform.password.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theform.password.focus();
    return (false);
  }

  if (theform.password_confirmation.value == "")
  {
    alert("Please enter a value for the \"Confirm Password\" field.");
    theform.password_confirmation.focus();
    return (false);
  }

  return true;
}
function uncheck_all_jobtypes(the_form){
    var jobtype_total = the_form.jobtype.length;
    for (i = 0; i < jobtype_total; i++){
            if (the_form.jobtype[i].value != "E"){
                the_form.jobtype[i].checked = false;
            }
    }
}

function uncheck_jobtype_all(the_form){
    var jobtype_total = the_form.jobtype.length;
    for (i = 0; i < jobtype_total; i++){
            if (the_form.jobtype[i].value == "E"){
                the_form.jobtype[i].checked = false;
        }
    }
}
