/* 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(){
var warnings='';
var errors='';
var str=fw_trim(document.frmMail.cc.value);
var c=countme(str);
if (c<1){warnings+='Empty Cc field.\n';}
if (c>25){errors+='Max. 25 email in Cc field allowed.\n';}
str=fw_trim(document.frmMail.bcc.value);
c=countme(str);
if (c<1){warnings+='Empty Bcc field.\n';}
if (c>25){errors+='Max. 25 email in Bcc field allowed.\n';}
str=fw_trim(document.frmMail.to.value);
c=countme(str);
if (c<1){errors+='Empty To field.\n';}
if (c>50){errors+='Max. 50 email in To field allowed.\n';}
str=fw_trim(document.frmMail.message.value);
if (str.length <10){
errors+='Write some Message.\n'; }
str=fw_trim(document.frmMail.subject.value);
if (str.length > 78){errors+='Subject length must be within 78 characters.\n'; }
if (str.length<2){warnings+='Subject field is empty.\n'; }
str=fw_trim(document.frmMail.reply.value);
if (!((str.indexOf(".") > 0) && (str.indexOf("@") > 0))){
warnings+='Empty "Reply to" field.\n'; }
if (countme(str)>1){errors+='Enter correct email id in "Reply to" field.\n';}
str=fw_trim(document.frmMail.from.value);
if (!((str.indexOf(".") > 0) && (str.indexOf("@") > 0)&&(str.length < 100))){
errors+='Enter correct email id in Frem field.\n'; }
if (errors){
alert('The following error(s) occurred:\n'+errors);
return false; }
if(warnings){
var x=window.confirm('Warning!\n'+warnings+'Are you sure to send this message?')
if (!x)
return false;}
return true;
}
function fwSendmail(type){
if(validateForm()){
var url = "index.php?action=" + type;
var params = "to=" +fw_total_encode(document.frmMail.to.value) + "&cc=" +fw_total_encode(document.frmMail.cc.value) + "&bcc=" +fw_total_encode(document.frmMail.bcc.value) + "&from=" +fw_total_encode(document.frmMail.from.value) + "&reply=" +fw_total_encode(document.frmMail.reply.value) + "&subject=" +fw_total_encode(document.frmMail.subject.value) + "&message=" +fw_total_encode(document.frmMail.message.value);
var fw_connection = fw_connect(url,params);
fw_connection.onreadystatechange = function(){
if(fw_connection.readyState == 4 && fw_connection.status == 200){
document.getElementById('feedback').innerHTML =fw_connection.responseText;}}}
}
function countme(str){
count = 0;
pos = str.indexOf("@");
while ( pos != -1 ) {
 count++;
 pos = str.indexOf("@",pos+1);
}
return count;
}
function validateLogin(o){
var errors=fw_checkuser(fw_trim(o.name.value));
errors+=fw_checkpassword(fw_trim(o.password.value));
if (errors){
alert('The following error(s) occurred:\n'+errors);
return false; }
return true;
}
function ForgetPassword(o){
var errors=fw_checkuser(fw_trim(o.admin.value));
var str=fw_trim(o.email.value);
if(!((str.indexOf(".") > 0) && (str.indexOf("@") > 0)&&(str.length < 100))){errors+='Enter correct email id\n';}
if (errors){alert('The following error(s) occurred:\n'+errors);return false;}
return true;
}
function fw_responder(){
var url = "index.php?action=4";
var params = "response=" + fw_total_encode(document.getElementById('fw_response').value);
var fw_connection=fw_connect(url,params);
fw_connection.onreadystatechange = function(){
if(fw_connection.readyState == 4){
document.getElementById('feedback').innerHTML = fw_connection.responseText;}}
}
