<?php 
	session_start(); 
	include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';
	
	$securimage = new Securimage();
	
	if ($securimage->check($_POST['captcha_code']) == false) {
	// the code was incorrect
	// you should handle the error so that the form processor doesn't continue

	// or you can use the following code if there is no validation or you do not know how
	echo "The security code entered was incorrect.<br /><br />";
	echo "Please go <a href='javascript:history.go(-1)'>back</a> and try again.";
	exit;
}

?>

function validate(theForm)
{
	if (theForm.cname && (theForm.cname.value == "") || theForm.cname && (theForm.cname.value == "Name"))
	{
	alert("Please Enter Name");
	theForm.cname.focus();
	return (false);
	}	
	
	if (theForm.cemail && (theForm.cemail.value == ""))
	{
	alert("Please Enter Email");
	theForm.cemail.focus();
	return (false);
	}
	    // test if valid email address, must have @ and .
		var checkEmail = "@.";
		var checkStr = theForm.cemail.value;
		var EmailValid = false;
		var EmailAt = false;
		var EmailPeriod = false;
		for (i = 0;  i < checkStr.length;  i++)
		{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkEmail.length;  j++)
		{
		if (ch == checkEmail.charAt(j) && ch == "@")
		EmailAt = true;
		if (ch == checkEmail.charAt(j) && ch == ".")
		EmailPeriod = true;
			  if (EmailAt && EmailPeriod)
				break;
			  if (j == checkEmail.length)
				break;
			}
			// if both the @ and . were in the string
		if (EmailAt && EmailPeriod)
		{
				EmailValid = true
				break;
			}
		}
		if (!EmailValid)
		{
		alert("Please Enter valid email id.");
		theForm.cemail.focus();
		return (false);
		}
	else
	{
		return true;
		//form.action='/contacts';
		//form.submit();
	}
}

