//promotionmailer.js
//validate all custom fields - name, address1, city, state, zip, country, email
//

//################################################################## 
//###			(c) Saleem Jeelani 2002 		     	   ###
//###		    Licensed For use by Vintage Logos only         ###
//###			saleemjeelani@yahoo.com	            	   ###
//##################################################################


function validateMailer()
{
	var errorMessage="";
	if (document.mailer.name.value.length == 0)
	{
		errorMessage += "Name is required, please enter your name \n"
	}
	if (document.mailer.address1.value.length == 0)
	{
		errorMessage += "Address cannot be blank\n"
	}
	if (document.mailer.city.value.length == 0)
	{
		errorMessage += "City is required, please enter your city \n"
	}
	if (document.mailer.state.value.length == 0)
	{
		errorMessage += "State/Providence cannot be blank\n"
	}	

	if (document.mailer.zip.value.length == 0)
	{
		errorMessage += "Zip cannot be blank\n"
	}
	

	if (document.mailer.country.value.length == 0)
	{
		errorMessage += "Country cannot be blank \n"
	}
	if (document.mailer.email.value.length == 0)
	{
		errorMessage += "E-mail address is required \n"
	} else {
		if (!isEmail(document.mailer.email.value))
		{
		errorMessage += "Enter a valid e-mail address \n"
		}
	}

	if (errorMessage.length == 0)
	{
		//alert("validated, now passing control to server")
		//alert(errorMessage.length)	
		document.mailer.submit()
	} else {
		//alert("comes here")
		alert(errorMessage)
	}
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}




