/*
Various javascript code for extra functionality.  Every page MUST
still work with javascript disabled. --ee (hahah  --dlb)
*/

// disabled logins message
var disabled = "Logins are currently disabled while the system undergoes ";
disabled = disabled + " maintenance.<br /> Please try again later.";

var local_base;

var queryArgs = new Array();

queryArgs = location.search.substring(1).split("&");

local_base = parseBase (queryArgs);

function debug (str)
{
	var DEBUG = 0;  // enable this to see debug messages
	if (DEBUG) { alert("DEBUG\n" + str); }
}

// call the init function when the document first loads
addEvent (window, "load", init);

// Stuff to do when page first loads
function init ()
{

    if (! document.getElementsByName) {
        //debug ('getElementsByName not found');
        return;
    }

	// Set the example text on search forms
	var forms = document.getElementsByTagName ('form');
	for (var i = 0; i < forms.length; ++i)
	{
		var form = forms[i];
		if (form.find_code) {
			//debug ('form: ' + i);
			set_example_text (form.find_code);
		}

		if (form.scan_code) {
			set_example_text (form.scan_code);
		}

	}

	//debug ('init() local_base: ' + local_base);
	setDocumentID ();

}


// Set the document.body.id CSS value to match the local_base
// removes the need for all the special files, except the forms
function setDocumentID ()
{

	// If you still don't know local_base get it from cookie
	if (! local_base || local_base == "false")
	{
		//debug ("setDocumentID() document cookie: " + document.cookie);
		local_base = parseBase (document.cookie.split("; "));
	}

	//debug ('setDocumentID() local_base: ' + local_base);

	// Set the cookie if we know the local base
	if (local_base) document.cookie = "local_base = " + local_base + "; path = /";

	if (local_base == "ucd01pub") document.body.id = "ucd01-search";
	if (local_base == "u-ucd30") document.body.id = "reserve-search";
	if (local_base == "journal") document.body.id = "journal-search";
	if (local_base == "ejournal") document.body.id = "ejournal-search";
	if (local_base == "diss") document.body.id = "more-search";
	if (local_base == "new") document.body.id = "more-search";
	if (local_base == "more") document.body.id = "more-search";
	if (local_base == "harrison") document.body.id = "speccol-search";
	if (local_base == "east") document.body.id = "speccol-search";
	if (local_base == "speccol") document.body.id = "speccol-search";

}


// expects an array of name = value pairs.
function parseBase (inArray)
{
	var itemnum = 0;

	var curItem = new Array();

	while (itemnum < inArray.length)
	{
		//debug ("current row: " + inArray[itemnum]);

		curItem = inArray[itemnum].split("=");

		//debug ("current item = [" + curItem[0] + "]");

		if (curItem[0] == "local_base")
		{
			//debug ("found local_base: " + curItem[1])
			return curItem[1];
		}

		itemnum++
	}

	return false;

}
	

// Set the default field values on an advanced search form
function set_fields (form)
{
	return; // disabled for now, we need 3 copies of keywords

	// Selected field values
	// numbers are positions of options in <select name=find_code>
	// (see find-code-include)
    var field_defaults = new Array (1, 7, 0);

	for (var i = 0; i < form.find_code.length; i++)
	{
		var field = form.find_code [i];
		//debug ("field = " + field);
		var value = field_defaults [i];
        field.selectedIndex = value;
	}
	return;
}


// Set refine search field default
function refine_refine (form)
{

	var field = form.request.value;

	if (field == "") {

		form.request_op[2].checked = true;
		form.request.value = "no_word_supplied";

	}

	return;
}


// fast reset that doesn't require hitting the server
// provide another method for non-javascript browsers
function reset_form (link)
{
	//debug ("anchor = " + link);
	//document.write (show_props (link));
	// find this links parent form element
	var parent = link.parentNode;
	while (parent && parent.tagName != 'FORM') {
		parent = parent.parentNode;
	}
	var form = parent;
	if (! form) {
		//debug ("form = " + parent);
		return false;
	}
	form.reset();
	// clear the search terms manually, advanced search embeds them in form

	for (var x in form)
	{
		if (x == 'request' || x == 'y') {
			var inputs = form [x];

			form[x].value = '';

			//for (var y in inputs)
			//	inputs[y].value = '';
		}
	}
	//if (form.name == 'form-adv-search') {
	//	set_fields (form);
	//}
	// Cancel the pending link submit that triggered this function
	return false;
}

// examples for basic & browse searches
// array values set at end of file
var examples = new Array ();	

// Change the example text when the search field changes
function set_example_text (selectBox)
{
    if (! selectBox.form) {
        //debug ('selectBox.form not found');
        return;
    }

	var cells = selectBox.form.getElementsByTagName ('td');
	var search_examples = null;
	for (var i in cells) {
		var td = cells[i];
		//debug ("td = " + td + ":" + td.id);
		if (td.id == 'search-examples') {
			search_examples = td;
		}
	}

	if (! search_examples) {
		//debug ("td div=search-examples not found");
		return;
	}


	// Get local base because some examples are different.
	var test = selectBox.form.getElementsByTagName ('input');
	for (var i in test) {
		var lb = test[i];
		if (lb.name == "local_base") localbase = lb.value;
		//debug ("lb.name = " + lb + ":" + lb.name);
		//debug ("lb.value = " + lb + ":" + lb.value);
	}

	var code = selectBox.value;

	var newcode = code.split("_");
	if (newcode[1]) {
		code = newcode[1]
	}


	var lb_code = localbase + "_" + code;
	//debug ("code = " + code);
	//debug ("lbcode = " + lb_code);
	//debug ("msg_type = " + msg_type);
	//debug ("msg_code = " + msg_code);

	example_text = examples[lb_code];

	if (! example_text) {
        example_text = examples[code];
	}

	if (! example_text) {
		example_text = examples['default'];
	}


	search_examples.innerHTML = example_text;
	//search_examples.innerHTML = "foo bar"; 
	//document.write (show_props (search_examples));
	//document.write (show_props (selectBox.form));
}


// Turn an aleph image button into a button-like text link
// aleph_str - the aleph html fragment, usually from a code like $0300
// text - the label to appear on the button
function make_button (aleph_str, text)
{
	// debug ("make_button() str: " + aleph_str);

	// deactivate when image ends in dim.gif
	/* not needed, use href to detect instead
	var active = (aleph_str.split('-').pop().split('.').shift() !== 'dim');
	if (! active) {
		classa += ' disabled';
	}
	*/

	// extract link target from passed string, if present
	var re = new RegExp ('href=[^ \t\n>]*', 'i');
	var hrefs = aleph_str.match (re);
	var target = (hrefs) ? hrefs.shift() : '';

	var classa = 'button';
	// disable button if no link found
	if (target.length == 0) { classa += ' disabled'; }

	var button = '<a class="' + classa + '" ' + target + '>' + text + '</a>';
	//debug ("button: " + button);
	return button;
}


// cross-browser event handling for IE5+, NS6 and Mozilla
// By Scott Andrew
function addEvent(elm, evType, fn, useCapture)
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
	return true;
}

// Return all the property name-value pairs of an object as a ul
// for debugging
function show_props (obj)
{
    var props = new Array();
    for (x in obj)
    {
        //ret += "<li>" + x + "</li>";
        //ret += "<li>" + x + ": " + obj[x] + "</li>";
        //props.push ("<li>" + x + "</li>");
        props.push ("<li>" + x + ": " + obj[x] + "</li>");
    }
    props.sort();
    ret = "<ul>";
    ret += props.join("\n");
    ret += "</ul>";
    return ret;
}

function dump_form (obj)
{

	ret = "<table border=1><tr><th>element</th><th>name</th><th>type</th><th>value</th>\n"

	for (var i=0;i<obj.length;i++)
	{
		current = obj.elements[i];
		ret += "<tr><td>" + i + "</td>\n";
		ret += '<td>' + current.name + "</td>\n";
		ret += '<td>' + current.type + "</td>\n";
		ret += '<td>' + current.value + '</tr>\n';
	}

	ret += "</table>"

	//document.write(ret);
	alert(ret);

}	

// Text examples for the search pages

examples ['AUT'] =
"himes chester (last name first) <br />\
du bois w. e. b. <br />\
hawking s";

examples ['BLA'] = "";

examples ['CFT'] =
"language international conference <br />\
national diary housing conference <br />\
siggraph";

examples ['journal_CFT'] =
"conference on asian affairs <br />\
national american veterinary <br />\
siggraph";

examples ['ejournal_CFT'] =
"international congress on child <br />\
abuse & neglect <br />\
sixteenth century studies <br />\
oopsla";

examples ['COD'] =
"YEHED4 <br />\
DAATES";

examples ['journal_COD'] =
"YOMJA9 <br />\
DAATES";

examples ['ejournal_COD'] =
"YOMJA9 <br />\
DAATES";

examples ['CJK'] =
"&#39640;&#34892;&#20581; <br />\
&#33274;&#28771;&#27511;&#21490; <br />\
&#26085;&#26412;&#12398;&#12356;&#12369;&#12427; <br />\
&#54620;&#44397;&#48337;&#54633; <br />\
(To search in Chinese(C), Japanese (J), or Korean (K), please switch on the \
IME Asia Languages Application for word processing.)";

examples ['journal_CJK'] =
"&#20826;&#21490;&#30740;&#31350;&#19982;&#25934;&#23398; <br />\
&#38867;&#22283;&#20986;&#29256;&#24180;&#37969; <br />\
&#26085;&#26412;&#35486;&#12398;&#30740;&#31350; <br />\
(To search in Chinese(C), Japanese (J), or Korean (K), please switch on the \
IME Asia Languages Application for word processing.)";

examples ['ejournal_CJK'] =
"&#20826;&#21490;&#30740;&#31350;&#19982;&#25934;&#23398; <br />\
&#26085;&#26412;&#24540;&#29992;&#21205;&#29289;&#26118;&#34411;&#23398;&#20250;&#35468; <br />\
(To search in Chinese(C), Japanese (J), or Korean (K), please switch on the \
IME Asia Languages Application for word processing.)";

examples ['CAU'] =
"himes chester (last name first) <br />\
geological survey of india";

examples ['journal_CAU'] =
"watkins, wayne b (last name first) <br />\
jackson <br />\
council on foreign relations";

examples ['ejournal_CAU'] =
"smith syndey (last name first) <br />\
opitz <br />\
british institute";

examples ['CRA'] =
"walter mosley (name in any order) <br />\
yoshino hiroko <br />\
ecological society america";

examples ['CRP'] =
"American Chemical Society <br />\
Geological Survey of India <br />\
Conference on African Linguistics";

examples ['DOT'] =
"DOC V1.2/10 <br />\
DOC-CA T950 .H4 <br />\
DOC PREX 1.10";

examples ['journal_DOT'] =
"doc-ca T988.F74 <br />\
DOC E 1.1/2 <br />\
DOC MS";

examples ['ejournal_DOT'] =
"doc-ca T1050.r31 <br />\
DOC NAS 1.2/2x <br />\
doc d";

examples ['GEO'] =
"4363 y6 <br />\
3200";

examples ['GPO'] =
"1052-B <br />\
358-D";

examples ['journal_GPO'] =
"1059-A-01 <br />\
24-d <br />\
529";

examples ['ejournal_GPO'] =
"1059-A-01 <br />\
246-e <br />\
559-a";

examples ['ISB'] =
"1852427485 (hyphens optional)";

examples ['ISM'] =
"M001084512";

examples ['ISS'] =
"0000-0027 (hyphen optional)";

examples ['journal_ISS'] =
"0376-8716 (hyphen optional)";

examples ['ejournal_ISS'] =
"0376-8716 (hyphen optional)";

examples ['LCC'] =
"90050252 (do not include hyphen)";

examples ['journal_LCC'] =
"75647592 (do not include hyphen)";

examples ['ejournal_LCC'] =
"75647592 (do not include hyphen)";

examples ['LLA'] =
"ct275.a186 a3 1973 (complete or partial) <br />\
we755 m25 1997 <br />\
tj233";

examples ['LLT'] =
"ct275.a186 a3 1973 (complete or partial) <br />\
we755 m25 1997 <br />\
tj233";

examples ['journal_LLT'] =
"pn1993.f438 (complete or partial) <br />\
d410.F6 <br />\
q3";

examples ['ejournal_LLT'] =
"pn1993.f438 (complete or partial) <br />\
d410.F6 <br />\
q3";

examples ['OCN'] =
"Women's Hist. P-140 16:8 <br />\
CAL 1:1 <br />\
AR-010";

examples ['OCT'] =
"Women's Hist. P-140 16:8 <br />\
CAL 1:1 <br />\
AR-010";

examples ['PER'] =
"science <br />\
journal of adolescence <br />\
(try without or with initial articles: a, the, le, los, das, etc.)";

examples ['journal_PER'] =
"science <br />\
journal of adolescence <br />\
(try without or with initial articles: a, the, le, los, das, etc.)";

examples ['ejournal_PER'] =
"science <br />\
journal of adolescence <br />\
(try without or with initial articles: a, the, le, los, das, etc.)";

examples ['RPT'] =
"NAVMC 2537 <br />\
YCR-CR-02-1 <br />\
SAND 2000-0234";

examples ['journal_RPT'] =
"SeHy 1-3 <br />\
CG-129 <br />\
NUREG-0386";

examples ['ejournal_RPT'] =
"UCRL <br />\
YCR-NR-98-2 <br />\
BTS";

examples ['SCL'] =
"50000 (for 1:50,000 scale) <br />\
225000 (for 1:225,000 scale)";

examples ['SRS'] =
"acta horticulturae <br />\
lecture notes in mathematics <br />\
geology of north america <br />\
ACS symposium series";

examples ['journal_SRS'] =
"ventas y uso hechos fiscales <br />\
lecture notes in mathematics <br />\
oecd";

examples ['ejournal_SRS'] =
"current population reports <br />\
surveys of science <br />\
oecd";

examples ['SUB'] =
"nematoda classification <br />\
landscape architecture social aspects <br />\
geriatric assessment";

examples ['journal_SUB'] =
"substance related disorders <br />\
landscape <br />\
architecture <br />\
geriatric";

examples ['ejournal_SUB'] =
"substance related disorders <br />\
landscape <br />\
architecture <br />\
geriatric";

examples ['SUD'] =
"DOC V1.1/3:102-2 <br />\
DOC-CA T950 .H4 <br />\
DOC prex 1.10";

examples ['SUT'] =
"DOC V1.1/3:102-2 <br />\
DOC-CA T950 .H4 <br />\
DOC prex 1.10";

examples ['TIT'] =
"grapes of wrath <br />\
leiden des jungen werthers <br />\
(try without or with initial articles: a, the, le, los, das, etc.)";

examples ['TTL'] =
"fear and loathing <br />\
puddnhead wilson <br />\
(try without or with initial articles: a, the, le, los, das, etc.)";

examples ['journal_TTL'] =
"federal acquisition <br />\
trabajos de prehistoria <br />\
(try without or with initial articles: a, the, le, los, das, etc.)";

examples ['ejournal_TTL'] =
"federal acquisition <br />\
trabajos de prehistoria <br />\
(try without or with initial articles: a, the, le, los, das, etc.)";

examples ['WCN'] =
"Enter a course code and number <br />\
PHY009 <br />\
CHE108 <br />\
MIC050";

examples ['WIS'] =
"Applegate<br />\
Smith";
examples ['WMN'] =
"66644 <br />\
A00520PX <br />\
RHACD39";

examples ['WPC'] =
'walter mosley (name in any order) <br />\
"virno paolo" (last name first) <br />\
stumpf conn (two last names) <br />\
math? society america';

examples ['new_WPC'] =
"walter mosley (name in any order) <br />\
sokolov <br />\
math? society";

examples ['journal_WPC'] =
'ecological society america <br />\
"theoretical physics" (exact order) <br />\
biochem? molecular society';

examples ['ejournal_WPC'] =
'ecological society america <br />\
"theoretical physics" (exact order) <br />\
biochem? molecular society';

examples ['diss_WPC'] =
"Steven Krebs <br />\
Krebs, Stephen";

examples ['WPE'] =
'journal american folklore <br />\
"california history" <br />\
physiol? europe?';

examples ['new_WPE'] =
"journal american <br />\
histor?";

examples ['journal_WPE'] =
'journal american folklore <br />\
"california history" <br />\
physiol? europe?';

examples ['ejournal_WPE'] =
'journal american folklore <br />\
"california history" <br />\
physiol? europe?';

examples ['WRD'] =
'publications linguistics pomo <br />\
"trojan war" <br />\
(wom!n or female) and sport? <em>[sport, sports, sporting]</em>';

examples ['new_WRD'] =
'publications linguistics <br />\
"trojan war" <br />\
(wom!n or female) and sport? <em>[sport, sports, sporting]</em>';

examples ['journal_WRD'] =
'canadian biochemistry <br />\
"math? society" and applied <br />\
(wom!n or female) and sport? <em>[sport, sports, sporting]</em>';

examples ['ejournal_WRD'] =
'canadian biochemistry <br />\
"math? society" and applied <br />\
(wom!n or female) and sport? <em>[sport, sports, sporting]</em>';

examples ['diss_WRD'] =
'vitis rootstocks <br />\
"grape rootstocks" <br />\
(vitis or grape?) and rootstock?';

examples ['east_WRD'] =
'Riesen <br />\
roads animals <br />\
"Lassen lodge" <br />\
cloth? <em>[cloth, clothes, clothing]</em>';

examples ['WSU'] =
'athens politics government <br />\
"religious thought 20th century" <br />\
polymer? chemistry';

examples ['journal_WSU'] =
'macromolecules polymerization <br />\
"environmental law united states" <br />\
dog? <em>[dog, dogs]</em>';

examples ['ejournal_WSU'] =
'macromolecules polymerization <br />\
"environmental law united states" <br />\
dog? <em>[dog, dogs]</em>';

examples ['diss_WSU'] =
'Ecology <br />\
Plant Pathology';

examples ['east_WSU'] =
'Alturas <br />\
"deer hunting" <br />\
mountain?';

examples ['WTI'] =
'grapes wrath <br />\
"third factory" <br />\
arabian day? night? <em>[night, nights]</em>';

examples ['diss_WTI'] =
'grape disease <br />\
"Pierce\'s disease" <br />\
(virus or disease) and grape?';

examples ['east_WTI'] =
'4th July <br />\
"Lassen lodge" <br />\
play? (play, playing)';

examples ['new_WTI'] =
'economics world <br />\
"molecular biology" <br />\
africa? history';

examples ['HSU'] =
'army <br />\
"Custer fight" <br />\
"Western Art and Artists"';

examples ['WHS'] =
'army <br />\
"Custer fight" <br />\
"Western Art and Artists"';

examples ['default'] =
'publications linguistics pomo <br />\
"trojan war" <br />\
(wom!n or female) and sport? <em>[sport, sports, sporting]</em>';

// this is used by the "- - -" select options in the list
// they are disabled so FF can't select them, but IE can
examples ['disabled'] = "<br />";

// these ones seem to be duplicates
examples ['020'] = examples ['ISB'];
examples ['SSN'] = examples ['ISS'];
examples ['journal_SSN'] = examples ['journal_ISS'];
examples ['ejournal_SSN'] = examples ['ejournal_ISS'];
examples ['024'] = examples ['ISM'];
examples ['010'] = examples ['LCC'];
examples ['journal_010'] = examples ['journal_LCC'];
examples ['ejournal_010'] = examples ['ejournal_LCC'];



function holdingsDisplay(holdings) {
	var holdArray = holdings.split('</A><br>')
	var count, parsed, lib, owned, out
	for (count = 0; count < (holdArray.length) - 1; count++) {

		parsed = holdArray[count].substring(holdArray[count].indexOf('('), holdArray[count].indexOf(')'))
		lib = holdArray[count].substring(0,holdArray[count].indexOf('('))

		if (lib == "") lib = holdArray[count]
			document.write(lib + '</a><BR>')

		owned = parsed.substring(1, 7)
		out = parsed.substring(9, 15)

		if (owned != "") {
			document.write('Owned: ' + owned + '<BR>')
			document.write('Out: ' + out + '<BR>')
		}
 			// else document.write('<BR>')
	
		document.write('&nbsp;')
		if (count != holdArray.length - 1)
			document.write('<br>')
	}

}


function getRange(start_time_units, end_time_units, unit_of_time) { 
   var cDate = new Date(); 
   monthDays = new Array(); 
   monthDays[1] = 31; 
   monthDays[2] = 28; 
   monthDays[3] = 31; 
   monthDays[4] = 30; 
   monthDays[5] = 31; 
   monthDays[6] = 30; 
   monthDays[7] = 31; 
   monthDays[8] = 31; 
   monthDays[9] = 30; 
   monthDays[10] = 31; 
   monthDays[11] = 30; 
   monthDays[12] = 31; 
   var x = cDate.getYear(); 
   // to correct for differences in browsers 
   var cYear = x % 100; 
   cYear += (cYear < 38) ? 2000 : 1900; 
   // the current date 
   var cMonth = cDate.getMonth(); 
   cMonth = cMonth + 1; 
   var cDay = cDate.getDate(); 
   // starting point for end date 
   var eDay = cDay; 
   var eMonth = cMonth; 
   var eYear = cYear; 
   // starting point for early date 
   var sDay = cDay; 
   var sMonth = cMonth; 
   var sYear = cYear; 
// if range is used for year(s) 
   if (unit_of_time == "y") { 
      sYear = sYear - start_time_units; 
      // do classic leap year calculation 
      if (((sYear % 4 == 0) && (sYear % 100 != 0)) || (sYear % 400 == 0)) { 
         monthDays[2] = 29; 
      } else { 
 monthDays[2] = 28; 
      } 
      if (monthDays[sMonth] < sDay) { 
         sDay = monthDays[sMonth] 
      } 
      eYear = eYear - end_time_units; 
      // do classic leap year calculation 
      if (((eYear % 4 == 0) && (eYear % 100 != 0)) || (eYear % 400 == 0)) { 
         monthDays[2] = 29; 
      } else { 
         monthDays[2] = 28; 
      } 
      if (monthDays[eMonth] < eDay) { 
         eDay = monthDays[eMonth] 
      } 
   } 
// if range is used for month(s) 
   if (unit_of_time == "m") { 
      sMonth = sMonth - start_time_units; 
      while (sMonth <= 0) { 
        sMonth += 12; 
        sYear = sYear - 1; 
      } 
      // do classic leap year calculation 
      if (((sYear % 4 == 0) && (sYear % 100 != 0)) || (sYear % 400 == 0)) { 
         monthDays[2] = 29; 
      } else { 
         monthDays[2] = 28; 
      } 
      if (monthDays[sMonth] < sDay) { 
         sDay = monthDays[sMonth] 
      } 
      eMonth = eMonth - end_time_units; 
      while (eMonth <= 0) { 
        eMonth += 12; 
        eYear = eYear - 1; 
      } 
      // do classic leap year calculation 
 if (((eYear % 4 == 0) && (eYear % 100 != 0)) || (eYear % 400 == 0)) { 
         monthDays[2] = 29; 
      } else { 
         monthDays[2] = 28; 
      } 
      if (monthDays[eMonth] < eDay) { 
         eDay = monthDays[eMonth] 
      } 
   } 
// if range is used for week(s) or day(s) 
   if ((unit_of_time == "w") || (unit_of_time == "d")) { 
      if (unit_of_time == "w") { 
         sDay = sDay - (start_time_units*7); 
      } else { 
         sDay = sDay - (start_time_units); 
      } 
      while (sDay <= 0) { 
        sMonth = sMonth -1; 
        if (sMonth == 0) { 
           sMonth += 12; 
           sYear = sYear - 1; 
        } 
        // do classic leap year calculation 
        if (((sYear % 4 == 0) && (sYear % 100 != 0)) || (sYear % 400 == 0)) { 
           monthDays[2] = 29; 
        } else { 
           monthDays[2] = 28; 
        } 
        sDay += monthDays[sMonth]; 
      } 
      if (unit_of_time == "w") { 
         eDay = eDay - (end_time_units*7); 
      } else { 
         eDay = eDay - (end_time_units); 
      } 
      while (eDay <= 0) { 
        eMonth = eMonth -1; 
        if (eMonth == 0) { 
 eMonth += 12; 
           eYear = eYear - 1; 
        } 
        // do classic leap year calculation 
        if (((eYear % 4 == 0) && (eYear % 100 != 0)) || (eYear % 400 == 0)) { 
           monthDays[2] = 29; 
        } else { 
           monthDays[2] = 28; 
        } 
        eDay += monthDays[eMonth]; 
      } 
   } 
   // add zeros before single digit numbers to match 'new' data 
   if (eMonth == 1 || eMonth == 2 || eMonth == 3 || eMonth == 4 || eMonth == 5 || eMonth == 6 || eMonth == 7 || eMonth == 8 || eMonth == 9) { 
        eMonth = '0' + eMonth; 
   } 
   if (sMonth == 1 || sMonth == 2 || sMonth == 3 || sMonth == 4 || sMonth == 5 || sMonth == 6 || sMonth == 7 || sMonth == 8 || sMonth == 9) { 

        sMonth = '0' + sMonth; 
   } 
   if (eDay == 1 || eDay == 2 || eDay == 3 || eDay == 4 || eDay == 5 || eDay == 6 || eDay == 7 || eDay == 8 || eDay 
== 9) { 
        eDay = '0' + eDay; 
   } 
   if (sDay == 1 || sDay == 2 || sDay == 3 || sDay == 4 || sDay == 5 || sDay == 6 || sDay == 7 || sDay == 8 || sDay 
== 9) { 
        sDay = '0' + sDay; 
   } 
   // create the range string 
   // var range = eYear.toString() + eMonth.toString() + eDay.toString() + "->"; 
   // range += cYear.toString() + cMonth.toString() + cDay.toString(); 
   var range = sYear.toString() + sMonth.toString() + sDay.toString() + "->"; 
   range += eYear.toString() + eMonth.toString() + eDay.toString(); 
   return range; 
} 


function checkPin(form) { 
	var bor_id = form.bor_id.value;
	//alert("login before = " + bor_id);
	bor_id = bor_id.replace(/ /g, "");
	//alert("login after = " + bor_id);
	form.bor_id.value = bor_id;
}	

// Ripped from the harvard guys.  Thanks all you smart people.
function verify(x,y) { 
      for ( var i = 0; i < x.length; i++ ) { 
         if ( x[i].selected ) { 
            var opt = x[i].value.split("_"); 
            if ( opt[0] == "find" || opt[0] == "F8" ) { 
               document.search.find_code.value = opt[1]; 
               document.search.request.value = y.value; 
//               document.search.action = 
//                  "&server_f"; 
               document.search.submit(); 
               break; 
            } 
            else { 
               document.browse.scan_code.value  = opt[1]; 
               document.browse.scan_start.value = y.value; 
//               document.browse.action = 
//                  "&server_f"; 
               document.browse.submit(); 
               break; 
            } 
         } 
      } 
      return true; 

} 


