// JavaScript Document

function ValidateNo(NumStr, String) 
{ 
    for(var Idx=0; Idx<NumStr.length; Idx++) 
    { 
        var Char = NumStr.charAt(Idx); 
        var Match = false; 

        for(var Idx1=0; Idx1<String.length; Idx1++) 
        { 
            if(Char == String.charAt (Idx1)) 
                Match = true; 
        } 

        if (!Match) 
            return false; 
    } 
    return true; 
} 


function formCheck(f)
{ 

	//declaration of boolean variable
var bValid;
	bValid = true;	

var sErrors = new String;
	sErrors = "The form cannot be sent. Please fill in the following: ";

var name = new String(f.name.value);
	if (name.length == 0)  
	{
		sErrors = sErrors + "your name\n";
		bValid = false;
		document.MembershipForm.name.focus();
	}

var email = new String(f.email.value);
	if (email.length == 0)
	{
	  bValid = false;
	  sErrors = sErrors +"e-mail\n";
	  document.MembershipForm.email.focus();
	}

var phone = new String(f.phone.value);
	if (phone.length == 0)  
	{
		sErrors = sErrors + "phone number\n";
		document.MembershipForm.phone.focus();
		bValid = false;
	}
	
var address = new String(f.address.value);
	if (address.length == 0)  
	{
		sErrors = sErrors + "your address\n";
		document.MembershipForm.address.focus();
		bValid = false;
	}
	
	
if(!ValidateNo(f.phone.value,"1234567890+-()# ")) 
    { 
        sErrors = sErrors +"phone number is invalid\n";
        document.MembershipForm.phone.focus();
        bValid = false; 
    } 
	
	
var Email1 = new String(f.email.value);
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(Email1))
	 {}
	else{
	  bValid = false;
	  sErrors = sErrors +"e-mail address is badly formated";
	}

//if anything is not filled out properly, alert user of error
if (bValid == false)
	{
		alert(sErrors);
		return false;
	}
	else
	{
		document.submit();
		return true;
	}
}
