var sw = 0

function chkJoin(form) 
{
    chkEmpty(form.FirstName,"Please Enter First Name.");
    if (sw==0) return false;
	
    chkEmpty(form.LastName,"Please Enrer Last Name.");
    if (sw==0) return false;
	
    chkEmpty(form.Address1,"Please Enter your Address.");
    if (sw==0) return false;
	
    chkEmpty(form.City,"Please Enter your City.");
    if (sw==0) return false;
	
    chkEmpty(form.State,"Please Enter your State.");
    if (sw==0) return false;

    chkEmpty(form.Zip,"Please Enter your Zip Code.");
    if (sw==0) return false;

    chkEmpty(form.Country,"Please Enter your Country Name.");
    if (sw==0) return false;
    
    chkEmail(form);
    if (sw==0) return false;
	
	chkEmpty(form.Checkname,"Please Enter your Name on Check.");
    if (sw==0) return false;		

	chkEmpty(form.UserID,"Please Enter your Member ID.");
    if (sw==0) return false;		

	chkEmpty(form.Password,"Please Enter your Password.");
    if (sw==0) return false;		
    
    if(form.Terms.checked==false){
    	alert("You must agree to terms and conditions");
    	return false;
    }
    return true;
}

function chkEmpty(formControl,mesg)
{
	if(formControl.value == "")
	{
		alert(mesg);
		formControl.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
}
