// JavaScript Document
function validate(){
	var st=document.contact.email1.value;
	var isChecked = false;
	
	if(document.contact.fname.value== "")
	{
	alert("Please enter your first name");
	document.contact.fname.focus();
	document.contact.fname.select();
	return false;
	}
	
	if(document.contact.lname.value== "")
	{
	alert("Please enter your last name");
	document.contact.lname.focus();
	document.contact.lname.select();
	return false;
	}
	
	if(document.contact.address1.value== "")
	{
	alert("Please enter your address");
	document.contact.address1.focus();
	document.contact.address1.select();
	return false;
	}
	
	if(document.contact.city.value== "")
	{
	alert("Please enter your city");
	document.contact.city.focus();
	document.contact.city.select();
	return false;
	}
	
	if(document.contact.state.value== "")
	{
	alert("Please enter your state");
	document.contact.state.focus();
	document.contact.state.select();
	return false;
	}
	
	

	//Code for PHONE NO.
	var stripped = document.contact.phone.value.replace(/[\(\)\.\-\ ]/g, ''); 
	var illegalChars = /[\W_a-zA-Z]/;	
	if(document.contact.phone.value== "" )
	{
	alert("Phone Number should not be left blank.");
	document.contact.phone.focus();
	document.contact.phone.select();
	return false;
	}else if (isNaN(parseInt(stripped)) || (illegalChars.test(document.contact.phone.value))) {
        alert("The Phone Number should be digit.\n");
        document.contact.phone.focus();
		document.contact.phone.select();
		return false;
    }

			
	if(document.contact.email1.value=="")
	{
		alert("Please enter your email1");
		document.contact.email1.focus();
		document.contact.email1.select();
		return false;
	}
	else
	{			
		if(checkemail1(st)!=true)
		{
			alert("Invalid E-Mail  \n"+st);
			document.contact.email1.focus();
			document.contact.email1.select();
			return false; 
		 }
	}
	
	//Group checkbox validation
	/*

		if((document.contact.services1.checked == false) && (document.contact.services2.checked == false) && (document.contact.services3.checked == false) && (document.contact.services4.checked == false))
	{
		alert("Please check, What services are you interested in?");
		return false;
	}
	*/
	
}

function checkemail1(str)
{
	if((str.indexOf("@")==-1))
	{
		fstr="Please Enter @ or .";
		return false;
	}
	else
	{
	if((str.indexOf("@") == 0) )
	{
		fstr="@  Cannot Be first";
		alert(fstr);
		return false;
	}
	if((str.indexOf("@") == (str.length-1)))
	{
		fstr="@ Cannot Be Last";
		return false;
	}

	
	if((str.indexOf("@")+1) == str.indexOf("."))
	{
		fstr="@. IS Invalid email1";
		return false;
	}
	}
	var cp=0;					
	if(cp==2)
	{
		fstr="@ cannnot be repeated";
		return false;
	}
	return true;
}

