// JavaScript Document

function fb_Validation(){
  if ((fb_validName()==true) && (fb_emailLength()==true) && (fb_emailValid(document.form1.email.value)==true) && (sub_textValid()==true) && (fb_textValid()==true)){
	return true;	
 }else{
   return false;
 }
}

function fb_validName()
{
  if ((document.form1.name.value=="") || (document.form1.name.value==null))
  {
    alert("Please enter your Name.");
	document.form1.name.focus();
	return false;
   }
   return true;
}  
 
function fb_emailLength()
{
  var emailID=document.form1.email.value;

  if ((emailID==null)||(emailID==""))
  {
	  alert("Please enter your Email address.");
	  	document.form1.email.focus();
	  return false;
  }
  
  if ((emailID.length < 5))
  {
	  alert("Email address should be a valid one and more than 5 characters.");
	  document.form1.email.focus();
	  return false;
  }
  return true;
}
 
function fb_emailValid(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. Please try again.");
	   document.form1.email.focus();
	   return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		alert("Invalid Email address. Please try again.");
	  	document.form1.email.focus();		
		return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		alert("Invalid Email address. Please try again.");
	  	document.form1.email.focus();		
		return false;
	}

	if (str.indexOf(at,(lat+1))!=-1)
	{
		alert("Invalid Email address. Please try again.");
	  	document.form1.email.focus();		
		return false;
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		alert("Invalid Email address. Please try again.");
	  	document.form1.email.focus();		
		return false;
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
		alert("Invalid Email address. Please try again.");
	  	document.form1.email.focus();		
		return false;
	}
		
	if (str.indexOf(" ")!=-1)
	{
		alert("Invalid Email address. Please try again.");
	  	document.form1.email.focus();		
		return false;
	}

 	return true;
}

function sub_textValid()
{
	var sel=document.form1.subject.options[document.form1.subject.selectedIndex].text;
	
	if (sel=="SELECT")
    {
		alert("Please select a subject");
	  	document.form1.subject.focus();	   
		return false;
	}
	 return true;	
}

function fb_textValid()
{
  if ((document.form1.content.value=="") || (document.form1.content.value==null))
     {
	   alert("Please enter your Questions/Comments.");
	  	document.form1.content.focus();	   
	   return false;
	 }
	 return true;
}