// JavaScript Document



function Validate()
{ 
	if(document.getElementById('name').value=="")
	{
		window.alert("Please enter the Name");
		document.getElementById('name').focus();
		return false;					
	}
	 
	 //email
	   if(document.getElementById('email').value=="")
	{
		window.alert("Please enter Email Id");  
		document.getElementById('email').focus();
		return false;
	}
     if(!email('email') )
	   {
		  return false;  
	   }
	   
	   
	   //phone
	 if(document.getElementById('phone').value=="")
        {
          alert ( "Please enter Phone number" );
          document.getElementById('phone').focus();
		  return false;	
        }
      
       /* var inpVal = parseInt(document.getElementById('phone').value, 10);
        if (isNaN(inpVal))
		{
            alert("Invalid Phone number.");
			document.getElementById('phone').focus();
			return false;
		}*/
		
		if(document.getElementById('address').value=="")
	{
		window.alert("Please enter your address");
		document.getElementById('address').focus();
		return false;					
	}
	
	
	if(document.getElementById('city').value=="")
	{
		window.alert("Please enter your city");
		document.getElementById('city').focus();
		return false;					
	}
	
	
	if(document.getElementById('country').value=="")
	{
		window.alert("Please enter your country");
		document.getElementById('country').focus();
		return false;					
	}
	
	
	if(document.getElementById('zip').value=="")
	{
		window.alert("Please enter the zip code");
		document.getElementById('zip').focus();
		return false;					
	}
	   
	return true;
}




function email(email)
{
/********Declaring variables required for Email Validation********/
	var str = document.getElementById(email).value;
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	/*********End of Declaration************************/
	
	/*********Email Validation Code************/
	if (str.indexOf(at)==-1)
	{
		alert("Invalid Email ID");
		document.getElementById(email).focus();
		return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		alert("Invalid Email ID");
	    document.getElementById(email).focus();
		return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		alert("Invalid Email ID");
		document.getElementById(email).focus();
		return false;
	}
	if (str.indexOf(at,(lat+1))!=-1)
	{
		alert("Invalid Email ID");
		document.getElementById(email).focus();
		return false;
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		alert("Invalid Email ID");
		document.getElementById(email).focus();
		return false;
	}
	if (str.indexOf(dot,(lat+2))==-1)
	{
		alert("Invalid Email ID");
		document.getElementById(email).focus();
		return false;
	}
	if (str.indexOf(" ")!=-1)
	{
		alert("Invalid Email ID");
		document.getElementById(email).focus();
		return false;
	}
				
	/************End Of Email Validation Code****************/
	return true;
}



