function noneEmptyFormFields() {
    var goodToGo = true

    for (var i = 0; i < arguments.length; i++) {
        if (arguments[i].value.replace(/^\s+|\s+$/g,'')
         == "") {
            if (goodToGo) {
                var firstFailed = arguments[i]
                arguments[i].value = ""
            }
            goodToGo =  false
        }
    }

    if (!goodToGo) {
        firstFailed.focus()
        alert("Please enter all required information.")
    }

    return goodToGo
}
function checkEmail(emField){ //reference to email field passed as argument
    var fieldValue = emField.value


    // Empty field dispatched early.
    // Non-empty field tested, and a value of "false" is returned as soon as 
    // possible, if needed.
    if (fieldValue == "") {  
        emField.focus()
        alert("Please Enter A Valid Email Address")
        return false 
    } else{ 
        // Count occurrences of "at" symbol: @. Single one in the right place 
        // is OK, otherwise return false.

        var atSymbol = 0
        for (var a = 0; a < fieldValue.length; a++) { 
            if (fieldValue.charAt(a) == "@") { 
                atSymbol++
            }
        }

        if (atSymbol > 1) { 
            emField.focus()
            alert("Please Enter A Valid Email Address")
            return false 
        }

        // if 1 @ symbol was found, and it is not the 1st character in string
        if (atSymbol == 1 && fieldValue.charAt(0) != "@") { 
            //look for period at 2nd character after @ symbol 
            var period = fieldValue.indexOf(".", fieldValue.indexOf("@") + 2 ) 

            // "." immediately following 1st "." ? 
            var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false 

            //if period was not found OR 2 periods together OR field contains less than 5 characters OR period is in last position
            if (period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length - 1) == ".") {
                emField.focus()
                alert("Please Enter A Valid Email Address")
                return false 
            }
        } else { 
            // no @ symbol exists or it is in position 0 (the first character of the field)
            emField.focus()
            alert("Please Enter A Valid Email Address")
            return false 
        }
    }
    // All tests passed, so it's ok to submit the form.
    return true
}

