function CheckPhoneNumber(TheNumber) {
	var valid = 1
	var GoodChars = "0123456789()-+ "
	var i = 0
	//if (TheNumber=="") {
		// Return false if number is empty
		//valid = 0
	//}
	for (i =0; i <= TheNumber.length -1; i++) {
		if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
 alert(TheNumber.charAt(i) + " is not valid in a phone number.")
			valid = 0
			return valid
} // End if statement
	} // End for loop
	return valid
}

function echeck(str) 
{

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("E-mail not in correct format.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("E-mail not in correct format.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("E-mail not in correct format.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("E-mail not in correct format.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("E-mail not in correct format.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("E-mail not in correct format.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("E-mail not in correct format.")
		    return false
		 }

 		 return true					
 }

function SubmitForm(theForm)
{
var formOK = true;
//MM_validateForm('','','R','','','R','','','RisEmail')


	if(theForm.Name.value == "")
	{
		alert("Please enter your name.");
return (false);
	}
	else if(theForm.Email.value == "")
	{
		alert("Please enter your email address.");
return (false);
	}
var check=echeck(theForm.Email.value);
if (check== false)
	{
	return (false);
	}		
		
}


function SubmitFormNew(theForm)
{
theForm.jsChecks.value="Yes";

var formOK = true;
//MM_validateForm('','','R','','','R','','','RisEmail')


	if(theForm.bride_name.value == "")
	{
		alert("Please enter the Bride\'s name.");
		theForm.bride_name.focus();
return (false);
	}
	else if(theForm.bride_email.value == "")
	{
		alert("Please enter your email address.");
		theForm.bride_email.focus();
return (false);
	}
	else if(theForm.groom_name.value == "")
	{
		alert("Please enter the groom\'s name.");
		theForm.groom_name.focus();
return (false);
	}
	else if(theForm.telephone.value == "")
	{
		alert("Please enter your telephone number.");
		theForm.telephone.focus();
return (false);
	}
	else if(theForm.security_code.value == "")
	{
		alert("Please enter the security code in the graphic.");
		theForm.security_code.focus();
return (false);
	}
var check=echeck(theForm.bride_email.value);
if (check== false)
	{
		theForm.bride_email.focus();
	return (false);
	}		
//check phone number if exists
var check=CheckPhoneNumber(theForm.telephone.value);
if (check== false)
	{
		theForm.telephone.focus();
	return (false);
	}		
		
}

