//-----------------------------------------------------------
// This file contains functions used by the Feldman Student OLC
// journal pages allowing print or email
//-----------------------------------------------------------

function CI_printJournal() {

//Collect all the forms and text area values 
   var writeJournal = "";
   if (JourTopic != "") writeJournal += JourTopic;
   var JourText = "";
   for (i = 1; i <= maxQues; i++) {
         writeJournal += eval("Jour" + i) + "<BR>";
         jourText = eval('document.forms[' + i + '].textarea' + i + '.value');// + '<BR>';
      	 writeJournal += '<pre>' + jourText + '</pre><br>';
    }

    //For chapter 8 with 2 sections (A and B)
    //numbering starts over at 1 in section b

    if (typeof JourTopic2 == "undefined") {
    } else {
        var JourText2 = "";
        writeJournal += "<br>&nbsp;<br>" + JourTopic2
        for(j = i; j <=maxQues2 + maxQues; j++) {
               writeJournal += eval("Jour2_" + j) + "<BR>";
               jourText2 = eval('document.forms[' + j + '].textarea' + j + '.value');// + '<BR>';
               writeJournal += '<pre>' + jourText2 + '</pre><br>';
         }
     }       
     


       // Open a new browser window and print a title
	   var printWin = window.open('','JournalPrintWindow', 'resizable,scrollbars,width=591,height=400');
       printWin.document.write('<center><h2>Journal Reflections</h2></center><p>&nbsp;</p>');
       // Print our writeJournal variable
	   printWin.document.write(writeJournal);

        printWin.document.close();
        printWin.print();
        printWin.close();

}

//-----------------------------------------------------------
// CI_emailJournal - Allows user to email current Journal
//                 - entries with question/promt text
//
//   This function opens a new browser window and writes
//   the content of all of the page DIV's (questions and
//   textarea answers to the new window. The user is able
//   to select File then Send from the browser menu
//   and email the contents of the journal.
//-----------------------------------------------------------
function CI_emailJournal() {

   //Collect all the forms and text area values 
   var writeJournal = "";
   if (JourTopic != "") writeJournal += JourTopic;
   var JourText = "";
   for (i = 1; i <= maxQues; i++) {
         writeJournal += eval("Jour" + i) + "<BR>";
         JourText = eval('document.forms[' + i + '].textarea' + i + '.value');// + '<BR>';
      	 writeJournal += '<pre>' + JourText + '</pre><br>';
    }

    //For chapter 8 with 2 sections (A and B)
    //numbering starts over at 1 in section b

    if (typeof JourTopic2 == "undefined") {
    } else {
       writeJournal += "<br>&nbsp;<br>" + JourTopic2
       var JourText2 = "";
  	   for(j = i; j <=maxQues2 + maxQues; j++) {
           writeJournal += eval("Jour2_" + j) + "<BR>";
           jourText2 = eval('document.forms[' + j + '].textarea' + j + '.value');// + '<BR>';
           writeJournal += '<pre>' + jourText2 + '</pre><br>';
        }       
     }
	// Open a new browser window and print a title
	//	var emailWin = window.open('','JournalEmailWindow', 'resizable,scrollbars,width=591,height=400');
	var emailWin = window.open('','JournalemailWindow', 'menubar,resizable,,scrollbars,width=591,height=400');

    // Print our writeJournal variable
    emailWin.document.write('<html><head><title>Journal Reflections</title></head><font size="-1" color="red">To send this document as an email: <ol type="1."><li>Select EDIT followed by SELECT ALL from the menu bar above.<li>Select EDIT from the menu bar again followed by COPY.<li>Use your email program to open a new email message.<li>Paste the copied text into the email message.<li>Fill in the "To:" and "Subject:" fields and select SEND.</ol></font><center><h2>Journal Reflections</h2></center><p>&nbsp;</p><body>');
	emailWin.document.write(writeJournal);
    emailWin.document.close();
}