isEmailFeature = 1;
if (typeof DEBUGMODE == "undefined") DEBUGMODE = 0;
///////////////////////////////////////////////////////////////////////////////////////////
function doBeforeSubmitting() {testEmailText(EMAILSTRING); //***DELETE THIS         //alert("submitting1...");
destinationAddress = top.genWindowObject.document.mailButtonForm["toAddress"].value;//alert("submitting2...");

//----
if (!(verifyAddress(destinationAddress)))
  {
   //alert("submitting3...");
   confirmMsg = "The email address \"" +destinationAddress+ "\" does not appear to be valid. It should be of the form:\n'name@somewhere.domain'\n(Your email might not arrive at any destination.)\n \nDo you still wish to continue?";
   submitformOK = (window.confirm(confirmMsg)); //alert("submitformOK: " + submitformOK); //alert("submitting4...");
/* 
   if (submitformOK){             //alert("submitting5...");   
     top.genWindowObject.onblur=new Function("top.genWindowObject.window.focus();top.genWindowObject.clickcount=(typeof top.genWindowObject.clickcount!='number')?2:++top.genWindowObject.clickcount;if(!(top.genWindowObject.clickcount % 3)){alert('Still attempting to submit your email... Close the generated window in order to cancel attempt.')}");
    }; //end IF submitformOK
*/
   top.genWindowObject.focus();
   return(submitformOK);
  };
//----
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////

function verifyAddress(checkThisAddress) { 
 if (checkThisAddress!=null && checkThisAddress!="")
  { atindx = checkThisAddress.indexOf("@");
    dotindx = checkThisAddress.indexOf(".");
    validaddress = (atindx>0 && dotindx>(atindx+1) && dotindx<checkThisAddress.length)?1:0;
    if (validaddress) {return true} else {return false};
  } else {return false};
return false;
}
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
var EMAILSTRING = new String(" ");
var emailSeparator = new String("");
var brokenSeparator = new String("\n \n  ----------------------------------------------------------"); //EMAILSTRING
var solidSeparator = new String("\n________________________________________________________________\n "); //EMAILSTRING
var mainHeadingH2 = "";
var subHeadingH3 = "";
///////////////////////////////////////////////////////////////////////////////////////////

if (typeof this.booktitle == "undefined")  // ie: IF NOT SPECIFIED IN MAIN .htm FILE...
   {booktitle = "Interactive Edition"};

if (typeof pagename == "undefined")
   { //alert('undefined')
     if (mainHeadingH2 != " ") {pagename = mainHeadingH2}
     else if (subHeadingH3 != " ") {pagename = subHeadingH3}
     else {pagename = booktitle};
   };
   
///////////////////////////////////////////////////////////////////////////////////////////
var usersName=""; 
var senderAddress=""; 
var destinationAddress="";
writeEmailTableSuccess=0;
function writeEmailTable(windowObjectName)
{
--writeEmailTableSuccess;
if (writeEmailTableSuccess<-2) {return false};
with (windowObjectName)
{

writeln("<center><FORM NAME=\"mailButtonForm\" TYPE=\"SUBMIT\" METHOD=\"POST\" ACTION=\"http://ajax.abacon.com/cgi-bin/abacon/intered/mailfwd.cgi\" onSubmit=\"if(typeof(top.opener)=='object'&&top.opener!=null){if(top.opener.document && typeof(top.opener.isEmailFeature)!='undefined'){return top.opener.doBeforeSubmitting();}};\">");
  //          http://ajax.abacon.com/cgi-bin/divisions/abacon/intered/mailfwd.cgi
  //          http://ajax.abacon.com/cgi-bin/abacon/intered/mailfwd.cgi
  // TARGET=\"_top\"  // bgcolor='#DDDDDD' // ENCTYPE=\"text/plain\"
  //   development:  ajax.abacon.com/cgi-bin/abacon/intered/mailfwd.cgi
  //   production :   www.abacon.com/cgi-bin/abacon/intered/mailfwd.cgi
     
writeln("<table CELLSPACING=1 CELLPADDING=1 border=0>");

writeln("<TR><td><INPUT TYPE=\"HIDDEN\" NAME=\"mailText\" VALUE=\"" + escape(EMAILSTRING) + "\">");
writeln("<INPUT TYPE=\"HIDDEN\" NAME=\"bookTitle\" VALUE=\"" + escape(booktitle) + "\"></td></TR>");
writeln("<TR><td><INPUT TYPE=\"HIDDEN\" NAME=\"emailSubject\" VALUE=\"" + escape(pagename) + "\"></td></TR>");



writeln("<TR><td ALIGN=CENTER COLSPAN=2><b>"+EmailerDirections+"</b></td></TR>");

writeln("<TR><td ALIGN=RIGHT>Your name: </td><td><INPUT TYPE=\"TEXT\" SIZE=30 NAME=\"studentName\" VALUE=\"" + usersName + "\" onChange=\"if(typeof(top.opener)=='object'&&top.opener!=null){if(top.opener.document && typeof(top.opener.isEmailFeature)!='undefined'){top.opener.SetAllCookies('studentName');}};\"></td></TR>");

writeln("<TR><td ALIGN=RIGHT> Your email address: </td><td> <INPUT TYPE=\"TEXT\" SIZE=30 NAME=\"fromAddress\" VALUE=\"" + senderAddress + "\" onChange=\"if(typeof(top.opener)=='object'&&top.opener!=null){if(top.opener.document && typeof(top.opener.isEmailFeature)!='undefined'){top.opener.SetAllCookies('fromAddress');}};\"></td></TR>"); 

writeln("<TR><td ALIGN=RIGHT>Email to: </td><td> <INPUT TYPE=\"TEXT\" SIZE=30 NAME=\"toAddress\" VALUE=\"" + destinationAddress + "\" onChange=\"if(typeof(top.opener)=='object'&&top.opener!=null){if(top.opener.document && typeof(top.opener.isEmailFeature)!='undefined'){top.opener.SetAllCookies('toAddress');}};\"></td></TR>");

writeln("<TR><td COLSPAN=2 ALIGN=CENTER> <INPUT TYPE=\"SUBMIT\" NAME=\"emailSubmitter\" VALUE=\" Submit... \"> </td></tr></table></FORM></center>");
        //onClick=\"top.opener.testEmailText(top.opener.EMAILSTRING);\" 
        
} // END of WITH statement
Fill_InFormValues();
writeEmailTableSuccess=1;
return true;
} // end of fn() "writeEmailTable"

///////////////////////////////////////////////////////////////////////////////////////////

function GetCookieTempl(inputName) 
{ ckString=document.cookie;

 if  (ckString!=null && ckString!="" && ckString.indexOf(inputName)!=-1)
    {
     getCutPoints(inputName,ckString);  
     ckVal=ckString.substring(startcut,endcut);
     return unescape(ckVal);
     }
else  { return null };

return null;
}
//-----------------
  startcut=0;
  endcut=0;
  
function getCutPoints(inputName,inputString) 
{   ckdelimiter=  ";";  inputName+=  "="; 

 if (inputString!=""&&inputString!=null&&inputString.length>1)
    {
     startcut = inputString.indexOf(inputName)+inputName.length;
     endcut   = inputString.indexOf(ckdelimiter, startcut);  
     if (endcut==-1){endcut=ckString.length};   
    };
} //end of fn()

//---------------------
 function SetCookieTempl(inputName,inputValue) 
{
  todaysdate = new Date();
    expidate = new Date();
    
 if(typeof(todaysdate.setFullYear) == "function") 
   { incrementYear = (parseInt(todaysdate.getFullYear())) + 1; 
     if (typeof incrementYear != "number" || isNaN(incrementYear) || incrementYear>2050) {incrementYear=2012};
     expidate.setFullYear(incrementYear); 
 } else {
  tdate_msec = todaysdate.getTime();     
  mseconds_later = 1000*60*60*24*365;    
  mseconds = tdate_msec + mseconds_later;
  expidate.setTime(mseconds);      
 }; 

  if (inputValue!=null && inputValue.toUpperCase()=="DELETE"){alert("Deleting cookie\""+inputName+"\"."); 
  if (typeof notcapable=='number' && notcapable){expidate.setYear(1971)}else{expidate.setFullYear(1971)} };//DELETE COOKIE
     
  ckattributes= "; expires=" + expidate.toGMTString() + "; path=/";  
  
//-.-.-.-.-.-.-.-.-.-.-.-
  if (inputValue!=null && inputValue.indexOf("\r")==-1 && inputValue.indexOf("\n")==-1)
     { document.cookie = inputName +"="+ escape(inputValue) +ckattributes };
} 
//---------------------
 
///////////////////////////////////////////////////////////////////////////////////////////

var oldCookieVal = "<<enter an address>>";
var newCookieVal = "";


function SetAllCookies(cookieToGet)
{
oldCookieVal = GetCookieTempl(cookieToGet);// alert(cookieToGet);

SetCookieTempl(cookieToGet, top.genWindowObject.document.mailButtonForm[cookieToGet].value);

newCookieVal = GetCookieTempl(cookieToGet);

if (cookieToGet!="studentName")
{
addressTypeMsg = (cookieToGet=="toAddress")? "the DESTINATION":"your REPLY email";

invalidMsg = (!verifyAddress(newCookieVal))?  "\n \n(This does not appear to be a properly-formatted email address.)":" ";

if (oldCookieVal!=newCookieVal && oldCookieVal!=null) {alert("You have changed  " +addressTypeMsg+ " address from: \"" + oldCookieVal + "\" to: \"" + newCookieVal + "\"." + invalidMsg)};
} // end IF

top.genWindowObject.focus();

} // end of SetAllCookies()

Fill_InFormValuesSuccess=0;
function Fill_InFormValues() {
if(Fill_InFormValuesSuccess<=-1){return false;}
--Fill_InFormValuesSuccess;

destinationAddress = GetCookieTempl("toAddress");
senderAddress = GetCookieTempl("fromAddress");
usersName = GetCookieTempl("studentName");

if (destinationAddress==null) {destinationAddress = ""};
if (senderAddress==null) {senderAddress = ""};
if (usersName==null) {usersName = ""};

if (typeof top.genWindowObject != "undefined" && typeof top.genWindowObject.document != "undefined") 
  {
    with (top.genWindowObject.document) {
      mailButtonForm["toAddress"].value=destinationAddress;
      mailButtonForm["fromAddress"].value=senderAddress;
      mailButtonForm["studentName"].value=usersName;
  };  // end of WITH
 };
Fill_InFormValuesSuccess=1; 
return true;
} //end of fn()

/////////////////////////////////////////////////

testEM=1;
function testEmailText(inputString)
{
if (testEM==1) {

testWin = window.open('','testWINDOW',"toolbar=yes,location=yes,directories=yes,status=no,history=yes,menubar=yes,scrollbars=yes,resizable=yes,screenX=1,screenY=1,width=800,height=600");

  testWin.document.writeln("<HTML><HEAD><TITLE>Test EMAILSTRING Wrapping</TITLE></HEAD><BODY>"); 

  testWin.document.writeln("<table><tr><td><FORM NAME='testForm'>");
  testWin.document.writeln("<TEXTAREA NAME='testwidth' ROWS=1 COLS=78></TEXTAREA>78<BR><P><BR>unescaped form value \"mailText\":<BR>");
  
  testWin.document.writeln("<TEXTAREA NAME='textar1' ROWS=20 COLS=90></TEXTAREA><BR><P><BR>EMAILSTRING:<BR>");
  testWin.document.writeln("<TEXTAREA NAME='textar2' ROWS=20 COLS=90></TEXTAREA>");

  testWin.document.writeln("</FORM></td></tr></table>");

  testWin.document.writeln("<HR>PRE:<HR><PRE>" + EMAILSTRING +"</PRE>");

  testWin.document.writeln("<HR>XMP:<HR><XMP>" + EMAILSTRING +"</XMP>");

  testWin.document.writeln("</BODY></HTML>");
  
    testWin.document.close();
   // if (isNetscape) testWin.stop();
    
  testWin.document.testForm.textar1.value = top.genWindowObject.document.mailButtonForm["studentName"].value + "\n" + unescape(top.genWindowObject.document.mailButtonForm["mailText"].value);

  testWin.document.testForm.textar2.value = EMAILSTRING;


}

} //end fn()

function sd(m){DEBUGMODE=m;testEM=m;};

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~  All javascript written by:  Erwin O. Fox Tree, 1999  ~~
//~~  foxtree@tiac.net                   okwa@hotmail.com  ~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~







