/*
Developed by Steve Curry
June 27, 2007
*/
//validate newsletter form

var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

function validateAJAXNLForm()
{
	var myQueryString;
	var myEmail;
	myEmail = document.getElementById("txtNLEmail").value;
	
	if (myEmail == "")
	{
		alert("Your email address is required!");
		return false;
	}
	else if (!filter.test(myEmail))
	{
		alert("Invalid email address\nPlease retry.");	
		return false;
	}
	else
	{
		myEmail = encodeURI(myEmail);																				  
		myQueryString = "email="+myEmail+"&ID=7";
		Modalbox.show("Sending status", "submitnewsletterform.aspx", {method: 'post', params: myQueryString, width: 400, height: 150 }); 
		return true; 
	}
}

// Check whether string s is empty.
    

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}


// BOI, followed by one or more characters, followed by @,
// followed by one or more characters, followed by ., 
// followed by one or more characters, followed by EOI.
//var reEmail = /^.+\@.+\..+$/

// isEmail (STRING s [, BOOLEAN emptyOK])
// 
// Email address must be of form a@b.c -- in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isEmail (s)

{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
    
    else {
       return reEmail.test(s)
    }
}
