function ContactUsValidation()
{
	//alert("test");	
	var name = $("#txtName").val();
	var email = $("#txtEmail").val();
	var Website = $("#txtWebsite").val();	
	var Message = $("#rtxtMessage").val();		
	
	if(name==""){
		alert("Please enter Name");
		$("#txtName").focus();
		return false;
	}
	if(email==""){
		alert("Please enter email id.");
		$("#txtEmail").focus();
		return false;
	}  	
	var checkEmail = "@.";
	var checkStr = email;
	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 (EmailAt && EmailPeriod)
		{
			EmailValid = true;
			break;
		}
	}
	if (!EmailValid)
	{
		alert("The \"email\" field must contain an \"@\" and \".\".");
		$("#txtEmail").focus();
		$("#txtEmail").val('');
		return false;
	}	
	
	if(Message=="")
	{
		alert("Please enter Message");
		$("#rtxtMessage").focus();	
		return false;
	}
	else
	{
		$("#LoaderDiv").show();
		 $.post("products/include/contactMail.php", { name: name, email: email, Website: Website,  Message: Message},
		  function(data){
			//alert("Data Loaded: " + data);			
			if(data==1)
			{
				alert("Your information is successfully sent to westside-barbell.com, we will get back to you soon.");
				//document.location.href="thankyou.html";
			}else{
				alert("Your Contact Information has been failed. Please try again.");
			}
			$("#LoaderDiv").hide();
			$("#txtName").val('');
			$("#txtEmail").val('');
			$("#txtWebsite").val('');
			$("#rtxtMessage").val('');
			/*if(data==0)
			{
				alert("Data Loaded: " + data);
				alert("Sorry but the email could not be sent. Please try again!");
			}else{
				$(name).html(data);
				alert("Data Loaded: " + data);				
			}*/
		  });
		return false;
	}
	return true;

}





/*var url = 'http://localhost/westside_rbs/wolf/plugins/comment/image.php?code=';
var captchaOK = 2;  // 2 - not yet checked, 1 - correct, 0 - failed

function getHTTPObject()
{
try {
req = new XMLHttpRequest();
  } catch (err1)
  {
  try {
  req = new ActiveXObject("Msxml12.XMLHTTP");
  } catch (err2)
  {
  try {
	req = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (err3)
	{
req = false;
	}
  }
}
return req;
}

var http = getHTTPObject(); // We create the HTTP Object        

function handleHttpResponse() {
if (http.readyState == 4) {
	captchaOK = http.responseText;
	if(captchaOK != 1) {
	  alert('The entered code was not correct. Please try again');
	  $("#comment-captcha-answer").val('');
	  $("#comment-captcha-answer").focus();
	  return false;
	  }
	 //document.myform.submit();
   }
}

function checkcode(thecode) {
	http.open("GET", url + escape(thecode), true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
}*/
		
function LogCommentsValidation()
{
	//alert("test");	
	var name = $("#comment_form_name").val();
	var email = $("#comment_form_email").val();
	var Captcha = $("#comment-captcha-answer").val();	
	//var Message = $("#rtxtMessage").val();		
	//alert(Captcha);
	
	if(name==""){
		alert("Please enter Name");
		$("#comment_form_name").focus();
		return false;
	}
	if(email==""){
		alert("Please enter email id.");
		$("#comment_form_email").focus();
		return false;
	}  	
	var checkEmail = "@.";
	var checkStr = email;
	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 (EmailAt && EmailPeriod)
		{
			EmailValid = true;
			break;
		}
	}
	if (!EmailValid)
	{
		alert("The \"email\" field must contain an \"@\" and \".\".");
		$("#comment_form_email").focus();
		$("#comment_form_email").val('');
		return false;
	}	
	if(Captcha=="")
	{
		alert('Please enter the string from the displayed image');
		$("#comment-captcha-answer").focus();
		//$("#comment-captcha-answer").val('');
		return false;
	}
	/*else if(Captcha=="")
	{
		// Now the Ajax CAPTCHA validation
		checkcode($("#comment-captcha-answer").val());
		return false;
	}*/
	
	/*if(Message=="")
	{
		alert("Please enter Message");
		$("#rtxtMessage").focus();	
		return false;
	}*/
	else
	{
		submit();
	}
	return true;

}
