function validateAdd()
{
	if(fnname()&&fnemail()&&fndetails())
		{
			document.form1.action="feedbacksubmit.php";
			document.form1.submit();
			return true;
		}
		return false;
}

  function fnname()
 {
   var name;
   name = document.form1.name.value;
   
   if(name=="") 
   {
    alert("Name Cannot Be Empty");
    document.form1.name.focus();
    return false;      
   }
    return true;
 }

//function to check the Email
function fnemail()
{
  
  var email;
  email = document.form1.email.value;
	
	//TO FIND A SINGLE QUOTE IN A VALUE
	var SnglQuote=email.indexOf("'");

    if (SnglQuote == "-1")
    {}
    else
    {
        alert("Please Enter a valid Email Address ");
		document.form1.email.focus();
		return false;
    }
    
		atPos = email.indexOf("@",0);
		pPos1 = email.indexOf(".",0);
		periodPos = email.indexOf(".",atPos);

	// Are there consecutive periods?
		pos1 = pPos1;
		pos2 = 0;
		
		 while (pos2 > -1) 
		  {
			pos2 = email.indexOf(".",pos1+1);
			if (pos2 == pos1+1) 
			{
			    alert("Please Enter a valid Email Address ");
				document.form1.email.focus();
				return false;
			} 
			else 
			{
				pos1 = pos2;
			}
		}

	// Is there an @ symbol in the address?

		if (atPos == -1) 
		{
		  
			alert("Please Enter a valid Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Is the @ symbol in the first position?

		if (atPos == 0) 
		{
		    
			alert("Please Enter a valid Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Is there a period in the first position?

		if (pPos1 == 0) 
		{
		    
			alert("Please Enter a valid Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Is there more than one @ symbol in the address?

		if(email.indexOf("@",atPos+1) > -1) 
		{
		    
			alert("Please Enter a valid Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Is there a period after the @ symbol?

		if (periodPos == -1) 
		{
		    
			alert("Please Enter a valid Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Is the period imediately after the @ symbol?

		if (atPos+1 == periodPos) 
		{
		    
			alert("Please Enter a valid Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Are there at least 2 characters after the period?

		if (periodPos+3 > email.length) 
		{
		   
			alert("Please Enter a valid Email Address");
			document.form1.email.focus();
			return false;
		}
	      	return true;
}

function fndetails()
 {
   var details;
   details = document.form1.details.value;
   
   if(details=="") 
   {
    alert("details Cannot Be Empty");
    document.form1.details.focus();
    return false;      
   }
    return true;
 }



function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false;}
else {return true}
}
}


function validate_quote_form(thisform)
{
with (thisform)
{
//if (validate_email(email,"Not a valid e-mail address!")==false)
  //{email.focus();return false;}
  
if (validate_required(fname,"Please Enter Name!")==false)
  {fname.focus();return false;}
/*if (validate_required(coname,"Please Enter Company Name!")==false)
  {coname.focus();return false;}*/
  
/*if (validate_required(website,"Website Address must be filled out!")==false)
  {website.focus();return false;}

if (validate_required(address,"Address must be filled out!")==false)
  {address.focus();return false;}

if (validate_required(city,"City must be filled out!")==false)
  {city.focus();return false;}

if (validate_required(state,"State must be filled out!")==false)
  {state.focus();return false;}

if (validate_required(zip,"Zip must be filled out!")==false)
  {zip.focus();return false;}*/


 
if (validate_required(email,"Please Enter Email!")==false)
  {email.focus();return false;} 

 if (validate_email(email)==false)
  {email.focus();return false;}
  
  if (validate_required(phone,"Please Enter Phone No.!")==false)
  {phone.focus();return false;}
  
  if(IsNumeric(phone.value)==false)
		{
			alert("The phone you entered must contain only numeric values");
			phone.value="";
			phone.focus();
			return false;
		}
		
/*if (validate_required(services,"Services must be filled out!")==false)
  {services.focus();return false;}*/
  

  
}
}


function check_email(field)
{
  
  var email;
  email = field.value;
	
	//TO FIND A SINGLE QUOTE IN A VALUE
	var SnglQuote=email.indexOf("'");

    if (SnglQuote == "-1")
    {}
    else
    {
        alert("Please Enter a valid Email Address ");
		email.focus();
		return false;
    }
    
		atPos = email.indexOf("@",0);
		pPos1 = email.indexOf(".",0);
		periodPos = email.indexOf(".",atPos);

	// Are there consecutive periods?
		pos1 = pPos1;
		pos2 = 0;
		
		 while (pos2 > -1) 
		  {
			pos2 = email.indexOf(".",pos1+1);
			if (pos2 == pos1+1) 
			{
			    alert("Please Enter a valid Email Address ");
				email.focus();
				return false;
			} 
			else 
			{
				pos1 = pos2;
			}
		}

	// Is there an @ symbol in the address?

		if (atPos == -1) 
		{
		  
			alert("Please Enter a valid Email Address ");
			email.focus();
			return false;
		}

	// Is the @ symbol in the first position?

		if (atPos == 0) 
		{
		    
			alert("Please Enter a valid Email Address ");
			email.focus();
			return false;
		}

	// Is there a period in the first position?

		if (pPos1 == 0) 
		{
		    
			alert("Please Enter a valid Email Address ");
			email.focus();
			return false;
		}

	// Is there more than one @ symbol in the address?

		if(email.indexOf("@",atPos+1) > -1) 
		{
		    
			alert("Please Enter a valid Email Address ");
			email.focus();
			return false;
		}

	// Is there a period after the @ symbol?

		if (periodPos == -1) 
		{
		    
			alert("Please Enter a valid Email Address ");
			email.focus();
			return false;
		}

	// Is the period imediately after the @ symbol?

		if (atPos+1 == periodPos) 
		{
		    
			alert("Please Enter a valid Email Address ");
			email.focus();
			return false;
		}

	// Are there at least 2 characters after the period?

		if (periodPos+3 > email.length) 
		{
		   
			alert("Please Enter a valid Email Address");
			email.focus();
			return false;
		}
	      	return true;
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {

   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }


function validate_email(field)
{

	if (field.value==null||field.value=="")
	{
		alert("Please Enter Email Address");
		return false;
	}
	else
	{
			apos=field.value.indexOf("@");
			dotpos=field.value.lastIndexOf(".");
			if (apos<1||dotpos-apos<2) 
			 {
			  alert("Please Enter a valid Email Address");
			  return false;
			  }
			else 
			{
				return true;
			}
	}
	return true;
}
