function SubmitFormPass(oForm)
{
	var oName = oForm.txtName;
	var oPhone = oForm.txtPhone;
	var oEmail = oForm.txtEmail;
	var oSchool = oForm.txtSchool;
	var oContact = oForm.txtContact;


    if(oName.value == '')
    {
    	window.alert('Enter Name');
		oName.focus();
        return;
    }
	if(oPhone.value == '')
    {
    	window.alert('Enter Phone Number');
		oPhone.focus();
        return;
    }
	if(oEmail.value == '')
    {
    	window.alert('Enter Email Address');
		oEmail.focus();
        return;
    }
	if(!EmailCheck(oEmail)){
		return;
	}
	
   	if(oSchool.value == '')
    {
    	window.alert('Enter School or Organization');
		oSchool.focus();
        return;
    }

	if(oContact.value == '')
    {
    	window.alert('Enter best time to contact');
		oContact.focus();
        return;
    }

	oForm.submit();
}

function SubmitTellFrnd(oForm)
{
	var oEmail = oForm.txtEmail;
	var oFEmail = oForm.txtFrndEmail;
	var oContact = oForm.txtMsg;


	if(oEmail.value == '')
    {
    	window.alert('Enter your email address');
		oEmail.focus();
        return;
    }
	if(!EmailCheck(oEmail)){
		return;
	}
	
	if(oFEmail.value == '')
    {
    	window.alert('Enter your friend\'s email address');
		oFEmail.focus();
        return;
    }
	if(!EmailCheck(oFEmail)){
		return;
	}
	
	if(oContact.value == '')
    {
    	window.alert('Enter message');
		oContact.focus();
        return;
    }

	oForm.submit();
}


function EmailCheck(email){
		
		if(email.value==''){
			alert("Enter Email Address");
            email.focus();            
            return;
		}
		if ( !this.isCharsInBag( email.value, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._@-" ))
		{
		      
            alert("Invalid Email Address");
            email.focus();            
            return;
		}
	
	if(email.value != '')
	   {
		var str=email.value;	
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		var sdot=str.indexOf(dot,ldot+1);

		if (str.indexOf(at)==-1){
			alert("Invalid Email Address");
            email.focus();            
		   return;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			alert("Invalid Email Address");
            email.focus();            
		   return;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert("Invalid Email Address");
            email.focus();            
		    return;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
			alert("Invalid Email Address");
            email.focus();            
		    return;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			alert("Invalid Email Address");
            email.focus();            
		    return;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			alert("Invalid Email Address");
            email.focus();            
		    return;
		 }
		if (str.substring(ldot+1)==''){
			alert("Invalid Email Address");
            email.focus();            
		    return;
		 }
		 if (str.substring(sdot+1)==''){
			alert("Invalid Email Address");
            email.focus();            
		    return;
		 }
		 if (str.indexOf(" ")!=-1){
			alert("Invalid Email Address");
            email.focus();            
		    return;
		 }
	}//end of else
	return true;
}

function isCharsInBag (s, bag)
  {
    var i;
    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) return(false);
    }
    return true;
  }