/*
 *  File:  quicksearch.js
 *
 *  Note:  This script has been deprecated (use quickSearch.js instead)
 *
 *  Insert a BGSU QuickSearch form into the current document
 *
 *  Usage:
 *
 *    <script type="text/javascript"
 *            src="http://www.bgsu.edu/scripts/quicksearch.js">
 *    </script>
 *
 *  Variables:
 *
 *    textLength      Length of textfield
 *    buttonLabel     Button label
 *    buttonURL       URL of custom button
 *    searchName      Name of special search option
 *    searchURL       URL of special search option
 *
 *    Note:  buttonLabel and buttonURL are mutually exclusive.
 *
 *  Example 1:  quicksearchTest1.html
 *
 *    <script type="text/javascript"
 *            src="http://www.bgsu.edu/scripts/quicksearch.js">
 *    </script>
 *
 *  Example 2:  quicksearchTest2.html
 *
 *    <script type="text/javascript">
 *      var textLength = 12;
 *      var buttonLabel = "Go!";
 *    </script>
 *    <script type="text/javascript"
 *            src="http://www.bgsu.edu/scripts/quicksearch.js">
 *    </script>
 *
 *  Example 3:  quicksearchTest3.html
 *
 *    <script type="text/javascript">
 *      var searchName = "Firelands";
 *      var searchURL = "http://www.firelands.bgsu.edu/";
 *    </script>
 *    <script type="text/javascript"
 *            src="http://www.bgsu.edu/scripts/quicksearch.js">
 *    </script>
 *
 *  Example 4:  quicksearchTest4.html
 *
 *    <script type="text/javascript">
 *      var buttonURL = "http://www.bgsu.edu/scripts/quickSearchUp.gif";
 *    </script>
 *    <script type="text/javascript"
 *            src="http://www.bgsu.edu/scripts/quicksearch.js">
 *    </script>
 *
 *  Insert one of these scripts into the <body> of your document.
 *
 */

// Optional user-defined variables:
var textLength, buttonLabel, buttonURL, searchName, searchURL;

// Default values of user-defined variables:
var _textLength = 15;
var _buttonLabel = "Search";

// Write the search form into the current document:
document.writeln( '' );
document.writeln( '<form name="search" onsubmit="return checkForm()"' );
document.writeln( '      method="get" action="http://search.bgsu.edu/query.html">' );
// This text field must be the *first* field in the form:
if ( textLength == null ) textLength = _textLength;  // default length of textfield
document.writeln( '  <input type="text" size="' + textLength + '" maxlength="2033">' );
if ( buttonURL == null ) {
  if ( buttonLabel == null ) buttonLabel = _buttonLabel;  // default button label
  document.writeln( '  <input type="submit" value="' + buttonLabel + '">' );
} else {
  document.writeln( '  <input type="image" src="' + buttonURL + '" alt="Search">' );
}
document.writeln( '  <input type="hidden" name="qt" value="">' );
document.writeln( '  <select name="rq" size="1">' );
// The special search option must be the *first* option listed, if at all:
if ( searchName != null ) {
  document.writeln( '    <option value="0">' + searchName + '</option>' );
}
document.writeln( '    <option value="0">BGSU Web</option>' );
document.writeln( '    <option value="2">The Internet</option>' );
document.writeln( '  </select>' );
document.writeln( '  <input type="hidden" name="col" value="bigweb">' );
document.writeln( '  <input type="hidden" name="ht" value="0">' );
document.writeln( '  <input type="hidden" name="qp" value="">' );
document.writeln( '  <input type="hidden" name="qs" value="">' );
document.writeln( '  <input type="hidden" name="qc" value="">' );
document.writeln( '  <input type="hidden" name="pw" value="100%">' );
document.writeln( '  <input type="hidden" name="ws" value="0">' );
document.writeln( '  <input type="hidden" name="la" value="">' );
document.writeln( '  <input type="hidden" name="qm" value="0">' );
document.writeln( '  <input type="hidden" name="st" value="1">' );
document.writeln( '  <input type="hidden" name="nh" value="10">' );
document.writeln( '  <input type="hidden" name="lk" value="1">' );
document.writeln( '  <input type="hidden" name="rf" value="0">' );
document.writeln( '  <input type="hidden" name="oq" value="">' );
document.writeln( '  <input type="hidden" name="si" value="1">' );
document.writeln( '</form>' );

// Check the form before submitting:
function checkForm() {
  // Store the search string in a hidden field called 'qt':
  document.search.qt.value = document.search.elements[0].value;
  // Process special search option, if it exists:
  if ( searchName != null && document.search.rq.selectedIndex == 0 ) {
    if ( searchURL != null ) {
      document.search.qt.value += " AND url:" + searchURL;
    }
  }
  return true;
}