var check_user_fields = {
    firstName :  "Please fill in the First Name field\n",
    surname :    "Please fill in the Surname field\n",
    address1 :    "Please fill in the Address field\n",
    address2 :    "Please fill in the Address field\n",
    cityTown :    "Please fill in the City/Town field\n",
    postCode :    "Please fill in the postcode/zip field\n",
    companyName :    "Please fill in the Company Name field\n",
    individualEmail :    "Please fill in the email field\n",
    telephone :    "Please fill in the telephone field\n",
    fax :    "Please fill in the fax field\n",
    password :    "Please fill in the password field\n"
};

function checkUser(frm1, theURL, winName, features) {
    var msg = "";
    for (var field in check_user_fields) {
        if (frm1[field].value == "") {
            msg += check_user_fields[field];
        }
        msg += check_web(frm1[field].value);
    }

    if (frm1.individualEmail.value.search(/@/) == -1) {
        msg += "Please ensure that you have a properly formatted email address\n";
    }

    msg += check_web(frm1.whyJoin.value);

    if (msg != "") {
        msg = "Qantas Extranet Entry Error \n---------------\n\n" + msg;
        alert(msg);
        //return false;
    }
    else {
        window.open(theURL, winName, features);
        //frm1.submit();
    }
}

function check_web(field_content) {
    if (field_content.search(/http:\/\//) != -1) {
        return "Please do not put web addresses in the fields\n";
    }
    if (field_content.search(/www\./) != -1) {
        return "Please do not put web addresses in the fields\n";
    }
    if (field_content.search(/\[url\]/) != -1) {
        return "Please do not put web addresses in the fields\n";
    }
    return "";
}

function checkEditUser(frm1) {
    msg = "";
    if (frm1.firstName.value == "")        msg += "Please fill in the First Name field\n";
    if (frm1.surname.value == "")            msg += "Please fill in the Surname field\n";
    if (frm1.address1.value == "")            msg += "Please fill in the Address field\n";
    if (frm1.address2.value == "")            msg += "Please fill in the Address field\n";
    if (frm1.cityTown.value == "")            msg += "Please fill in the City/Town field\n";
    if (frm1.postCode.value == "")            msg += "Please fill in the postcode/zip field\n";
    if (frm1.companyName.value == "")        msg += "Please fill in the Company Name field\n";
    if (frm1.individualEmail.value == "")    msg += "Please fill in the email field\n";
    if (frm1.telephone.value == "")        msg += "Please fill in the telephone field\n";
    if (frm1.fax.value == "")                msg += "Please fill in the fax field\n";
    if (frm1.individualEmail.value.search(/@/) == -1)msg += "Please ensure that you have a properly formatted email address\n";

    if (msg != "") {
        msg = "Qantas Extranet Entry Error \n---------------\n\n" + msg;
        alert(msg);
        //return false;
    }
    else {
        frm1.submit();
    }
}

function checkTicks(frm1) {
    msg = "";
    if (frm1.teama.value == "")            msg += "Please fill in the team A field\n";
    if (frm1.teamb.value == "")            msg += "Please fill in the team B field\n";
    if (frm1.tick_number.value == "")        msg += "Please fill in the number of tickets field\n";
    if (isNaN(frm1.tick_number.value))    msg += "Please ensure that the number of tickets is a number\n";

    if (msg != "") {
        msg = "Qantas Extranet  Admin Entry Error \n---------------------------\n\n" + msg;
        alert(msg);
        //return false;
    }
    else {
        frm1.submit();
    }
}

function checkForgot(frm1) {
    msg = "";
    if (frm1.email.value == "")            msg += "Please fill in the email field\n";
    if (frm1.email.value.search(/@/) == -1)msg += "Please ensure that you have a properly formatted email address";

    if (msg != "") {
        msg = "Qantas Extranet  Password Forgot Error \n---------------------------\n\n" + msg;
        alert(msg);
        //return false;
    }
    else {
        frm1.submit();
    }
}

function checkPassChange(frm1) {
    msg = "";
    if (frm1.password.value != frm1.passwordnew.value)        msg += "Please make sure that your new password and confirmation match\n";

    if (msg != "") {
        msg = "Qantas Extranet  Password Change Error \n---------------------------\n\n" + msg;
        alert(msg);
        //return false;
    }
    else {
        frm1.submit();
    }
}


