/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Paul Tuckey | http://tuckey.org/ */

function mailform(name) {
if ( name == 'end' ) {
document.write('</td><td background="fborderr.gif" width="18"></td></tr><tr><td>');
document.write('<img src="fborderbl.gif" width="18" height="18"></td><td background="fborderb.gif"></td><td>');
document.write('<img src="fborderbr.gif" width="18" height="18"></td></tr></table></form>');
} else {
document.write('<table border="0" cellspacing="0" cellpadding="0" align="center"><tr><td>');
document.write('<img src="fbordertl.gif" width="18" height="18"></td><td background="fbordert.gif"></td><td>');
document.write('<img src="fbordertr.gif" width="18" height="18"></td></tr><tr><td background="fborderl.gif" width="18">');
document.write('</td><td bgcolor="#ffff33"><form method="post" action="/cgi-bin/mail/Mail.cgi">');
document.write('<input type="hidden" name="env_report" value="REMOTE_HOST,HTTP_USER_AGENT">');
document.write('<input type="hidden" name="print_config" value="email">');
document.write("<input type=hidden name=recipient value='" + name + "@" + "BnaiTikvah.org'>")
}}

function checkrequired(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,8)=="required") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false; break;
} } } }
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("Please make sure the "+shortFieldName+" field was properly completed.");
return false; } else return true;
}


function countLines(strtocount, cols) {
var hard_lines = 1;
var last = 0;
while ( true ) {
  last = strtocount.indexOf("\n", last+1);
  hard_lines ++;
  if ( last == -1 ) break;
}
var soft_lines = Math.round(strtocount.length / (cols-1));
var hard = eval("hard_lines  " + unescape("%3e") + "soft_lines;");
if ( hard ) soft_lines = hard_lines;
 return soft_lines;
}
function cleanForm() {
var the_form = document.forms[0];
for ( var x in the_form ) {
 if ( ! the_form[x] ) continue;
 if( typeof the_form[x].rows != "number" ) continue;
the_form[x].rows = countLines(the_form[x].value,the_form[x].cols) +1;
}
setTimeout("cleanForm();", 300);
}

function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
  window.onload = func;
 } else {
window.onload = function() {
if (oldonload) { oldonload();
}
func();
} } }

function checkCR(evt) {
var evt  = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
addLoadEvent(function() {
cleanForm();
});

document.onkeypress = checkCR;