/* Copyright: Copyright (c) 2008 http://www.free-websites.co.cc. 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=trim(form1.name.value);
if (str.length > 40){
errors='Message length must be within 40 characters.\n'; }
if (str.length <3){
errors='Write your name.\n'; }

str=trim(form1.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=trim(form1.subject.value);
if (str.length > 78){
errors+='Subject length must be within 78 characters.\n'; }

str=trim(form1.from.value);
if (!((str.indexOf(".") > 0) && (str.indexOf("@") > 0)&&(str.length < 320))){
errors+='Enter correct email id\n'; }

var code = parseInt(form1.captcha_code.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 trim(str){
return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');}
