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 Email Address");
		return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		alert("Invalid Email Address");
		return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid Email Address");
		return false;
	}
	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid Email Address");
		return false;
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid Email Address");
		return false;
	}
	if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid Email Address");
		return false;
	}
	if (str.indexOf(" ")!=-1){
		alert("Invalid Email Address");
		return false;
	}
	return true;
}

function checkval()
{
	
	
	if(document.advForm.firstName.value=="")
	{
		alert("First Name could not be left Blank");
		document.advForm.firstName.focus();
		return false;
	}
	if(document.advForm.lastName.value=="")
	{
		alert("Last Name could not be left Blank");
		document.advForm.lastName.focus();
		return false;
	}
	if(document.advForm.address1.value=="")
	{
		alert("Address1 could not be left Blank");
		document.advForm.address1.focus();
		return false;
	}
	if(document.advForm.city.value=="")
	{
		alert("City could not be left Blank");
		document.advForm.city.focus();
		return false;
	}
	if(document.advForm.country.selectedIndex<=0)
	{
		alert("Please select Country");
		document.advForm.country.focus();
		return false;
	}
	if(document.advForm.zip.value=="")
	{
		alert("Zip Code could not be left Blank");
		document.advForm.zip.focus();
		return false;
	}
	
	else
	{
		if(isNaN(document.advForm.zip.value))
	{
		alert("Fill valid zip code");
		document.advForm.zip.focus();
		return false;
	}
		
		}
	
	if(document.advForm.phoneNum1.value != "")
	{
		if(isNaN(document.advForm.phoneNum1.value))
		{
			alert("Fill only number");
			document.advForm.phoneNum1.focus();
			return false;
		}
		
    } 
	if(document.advForm.phoneNum2.value != "")
	{
		if(isNaN(document.advForm.phoneNum2.value))
		{
			alert("Fill only number");
			document.advForm.phoneNum2.focus();
			return false;
		}
		
    } 
	if(document.advForm.email.value=="")
	{
		alert("Email Address could not be left Blank");
		document.advForm.email.focus();
		return false;
	}
	if(document.advForm.password.value=="")
	{
		alert("Password could not be left Blank");
		document.advForm.password.focus();
		return false;
	}
	if(document.advForm.password.value != document.advForm.password1.value )
	{
		alert("Password is not same");
		document.advForm.password1.focus();
		document.advForm.password1.select();
		return false;
	}
	if (echeck(document.advForm.email.value)==false)
	{
		document.advForm.email.focus();
		return false;
	}
	echeck(document.advForm.email.value);

	return true;
}