/* Copyright: Copyright (c) 2008 http://ramui.com. All rights reserved.
This product is protected by copyright and distributed under licenses restricting copying, distribution. Permission is granted to the public to download and use this script provided that this Notice and any statement of authorship are reproduced in every page on all copies of the script. */
function validateForm(max){
var errors='';
var str=fw_trim(document.getElementById('fw_contact_name').value);
if (str.length > 40){
errors='Name must be within 40 characters.\n'; }
if (str.length <3){
errors='Write your name.\n'; }
str=fw_trim(document.getElementById('fw_contact_message').value);
if (str.length > max){
errors+='Message length must be within '+max+'characters.\n'; }
if (str.length <10){
errors+='Write some Message.\n'; }
str=fw_trim(document.getElementById('fw_contact_subject').value);
if (str.length > 78){
errors+='Subject length must be within 78 characters.\n'; }
str=fw_trim(document.getElementById('fw_contact_from').value);
if (!((str.indexOf(".") > 0) && (str.indexOf("@") > 0)&&(str.length < 100))){
errors+='Enter correct email id\n'; }
var code = parseInt(document.getElementById('fw_contact_captcha').value);
 if ((code < 1000) || (code > 9999) || isNaN(code)) {
errors+='Enter correct varification code\n'; }
if (errors){
alert('The following error(s) occurred:\n'+errors);
return false;}
return true;}
function fw_image(){
if(!fw_flag){return;}
fw_flag=false;
fw_imageindex=fw_imageindex+1;
document.getElementById('fw_captcha_img').src="mail/images/ajax-loader.gif";
var url="mail/securityimage.php";
var params="index="+fw_imageindex+"&delete=0";
var fw_connection=fw_connect(url,params);
fw_connection.onreadystatechange = function(){
if(fw_connection.readyState == 4 && fw_connection.status == 200){
document.getElementById('fw_captcha_img').src =fw_connection.responseText;
fw_flag=true;
fw_deleteimage();}}}
function fw_deleteimage(){
var url="mail/securityimage.php";
var params="index="+fw_imageindex+"&delete=1";
var fw_connection=fw_connect(url,params);}
function fw_mail(){
document.getElementById('fw_feedback').innerHTML="";
if(validateForm(3000)){
var url = "mail/index.php?sendmail=true";
var params = "name=" + fw_total_encode(document.getElementById('fw_contact_name').value) + "&from=" +fw_total_encode(document.getElementById('fw_contact_from').value) +"&subject=" + fw_total_encode(
document.getElementById('fw_contact_subject').value) + "&message=" +fw_total_encode(document.getElementById('fw_contact_message').value) + "&captcha_code=" + fw_total_encode(
document.getElementById('fw_contact_captcha').value);
var fw_connection=fw_connect(url,params);
fw_connection.onreadystatechange = function(){
if(fw_connection.readyState == 4 && fw_connection.status == 200){
document.getElementById('fw_feedback').innerHTML=fw_connection.responseText;
fw_image();}}}}
var fw_imageindex=0;
var fw_flag=true;
