// Account Creation Step1 Scripts //
// All Scripts built by Mitchell Anderson //

//Jump Phone Fields //
function checklength(nextfield,chars,currfield){
x = document.Create_Account[currfield].value.length;
if (x == chars){
eval('document.Create_Account.' + nextfield + '.focus();');
}
}




//COMPLETE VALIDATION begin//
function validate(){
var missinginfo = "";
var missinginfo2 = "";
//Form Fields //
var First_Name = document.Create_Account.Parent_First_Name.value;
var Surname = document.Create_Account.Parent_Surname.value;
var Street_Address = document.Create_Account.Parent_Street_Address.value;
var Suburb = document.Create_Account.Parent_Suburb.value;
var Postcode = document.Create_Account.Parent_Postcode.value;
var Telephone1 = document.Create_Account.Parent_Telephone1.value;
var Telephone2 = document.Create_Account.Parent_Telephone2.value;
var Telephone3 = document.Create_Account.Parent_Telephone3.value;
var Mobile1 = document.Create_Account.Parent_Mobile1.value;
var Mobile2 = document.Create_Account.Parent_Mobile2.value;
var Mobile3 = document.Create_Account.Parent_Mobile3.value;
var Email_Address = document.Create_Account.Parent_Email_Address.value;
var Email_Address_REAFFIRM = document.Create_Account.Parent_Email_Address_REAFFIRM.value;
var Password = document.Create_Account.Parent_Password.value;
var Password_REAFFIRM = document.Create_Account.Parent_Password_REAFFIRM.value;
var Recieve_Updates = document.Create_Account.Recieve_Updates.value;

//Statements //
if (First_Name == ""){
missinginfo += "\n     - First Name";
}
if (Surname == ""){
missinginfo += "\n     - Surname";
}
if (Street_Address == ""){
missinginfo += "\n     - Street Address";
}
if (Suburb == ""){
missinginfo += "\n     - Suburb";
}
if (Postcode == ""){
missinginfo += "\n     - Postcode";
}
if (Postcode.length < 4){
missinginfo2 += "\n     - Postcode is not valid.";
}
if ((Telephone1 == "") || (Telephone2 == "") || (Telephone3 == "")){
missinginfo += "\n     - Telephone";
}
if ((Mobile1 == "") || (Mobile2 == "") || (Mobile3 == "")){
document.Create_Account.Parent_Mobile1.value = "0000";
document.Create_Account.Parent_Mobile2.value = "000";
document.Create_Account.Parent_Mobile3.value = "000";
}
if (Email_Address == ""){
missinginfo += "\n     - Email Address";
}
if ((Email_Address == "") || (Email_Address.indexOf('@') == -1) || (Email_Address.indexOf('.') == -1)){
missinginfo2 += "\n     - Email Address is not valid";
}
if (Email_Address != Email_Address_REAFFIRM){
missinginfo2 += "\n     - The Email Addresses do not match.";
}
if (Password == ""){
missinginfo += "\n     - Password";
}
if (Password != Password_REAFFIRM){
missinginfo2 += "\n     - The Passwords do not match.";
}
var radio_choice2 = false;
for (counter2 = 0;  counter2 < Create_Account.Recieve_Updates.length; counter2++)
{
if (Create_Account.Recieve_Updates[counter2].checked)
radio_choice2 = true; 
}
if (!radio_choice2)
{
missinginfo2 += "\n     - Would you like to recieve email updates from Soccatoos?";
}


if ((missinginfo != "") || (missinginfo2 != "")){
message = "Form cannot be submitted!\n" + "The following details were not entered:\n" + "____________________________\n" + missinginfo + "\n____________________________\n" + "The following error(s) occured:\n" + missinginfo2 + "\n____________________________\n" + "Please re-enter and submit again. Thank you!\n";
alert(message);
return false;
}
else
return true;
}
//COMPLETE VALIDATION end//