/*
 *  File:  mailForm1.js
 *
 *  Note:  This script has been deprecated (use mailForm2.js instead)
 *
 *  Send e-mail to selected addresses
 *
 *  Example 1:  mailForm1Test1.html
 *
 *    <script type="text/javascript"
 *            src="http://www.bgsu.edu/scripts/mailForm1.js">
 *    </script>
 *    <script type="text/javascript">
 *      recipients[1] = 
 *        new Recipient( "Admissions Office", "admissions@bgnet.bgsu.edu" );
 *      recipients[2] = 
 *        new Recipient( "Human Resources", "ohr@bgnet.bgsu.edu" );
 *      recipients[3] = 
 *        new Recipient( "Registration and Records", "registrar@bgnet.bgsu.edu" );
 *      recipients[4] = 
 *        new Recipient( "Tech Support Center", "tsc@bgnet.bgsu.edu" );
 *      recipients[5] = 
 *        new Recipient( "Webmaster", "webmaster@bgnet.bgsu.edu" );
 *    </script>
 *    <!-- Put this link in the <body> of your document -->
 *    <a href="javascript:openMailForm()">Contact us!</a>
 *
 *  Example 2:  mailForm1Test2.html
 *
 *    <script type="text/javascript"
 *            src="http://www.bgsu.edu/scripts/mailForm1.js">
 *    </script>
 *    <script type="text/javascript">
 *      recipients[1] = 
 *        new Recipient( "Webmaster", "webmaster@bgnet.bgsu.edu" );
 *    </script>
 *    <!-- Put this form in the <body> of your document -->
 *    <form>
 *      <input type="button" value="Contact the Webmaster!" onclick="openMailForm()">
 *    </form>
 *
 *  Note:  According to the HTML 4.0 specification, the <form> is not needed,
 *         but a lone <input> tag will not render in Netscape Navigator 4.
 *
 */

// This script uses a PopUpWindow object:
document.writeln( '<script type="text/javascript"' );
document.writeln( '        src="http://www.bgsu.edu/scripts/popUpWindow.js">' );
document.writeln( '</script>' );

// A Window object:
var mailFormWin = null;

// Recipient object constructor:
function Recipient( name, email ) {
  this.name = name;
  this.email = email;
}

// A user-specified array of e-mail recipients:
var recipients = new Array();

// Write the <option> elements into the mail form window:
function writeOptions() {
  var name, email;
  recipients[0] = new Recipient( "Choose a recipient:", "" );
  for ( var i = 0; i < recipients.length; i++ ) {
    name = recipients[i].name;
    email = recipients[i].email;
    mailFormWin.document.write( '              ' );
    mailFormWin.document.write( '<option value="' + email + '">' );
    mailFormWin.document.write( name );
    mailFormWin.document.writeln( '</option>' );
  }
}

// Open the mail form window:
function openMailForm() {
  mailFormWin = new PopUpWindow();
  mailFormWin.setWidth( 465 );
  mailFormWin.setHeight( 375 );
  mailFormWin.setScrollbars( true );
  mailFormWin.setResizable( true );
  mailFormWin.open();
  mailFormWin.document.open();
  mailFormWin.document.writeln( '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' );
  mailFormWin.document.writeln( '' );
  mailFormWin.document.writeln( '<html>' );
  mailFormWin.document.writeln( '' );
  mailFormWin.document.writeln( '  <head>' );
  mailFormWin.document.writeln( '    <title>BGSU Mail Form</title>' );
  mailFormWin.document.writeln( '    <script type="text/javascript"' );
  mailFormWin.document.writeln( '            src="http://www.bgsu.edu/scripts/checkForm.js">' );
  mailFormWin.document.writeln( '    </script>' );
  mailFormWin.document.writeln( '    <script type="text/javascript">' );
  mailFormWin.document.writeln( '      // Override default behavior of checkSelectOne():' );
  mailFormWin.document.writeln( '      var checkSelectOne = checkSelectSpecial;' );
  mailFormWin.document.writeln( '    </script>' );
  mailFormWin.document.writeln( '    <script type="text/javascript">' );
  mailFormWin.document.writeln( '      function initialize() {' );
  mailFormWin.document.writeln( '        self.focus();' );
  mailFormWin.document.writeln( '        var form = self.document.mailForm;' );
  mailFormWin.document.writeln( '        var selectObj = form.mailTo;' );
  mailFormWin.document.writeln( '        // If there is only one recipient, select that recipient:' );
  mailFormWin.document.writeln( '        if ( selectObj.options.length == 2 ) {' );
  mailFormWin.document.writeln( '          selectObj.options[1].selected = true;' );
  mailFormWin.document.writeln( '          form.mailFrom.focus();' );
  mailFormWin.document.writeln( '        } else {' );
  mailFormWin.document.writeln( '          selectObj.options[0].selected = true;' );
  mailFormWin.document.writeln( '          selectObj.focus();' );
  mailFormWin.document.writeln( '        }' );
  mailFormWin.document.writeln( '      }' );
  mailFormWin.document.writeln( '      function closeThisWindow() {' );
  mailFormWin.document.writeln( '        self.close();' );
  mailFormWin.document.writeln( '      }' );
  mailFormWin.document.writeln( '    </script>' );
  mailFormWin.document.writeln( '  </head>' );
  mailFormWin.document.writeln( '  ' );
  mailFormWin.document.writeln( '  <body onload="initialize()">' );
  mailFormWin.document.writeln( '    <form name="mailForm" method="post" onsubmit="return checkForm( this )"' );
  mailFormWin.document.writeln( '          action="http://webapps.bgsu.edu/cgi-bin/bgsuform/submit3">' );
  mailFormWin.document.writeln( '      <table>' );
  mailFormWin.document.writeln( '        <caption><big><strong>BGSU Mail Form</strong></big></caption>' );
  mailFormWin.document.writeln( '        <tr>' );
  mailFormWin.document.writeln( '          <td align="right">To:</td>' );
  mailFormWin.document.writeln( '          <td>' );
  mailFormWin.document.writeln( '            <select name="mailTo" size="1" tabindex="1">' );
  writeOptions();
  mailFormWin.document.writeln( '            </select>' );
  mailFormWin.document.writeln( '          </td>' );
  mailFormWin.document.writeln( '          <td  align="center">' );
  mailFormWin.document.writeln( '            <input type="submit" value="Send">' );
  mailFormWin.document.writeln( '          </td>' );
  mailFormWin.document.writeln( '        </tr>' );
  mailFormWin.document.writeln( '        <tr>' );
  mailFormWin.document.writeln( '          <td align="right">From:</td>' );
  mailFormWin.document.writeln( '          <td><input type="text" name="mailFrom" size="24" tabindex="2"></td>' );
  mailFormWin.document.writeln( '          <td  align="center">' );
  mailFormWin.document.writeln( '            <input type="reset" value="Cancel" onclick="closeThisWindow()">' );
  mailFormWin.document.writeln( '          </td>' );
  mailFormWin.document.writeln( '        </tr>' );
  mailFormWin.document.writeln( '        <tr>' );
  mailFormWin.document.writeln( '          <td align="right">Subject:</td>' );
  mailFormWin.document.writeln( '          <td><input type="text" name="mailSubject" size="24" tabindex="3"></td>' );
  mailFormWin.document.writeln( '          <td align="center">' );
  mailFormWin.document.writeln( '            <select name="group" size="1">' );
  mailFormWin.document.writeln( '              <option selected value="">Identify yourself:</option>' );
  mailFormWin.document.writeln( '              <option>BGSU Student</option>' );
  mailFormWin.document.writeln( '              <option>BGSU Faculty</option>' );
  mailFormWin.document.writeln( '              <option>BGSU Staff</option>' );
  mailFormWin.document.writeln( '              <option>BGSU Alumni</option>' );
  mailFormWin.document.writeln( '              <option>Prospective Student</option>' );
  mailFormWin.document.writeln( '              <option>Parent</option>' );
  mailFormWin.document.writeln( '              <option>Guest</option>' );
  mailFormWin.document.writeln( '            </select>' );
  mailFormWin.document.writeln( '          </td>' );
  mailFormWin.document.writeln( '        </tr>' );
  mailFormWin.document.writeln( '        <tr>' );
  mailFormWin.document.writeln( '          <td align="center" colspan="3">' );
  mailFormWin.document.writeln( '            <textarea rows="10" cols="50" name="message" tabindex="4"></textarea>' );
  mailFormWin.document.writeln( '          </td>' );
  mailFormWin.document.writeln( '        </tr>' );
  mailFormWin.document.writeln( '        <tr>' );
  mailFormWin.document.writeln( '          <td align="center" colspan="3">' );
  mailFormWin.document.writeln( '            <small>' );
  mailFormWin.document.writeln( '              Bowling Green State University,' );
  mailFormWin.document.writeln( '              Bowling Green, OH 43403 USA<br>' );
  mailFormWin.document.writeln( '              Switchboard: 1-419-372-2531' );
  mailFormWin.document.writeln( '            </small>' );
  mailFormWin.document.writeln( '          </td>' );
  mailFormWin.document.writeln( '        </tr>' );
  mailFormWin.document.writeln( '      </table>' );
  mailFormWin.document.writeln( '    </form>' );
  mailFormWin.document.writeln( '  </body>' );
  mailFormWin.document.writeln( '  ' );
  mailFormWin.document.writeln( '</html>' );
  mailFormWin.document.close();
}

// Close the mail form window:
function closeMailForm() {
  mailFormWin.close();
}