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("Please enter a valid email address.");
	   return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
	   alert("Please enter a valid email address.");
	   return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
	   alert("Please enter a valid email address.");
		return false;
	}

	 if (str.indexOf(at,(lat+1))!=-1)
	 {
	   alert("Please enter a valid email address.");
		return false;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	 {
	   alert("Please enter a valid email address.");
		return false;
	 }

	 if (str.indexOf(dot,(lat+2))==-1)
	 {
	   alert("Please enter a valid email address.");
		return false;
	 }

	 if (str.indexOf(" ")!=-1)
	 {
	   alert("Please enter a valid email address.");
		return false;
	 }

	 return true;
}


function ValidateForm()
{
	var first_nameID=document.frmSIGNUP1.first_name;
	var last_nameID=document.frmSIGNUP1.last_name;
	var client_streetID=document.frmSIGNUP1.client_street;
	var client_cityID=document.frmSIGNUP1.client_city;
	var client_stateID=document.frmSIGNUP1.client_state;
	var client_zipID=document.frmSIGNUP1.client_zip;
	var client_workphone1ID=document.frmSIGNUP1.client_dayphone1;
	var client_workphone2ID=document.frmSIGNUP1.client_dayphone2;
	var client_workphone3ID=document.frmSIGNUP1.client_dayphone3;
	var client_emailID=document.frmSIGNUP1.client_email;
	
	var holder=document.frmSIGNUP1.client_holder;
	var client_cardtype=document.frmSIGNUP1.client_cardtype;
	var client_cvnumber=document.frmSIGNUP1.client_cvnumber;
	var client_cardno=document.frmSIGNUP1.client_cardno;

if (document.getElementById('client_email').value != document.getElementById('client_email2').value)
	{
		alert ('Email and confirm email do not match.\nPlease make sure you input your email correctly.');
		document.getElementById('client_email').focus();
		return false;
	}

	if (first_nameID.value==null || first_nameID.value=="")
	{
		alert("Please provide your first name.");
		first_nameID.focus();
		return false;
	}

	if (last_nameID.value==null || last_nameID.value=="")
	{
		alert("Please provide your last name.");
		last_nameID.focus();
		return false;
	}

	if (client_streetID.value==null || client_streetID.value=="" || client_streetID.value.length < 3)
	{
		alert("Please enter your Street address.");
		client_streetID.focus();
		return false;
	}

	if (client_cityID.value==null || client_cityID.value=="" || client_cityID.value.length < 2)
	{
		alert("Please provide your City.");
		client_cityID.focus();
		return false;
	}

	if (client_stateID.value==null || client_stateID.value=="")
	{
		alert("Please choose your State.");
		client_stateID.focus();
		return false;
	}

	if (client_zipID.value==null || client_zipID.value=="" ||  isNaN(client_zipID.value))
	{
		alert("Please provide your Zip code.");
		client_zipID.focus();
		return false;
	}
	if(client_zipID.value.length < 5 )
	{
		alert("Please enter valid Zip-code.");
		client_zipID.focus();
		return false;
	}

	if (client_workphone1ID.value==null || client_workphone1ID.value=="" || client_workphone1ID.value.length < 3 || isNaN(client_workphone1ID.value))
	{
		alert("Please provide the area code for your Daytime Phone.");
		client_workphone1ID.focus();
		return false;
	}

	if (client_workphone2ID.value==null || client_workphone2ID.value=="" || client_workphone2ID.value.length < 3 || client_workphone2ID.value==555 || isNaN(client_workphone2ID.value))
	{
		alert("Please provide the prefix for your Daytime Phone.");
		client_workphone2ID.focus();
		return false;
	}

	if (client_workphone3ID.value==null || client_workphone3ID.value=="" || client_workphone3ID.value.length < 4 || isNaN(client_workphone3ID.value))
	{
		alert("Please provide the suffix for your Daytime Phone.");
		client_workphone3ID.focus();
		return false;
	}
	

if(holder.value=="")
	{
		alert("Please provide the holder name.");
		holder.focus();
		return false;
	}
		if(client_cardtype.value=="")
	{
		alert("Please provide the card type.");
		client_cardtype.focus();
		return false;
	}
		
		if(client_cardno.value=="")
	{
		alert("Please provide the card number.");
		client_cardno.focus();
		return false;
	}
		if(client_cardno.value.length < 16 )
	{
		alert("Please enter valid card number.");
		client_cardno.focus();
		return false;
	}
	if(client_cvnumber.value=="")
	{
		alert("Please provide the CV Number.");
		client_cvnumber.focus();
		return false;
	}

	if (client_emailID.value==null || client_emailID.value=="")
	{
		alert("Please provide a valid email address.");
		client_emailID.focus();
		return false;
	}

	if (echeck(client_emailID.value)==false)
	{
		client_emailID.focus();
		return false;
	}
		return true;
 }
