var sw = 0

function chkAffil_Signup(AffilForm) {
        // check firstname 
        chkFirstName(AffilForm);
        if (sw==0) return false;
        // check lastname
        chkLastName(AffilForm);
        if (sw==0) return false;
        // check phone number
        chkPhoneNumber(AffilForm);
        if (sw==0) return false;
        // check email
        chkEmail(AffilForm);
        if (sw==0) return false;

				if (AffilForm.otherBusiness.value == "") {
        AffilForm.otherBusiness.value = "- Intentionally Left Blank -";
    }
				if (AffilForm.companyName.value == "") {
        AffilForm.companyName.value = "- Intentionally Left Blank -";
    }
				if (AffilForm.comment.value == "") {
        AffilForm.comment.value = "- Intentionally Left Blank -";
    }

}

function chkFirstName(form_id) {
    if (form_id.firstName.value == "") {
        alert("Please enter your first name");
        form_id.firstName.focus();
        sw = 0;
    }   
    else sw = 1;
}   

function chkLastName(form_id) {
    if (form_id.lastName.value == "") {
        alert("Please enter your last name");
        form_id.lastName.focus();
        sw = 0;
    }   
    else sw = 1;
}   

function chkPhoneNumber(form_id) {
    if (form_id.phoneNumber.value == "") {
        alert("Please enter your phone number");
        form_id.phoneNumber.focus();
        sw = 0;
    }   
    else sw = 1;
}   

function chkEmail(form_id) {
    if (form_id.email.value == "") {
        alert("Please enter your email address");
        form_id.email.focus();
        sw = 0;
    } else { 
        var emailAdd = new String();
            emailAdd = form_id.email.value;
            len = emailAdd.length;
            
            // check for the @ and .
            if ( (emailAdd.indexOf('@') > 0) || (emailAdd.indexOf('.') > 0) ||
            (emailAdd.indexOf('.') != len-1) || (emailAdd.indexOf('@') !=
len-1)) {   

                // go here when @ and .'s position are somewhat valid then test
                // the domain and user name
                at = emailAdd.indexOf('@');
                user = emailAdd.substring(0,at);
                domain = emailAdd.substring(at+1,len+1);

                // check the validity of the user and domain name
                if ( (domain.indexOf('@') >= 0) || (domain.lastIndexOf('.') ==
                    domain.length-1) || (domain.indexOf('.') == 0) ||
(domain.indexOf('.') < 0) ){
                    alert("Invalid email address!");
                    form_id.email.focus();
                    sw = 0;
                }   
                else if ( (user.lastIndexOf('.') == user.length-1) ||
                    (user.indexOf('.') == 0) ) { 
                    
                    alert("Invalid email address!");
                    form_id.email.focus();
                    sw = 0;
                }   
                else {
                
                    form_id.email.focus();
                    sw = 1;
                }
                // end check for validity of the user and domain name
                
            } // end inner if
   // go here when @ and/or  .'s position are invalid
            else {
            
            alert("Invalid email address!");
            form_id.email.focus();
            sw = 0;
            }
    } // end outermost else
}   

