// JavaScript Document
function notempty(edit,comment)
{
  flag=true;
  input=new String(edit.value);
  if (input.length==0)
  {
  	alert(comment);
    flag=false;
  }
  return(flag);

}

function isValidEmail(edit, comment) {
  str=edit.value;
  flag=(str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  if (!flag)
  {
    alert(comment);
  }
  return flag;
}

function is_numeric(edit,comment)
{
	numeric=new String("0123456789"); 
	input=new String(edit.value);
	len=input.length;
	flag=true;
	for (i=0;i<=len-1;i++)
	{
		temp=false;
		for (j=0;j<=9;j++)
		{   
			if (input.charAt(i) == numeric.charAt(j))
			{
				temp=true;
				break;
			}

		} 
		if (temp==false)
		{
			flag=false;
			alert(comment);
			break;
		}		
	}  
	return(flag); 
}

function validateForm(form)
{
  if(notempty(form.enquiry_type,'Subject is required.') && notempty(form.name,'Name is required.') && notempty(form.phone,'Phone is required.') && is_numeric(form.phone,'Phone is not valid.') &&  notempty(form.email,'Email is required.') && isValidEmail(form.email,'Email address is not valid.') && notempty(form.vercode,'Image verification is required.')){ 
  return true;
}else{ 
  return false;
}
}
