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...");
   var confirmMsg = "The e-mail address \"" +destinationAddress+ "\" does not appear to be valid. It should be of the form:\n'name@somewhere.domain'\n(Your e-mail 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 e-mail... 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\" METHOD=\"POST\" ACTION=\"http://www.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>");




EMAILSTRINGtempArr = (escape(EMAILSTRING)).split("%0D");
EMAILSTRING = EMAILSTRINGtempArr.join("%0A");


writeln("<TR><td><INPUT TYPE=\"HIDDEN\" NAME=\"mailText\" VALUE=\"" + 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 NOWRAP><tt>Your name:</tt> </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 NOWRAP><tt>Your e-mail address:</tt> </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 NOWRAP><tt>E-mail to:</tt> </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 e-mail";

invalidMsg = (!verifyAddress(newCookieVal))?  "\n \n(This does not appear to be a properly-formatted e-mail 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" &&  typeof top.genWindowObject.document.mailButtonForm != '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=0;
function testEmailText(inputString)
{
if (testEM==1) {
 testWin = window.open('','testWINDOW');
 with (testWin.document) {
 open("text/html")
  writeln("<HTML><HEAD><TITLE>Test EMAILSTRING Wrapping</TITLE></HEAD><BODY>"); 
  writeln("<table><tr><td><FORM NAME='testForm'>");
  writeln("<TEXTAREA NAME='testwidth' ROWS=1 COLS=72></TEXTAREA>72<BR><P><BR>unescaped form value \"mailText\":<BR>");  
  writeln("<TEXTAREA NAME='textar1' ROWS=20 COLS=90></TEXTAREA><BR><P><BR>mailText.value:(escaped)<BR>");
  writeln("<TEXTAREA NAME='textar2' ROWS=10 COLS=90></TEXTAREA>");
  writeln("</FORM></td></tr></table>");
  writeln("<HR>PRE:<HR><PRE>" + EMAILSTRING +"</PRE>");
  writeln("<HR>XMP:<HR><XMP>" + EMAILSTRING +"</XMP>");
  writeln("</BODY></HTML>");
  close();
  testForm.textar1.value = top.genWindowObject.document.mailButtonForm["studentName"].value + "\n" + unescape(top.genWindowObject.document.mailButtonForm["mailText"].value);
  testForm.textar2.value = top.genWindowObject.document.mailButtonForm["mailText"].value;
 };
};
} //end fn()

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

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








