var submitcount=0; 
function reset() {
  document.SBform.name.value="";
  document.SBform.email.value="";
  document.SBform.subject.value="";
  document.SBform.url.value="";
  document.SBform.url_title.value="";
  }

// used for Initiating posts
function countFirstSubmit(s) { 
  if ( (document.SBform.subject.value=="") || (document.SBform.body.value=="") )  { 
    alert("HEY THERE!!!!!!\n This is an INITIATING post - the first on a thread - according to the rules, you must have both a title and message to your post!"); return false;
  }else{
    if (submitcount == 0) { 
      submitcount++; 
      s.value = "  Sending...  "; 
      alert("Your post has been submitted. Please wait for the confirmation page to appear - DO NOT RESEND! Thanks.");
      return true; 
    }else{
      alert("PLEASE STAND BY.... \n Your Entry has already been submitted! \n\nThe server may be busy, or someone else may be \n posting on the board at the moment. \n\n If you are absolutely certain you have not already \n submitted your entry, please close this alert box\n - the one you are reading now, \n\n then copy the contents you tried to post by marking \n the text and hitting Ctrl-C... \n\n then refresh the page - for Netscape hold the shift\n key when reloading... \n\n and finally, paste in your message into the message box using Ctrl-V \n\n and try sending it again.  Thanks,  Webmaster"); 
      return false; 
    } 
  }
} 

// used for follow up posts

function countSubmits(s) { 
  if (document.SBform.subject.value=="") { alert("HEY THERE!!!!!!\n You must at least have a title to your post!"); return false;
  }else{
    if (submitcount == 0) { 
      submitcount++; s.value = "  Sending...  "; 
      alert("Your post has been submitted. Please wait for the confirmation page to appear - DO NOT RESEND! Thanks.");
      return true; 
    }else{
      alert("PLEASE STAND BY.... \n Your Entry has already been submitted! \n\nThe server may be busy, or someone else may be \n posting on the board at the moment. \n\n If you are absolutely certain you have not already \n submitted your entry, please close this alert box\n - the one you are reading now, \n\n then copy the contents you tried to post by marking \n the text and hitting Ctrl-C... \n\n then refresh the page - for Netscape hold the shift\n key when reloading... \n\n and finally, paste in your message into the message box using Ctrl-V \n\n and try sending it again.  Thanks,  Webmaster"); 
      return false; 
    } 
  }
} 

function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit) // trim if exceeding max!
    field.value = field.value.substring(0, maxlimit); 
  else 
 countfield.value = maxlimit - field.value.length; // otherwise, update 'characters left' counter
}


function postform(boardcode,followup,origname,origsubject,origdate) {

  var maxthreadlength = 20;
  if ( origsubject.match(/^Re:\s.*/i) ) {
    //do nothing
  }else{
    origsubject = "Re: "+origsubject;
  }

  if       ( boardcode == '1' ) {
    var
      boardscript1 = "acad.cgi";
//      bg1 = "b22200";
      bg1 = "003366";
      bg2 = "F0F0F0";
      fc1 = "ffffff";
  }else if ( boardcode == '2' ) {
    var
      boardscript1 = "ceeque.cgi";
      bg1 = "6D6030";
      bg2 = "CCCC66";
      fc1 = "ffffff";
  }else if ( boardcode == '3' ) {
    var
      boardscript1 = "genxer.cgi";
      bg1 = "793010";
      bg2 = "DCDCA9";
      fc1 = "ffffff";
  }else if ( boardcode == '4' ) {
    var
      boardscript1 = "jernee.cgi";
      bg1 = "684C4C";
      bg2 = "F0F0F0";
      fc1 = "ffffff";
  }else if ( boardcode == '5' ) {
    var
      boardscript1 = "soapbox.cgi";
      bg1 = "684C4C";
      bg2 = "F0F0F0";
      fc1 = "ffffff";
      maxthreadlength = 15;
  }


  //  document.write("(This thread is " + (followup.split(/,/g).length) + " levels deep)<br>");

  if ( followup.split(/,/g).length >= maxthreadlength ) {
    document.write("<div align=\"center\">Thread too long. Please start a new thread if you wish to reply.</div>");
  } else {

    document.write("<form name=\"SBform\" method=POST action=\"http:\/\/www.exfamily.org\/cgi-bin\/"+boardscript1+"\" onSubmit=\"return countSubmits(this.submitbutton)\">");

    document.write("<input type=hidden name=\"followup\" value=\""+followup+"\">");
    document.write("<input type=hidden name=\"origname\" value=\""+origname+"\">");
    document.write("<input type=\"hidden\" name=\"origsubject\" value=\""+origsubject+"\">");
    document.write("<input type=\"hidden\" name=\"origdate\" value=\""+origdate+"\">");
    document.write("");
    document.write("<center>");
    document.write("<table>");
    document.write("<tr>");
    document.write("<td bgcolor="+bg1+" align=right><font color="+fc1+" face=arial>Name:<\/font><\/td>");
    document.write("<td bgcolor="+bg2+">");
    document.write("<input type=text name=\"name\" size=\"30\" onKeyDown=\"textCounter(this.form.name,this.form.remLenB,30);\" onKeyUp=\"textCounter(this.form.name,this.form.remLenB,30);\">");
    document.write("<input readonly type=\"text\" name=\"remLenB\" size=\"3\" maxlength=\"3\" value=\"30\"> characters left");
    document.write("<\/td>");
    document.write("<\/tr>");
    document.write("<tr>");
    document.write("<td bgcolor="+bg1+" align=right><font color="+fc1+" face=arial>Optional Email:<\/font><\/td>");
    document.write("<td bgcolor="+bg2+">");
    document.write("<input type=text name=\"email\" size=\"50\" onKeyDown=\"textCounter(this.form.email,this.form.remLenE,40);\" onKeyUp=\"textCounter(this.form.email,this.form.remLenE,40);\">");
    document.write("<input readonly type=\"text\" name=\"remLenE\" size=\"3\" maxlength=\"3\" value=\"40\"> characters left");
    document.write("<\/td>");
    document.write("<\/tr>");
    document.write("<tr>");
    document.write("<td bgcolor="+bg1+" align=right><font color="+fc1+" face=arial>Subject:<\/font><\/td>");
    document.write("<td bgcolor="+bg2+"><input type=text name=\"subject\" value=\""+origsubject+"\" size=\"50\" onKeyDown=\"textCounter(this.form.subject,this.form.remLenC,70);\" onKeyUp=\"textCounter(this.form.subject,this.form.remLenC,70);\">");
    document.write("<input readonly type=\"text\" name=\"remLenC\" size=\"3\" maxlength=\"3\" value=\"70\"> characters left");
    document.write("<\/td>");
    document.write("<\/tr>");
    document.write("<tr>");
    document.write(" <td bgcolor="+bg1+" align=right><font color="+fc1+" face=arial>Message:<\/font><\/td>");
    document.write("<td bgcolor="+bg2+" valign=\"top\">");
    document.write("<textarea cols=50 rows=10 name=\"body\" wrap=\"virtual\"><\/textarea>");
    document.write("<br><font size=\"1\" color=\"red\">NO SPAM POLICY: No outward bound hyperlinks will be created as of March 2007<\/font>");
    document.write("<\/td>");
    document.write("<\/tr>");
  //  document.write("<tr>");
  //  document.write("<td bgcolor="+bg1+" align=right><font color="+fc1+" face=arial>Optional Link URL:<\/font><\/td>");
  //  document.write("<td bgcolor="+bg2+">");
  //  document.write("<input type=text name=\"url\" size=50 onKeyDown=\"textCounter(this.form.url,this.form.remLenF,100);\" onKeyUp=\"textCounter(this.form.url,this.form.remLenF,100);\">");
  //  document.write("<input readonly type=\"text\" name=\"remLenF\" size=\"4\" maxlength=\"3\" value=\"100\">");
  //  document.write("<\/td>");
  //  document.write("<\/tr>");
  //  document.write("<tr>");
  //  document.write("<td bgcolor="+bg1+" align=right><font color="+fc1+" face=arial>(Opt.) Link Title:<\/font><\/td>");
  //  document.write("<td bgcolor="+bg2+">");
  //  document.write("<input type=text name=\"url_title\" size=50 onKeyDown=\"textCounter(this.form.url_title,this.form.remLenT,50);\" onKeyUp=\"textCounter(this.form.url_title,this.form.remLenT,50);\">");
  //  document.write("<input readonly type=\"text\" name=\"remLenT\" size=\"4\" maxlength=\"3\" value=\"50\">");
  //  document.write("<\/td>");
  //  document.write("<\/tr>");
    document.write("<\/table>");
    document.write("<input type=submit value=\"OK I'm done :-)\" name=\"submitbutton\"> <input type=reset value=\"Naah... I'll start over\">");
    document.write("<\/center>");
    document.write("<\/form>");

  }

}

function newpostform(boardcode,thispost,origsubject) {

  if ( origsubject.match(/^Re:\s.*/i) ) {
    //do nothing
  }else{
    origsubject = "Re: "+origsubject;
  }

  if       ( boardcode == '1' ) {
    var
      boardscript1 = "acad.cgi";
//      bg1 = "b22200";
      bg1 = "003366";
      bg2 = "F0F0F0";
      fc1 = "ffffff";
  }else if ( boardcode == '2' ) {
    var
      boardscript1 = "ceeque.cgi";
      bg1 = "6D6030";
      bg2 = "CCCC66";
      fc1 = "ffffff";
  }else if ( boardcode == '3' ) {
    var
      boardscript1 = "genxer.cgi";
      bg1 = "793010";
      bg2 = "DCDCA9";
      fc1 = "ffffff";
  }else if ( boardcode == '4' ) {
    var
      boardscript1 = "jernee.cgi";
      bg1 = "684C4C";
      bg2 = "F0F0F0";
      fc1 = "ffffff";
  }else if ( boardcode == '5' ) {
    var
      boardscript1 = "soapbox.cgi";
      bg1 = "684C4C";
      bg2 = "F0F0F0";
      fc1 = "ffffff";
  }

  document.write("<form name=\"SBform\" method=POST action=\"http:\/\/www.exfamily.org\/cgi-bin\/"+boardscript1+"\" onSubmit=\"return countSubmits(this.submitbutton)\">");

  document.write("<input type=hidden name=\"spawningpost\" value=\""+thispost+"\">");
  document.write("");
  document.write("<center>");
  document.write("<table>");
  document.write("<tr>");
  document.write("<td bgcolor="+bg1+" align=right><font color="+fc1+" face=arial>Name:<\/font><\/td>");
  document.write("<td bgcolor="+bg2+">");
  document.write("<input type=text name=\"name\" size=\"30\" onKeyDown=\"textCounter(this.form.name,this.form.remLenB,30);\" onKeyUp=\"textCounter(this.form.name,this.form.remLenB,30);\">");
  document.write("<input readonly type=\"text\" name=\"remLenB\" size=\"3\" maxlength=\"3\" value=\"30\"> characters left");
  document.write("<\/td>");
  document.write("<\/tr>");
  document.write("<tr>");
  document.write("<td bgcolor="+bg1+" align=right><font color="+fc1+" face=arial>Optional Email:<\/font><\/td>");
  document.write("<td bgcolor="+bg2+">");
  document.write("<input type=text name=\"email\" size=\"50\" onKeyDown=\"textCounter(this.form.email,this.form.remLenE,40);\" onKeyUp=\"textCounter(this.form.email,this.form.remLenE,40);\">");
  document.write("<input readonly type=\"text\" name=\"remLenE\" size=\"3\" maxlength=\"3\" value=\"40\"> characters left");
  document.write("<\/td>");
  document.write("<\/tr>");
  document.write("<tr>");
  document.write("<td bgcolor="+bg1+" align=right><font color="+fc1+" face=arial>Subject:<\/font><\/td>");
  document.write("<td bgcolor="+bg2+"><input type=text name=\"subject\" value=\""+origsubject+"\" size=\"50\" onKeyDown=\"textCounter(this.form.subject,this.form.remLenC,70);\" onKeyUp=\"textCounter(this.form.subject,this.form.remLenC,70);\">");
  document.write("<input readonly type=\"text\" name=\"remLenC\" size=\"3\" maxlength=\"3\" value=\"70\"> characters left");
  document.write("<\/td>");
  document.write("<\/tr>");
  document.write("<tr>");
  document.write(" <td bgcolor="+bg1+" align=right><font color="+fc1+" face=arial>Message:<\/font><\/td>");
  document.write("<td bgcolor="+bg2+" valign=\"top\">");
  document.write("<textarea cols=50 rows=10 name=\"body\" wrap=\"virtual\"><\/textarea>");
  document.write("<br><font size=\"1\" color=\"red\">NO SPAM POLICY: No outward bound hyperlinks will be created as of March 2007<\/font>");
  document.write("<\/td>");
  document.write("<\/tr>");
  document.write("<\/table>");
  document.write("<input type=submit value=\"OK I'm done :-)\" name=\"submitbutton\"> <input type=reset value=\"Naah... I'll start over\">");
  document.write("<\/center>");
  document.write("<\/form>");


}
