// checkForm.js
// © Paira Creative 2007
// version 1 | 3.29.07
function checkForm(form,nulls) {
    if(!nulls) { nulls=""; }
    // array each input element
    var f = document.getElementById(form);
    var input = f.getElementsByTagName("input");
    var textarea = f.getElementsByTagName("textarea");
    var sel = f.getElementsByTagName("select");

    found  = "";
    errOut = "";
    
    // scan for text, drop radio and textarea fields
    for(i=0;i<input.length;i++) {
        if(input[i].type=="text") {
        input[i].className = input[i].className.replace(" missingField","");
            if(input[i].value<="") {
                if(nulls.indexOf(input[i].name)<0) {
                    errOut = errOut + "\n     " + input[i].name.replace(/_/g," ");
                    input[i].className= input[i].className +" missingField";
                }
            } else {
                found = found + "\n" + input[i].type + " -> " + input[i].name.replace(/_/g," ");
            }
        }
    }
    // scan textareas
    for(i=0;i<textarea.length;i++) {
        textarea[i].className = textarea[i].className.replace(" missingField","");
        if(textarea[i].value<="") {
            if(nulls.indexOf(input[i].name)<0) {
                errOut = errOut + "\n     " + textarea[i].name.replace(/_/g," ");
                textarea[i].className= textarea[i].className +" missingField";
            }
        } else {
            found = found + "\n" + textarea[i].type + " -> " + textarea[i].value;
        }
    }
    
    if(errOut>"") {
        errOut = "The following fields are missing: \n" + errOut;
        //alert(errOut);
        alert("Please Fill In Required Fields.");
    } else {
        f.submit();
    }
	
	
}

