// JavaScript Document
function validation()

{

fname = document.form1.fname.value;

cname = document.form1.cname.value;

url=document.form1.url.value;


phone =  document.form1.phone.value;

email = document.form1.email.value;

desc = document.form1.desc.value;

aboutus = document.form1.aboutus.value;

secCode =  document.form1.secCode.value;



if(fname=="")
{
alert("Enter your Name");
document.form1.fname.focus();
return false;
}
if(cname=="")
{
alert("Enter your Company Name");
document.form1.cname.focus();
return false;
}
if(url!="")
{
var a = 'http://';
var b = url.substring(0,7); 
var j= url.indexOf(".");
if(j<2 || a!=b)
		{	
		alert("Invalid URL");
		document.form1.url.value="";
		document.form1.url.focus();
		return false;
		}
}

//if(phone=="")
//{
//alert("Enter your Phone Number");
//document.form1.phone.focus();
//return false;
//}
if(isNaN(phone))
{
alert("Invalid Phone Number");
document.form1.phone.value="";
document.form1.phone.focus();
return false;
}

if(email=="")
{
alert("Enter your Email");
document.form1.email.focus();
return false;
}else if(echeck(email)==false)
{
document.form1.email.value="";
document.form1.email.focus();
return false;
}

if(desc=="")
{
alert("Enter your Message");
document.form1.desc.focus();
return false;
}

if(aboutus=="")
{
alert("Select a value");
document.form1.aboutus.focus();
return false;
}

if(secCode=="")
{
alert("Copy the security code");
document.form1.secCode.focus();
return false;
}
}
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					
}