// JavaScript Document

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("Invalid E-mail ID")
		return false
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		alert("Invalid E-mail ID")
		return false
	}
	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		alert("Invalid E-mail ID")
		return false
	}
	
	if (str.indexOf(at,(lat+1))!=-1)
	{
		alert("Invalid E-mail ID")
		return false
	}
	
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		alert("Invalid E-mail ID")
		return false
	}
	
	if (str.indexOf(dot,(lat+2))==-1)
	{
		alert("Invalid E-mail ID")
		return false
	}
	
	if (str.indexOf(" ")!=-1)
	{
		alert("Invalid E-mail ID")
		return false
	}
	
	return true	
}

function ValidateMailingList()
{
	var FormName = window.document.Mailing_List;
	
	if(FormName.Name.value==''||FormName.Name.value==null)
	{
		alert("Please give your name")
		FormName.Name.focus();
		return false;
	}
	
	if(FormName.Street.value==''||FormName.Street.value==null)
	{
		alert("Please give street name")
		FormName.Street.focus();
		return false;
	}
	
	if(FormName.City.value==''||FormName.City.value==null)
	{
		alert("Please give city name")
		FormName.City.focus();
		return false;
	}
	
	if(FormName.State.value==''||FormName.State.value==null)
	{
		alert("Please give state name")
		FormName.State.focus();
		return false;
	}
	
	if(FormName.Zip_Code.value==''||FormName.Zip_Code.value==null)
	{
		alert("Please give zip code")
		FormName.Zip_Code.focus();
		return false;
	}
	
	if(FormName.Country.value==''||FormName.Country.value==null)
	{
		alert("Please give country name")
		FormName.Country.focus();
		return false;
	}
	
	var emailID = FormName.Email;
	if((emailID.value=='')||(emailID.value==null))
	{
		alert("Please give your email address")
		emailID.focus();
		return false;
	}
	
	if(echeck(emailID.value)==false)
	{
		emailID.focus()
		return false;
	}
	
	var to_join = confirm("Have you filled all the information correct \?")
	if(to_join == true)
	{
		return true;
	}
	else
	{
		return false;
	}
}