/*====================================================================*/
/* AUTOTEXT.JS - Standard Text, Image, and Links Generator            */
/*====================================================================*/
/* Created by Jonathan Fisher                            10 July 2001 */
/* For USGS-Water Resources Division                                  */
/*     MD-DE-DC Water Science Center, Watershed Studies Section                   */
/*====================================================================*/
  /* These programs are designed to function like CSS documents so */
  /* large numbers of HTML documents can be edited through one     */
  /* standardized document. The functions are called from a user's */
  /* browser and generate standardized text, images, and links.    */
  /* Pages are kept consistent and links are kept updated across   */
  /* many documents. For more documentation, visit the site's help */
  /* pages, or write the webmaster for feedback.                   */
  /*                                                               */
  /*   PROGRAMS IN THIS DOCUMENT:                                  */
  /*     header()                                                  */
  /*     coop()                                                    */
  /*     xhr()                                                     */
  /*     textbox3()                                                */
  /*     yesno()                                                   */
  /*     docviewer()                                               */
  /*     footer()                                                  */
  /*     getServer()                                               */
  /*---------------------------------------------------------------*/

var today = new Date();

var dw = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday",
  "Saturday");

var da = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");

var mo = new Array("January","February","March","April","May","June","July",
  "August","September","October","November","December");

var ma = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

var moss = new Array("","January","February","March","April","May","June","July",
  "August","September","October","November","December");

var state = new Array();
  state.DE = 'Delaware'; state.de = 'Delaware';
  state.MD = 'Maryland'; state.md = 'Maryland';
  state.PA = 'Pennsylvania'; state.pa = 'Pennsylvania';
  state.VA = 'Virginia'; state.va = 'Virginia';
  state.WV = 'West Virginia'; state.wv = 'West Virginia';
  state.DC = 'D.C.'; state.dc = 'D.C.';

/*====================================================================*/
/* header([name],[loc])                                               */
/*====================================================================*/
  /* Generates all headers                                         */
  /*---------------------------------------------------------------*/

function header(bnr,loc) {

  // set defaults
  var foreground = 'banner_default.gif';
  var background = '';
  loc += 'banners/';  //add directory of banners to location variable

  // choose a them if specified
  if (bnr) {
    foreground = 'banner_' + bnr + '.gif';
    background = 'banner_' + bnr + '_bg.gif';
  }

  var head = '';
  var lks = 'onClick="return overlib(\'' +
    '<p class=ll><a target=USGS href=http://md.usgs.gov/>MD-DE-DC Water Science Center</a>' +
    '</p><p class=ll>' +
    '<a target=USGS href=http://water.usgs.gov/>Water Resources Division</a>' +
    '</p><p class=ll>' +
    '<a target=USGS href=http://www.usgs.gov/>USGS National Homepage</a>' +
    '</p><p class=ll>' +
    '<a target=USGS href=http://www.doi.gov/>US Department of the Interior</a>' +
    '</p>' + "', CAPTION, 'USGS Links', STICKY, TEXTCOLOR, '#006F41', CLOSECOLOR, '#FFEFD4', FGCOLOR, '#FFEFD4', BGCOLOR, '#006F41', BORDER, '1', OFFSETY, '6', WIDTH, '250', FIXX, '200', FIXY, '12');\"";
  
  if (bnr != '') {
    head = '<tr>\n  <td id="headerCell" colspan=2 valign=top style="padding: 0pt; background: url(' + loc + background + ') top left no-repeat;">\n    ';
    head += '<map id="usgs"><area shape="rect" coords="4,4,173,67" href="javascript:void(0)" ' + 
      'onMouseOver="return overlib(' + "'<pre class=popup>Click here for USGS links</pre>', WIDTH, '40', OFFSETY, '-12', DELAY, '700'" + ')" ' +
      lks + ' onMouseOut="nd(0);"></map><a name="top"></a><img usemap="#usgs" src="' + loc + foreground + '" width=480 height=72 border=0></a><br>';
  } else if (bnr == 'absolute') {
    head = '<tr>\n  <td id="headerCell" colspan=2 valign=top style="padding: 0pt; background: transparent;">\n    ';
    head += '<a href="javascript:void(0)" ' + lks + 
      ' onMouseOut="nd(0);"><img src="' + loc + '" width=177 height=72 border=0></a>\n';
  } else if (bnr == 'special') {
    head = '<tr>\n  <td id="headerCell" colspan=2 valign=top style="padding: 0pt; background: url(' + loc + bnr[1] + ') top left no-repeat;">\n    ';
    head += '<a href="javascript:void(0)" ' + lks +
      ' onMouseOut="nd(0);"><img src="' + loc + 'pholder.gif" width=177 height=72 border=0></a>\n';
  } else { // DEFAULT BANNER
    head = '<tr>\n  <td id="headerCell" colspan=2 valign=top style="padding: 0pt;">\n    ';
    head += '<map id="usgs"><area shape="rect" coords="4,4,173,67" href="javascript:void(0)" ' + 
      'onMouseOver="return overlib(' + "'<pre class=popup>Click here for USGS links</pre>', WIDTH, '40', OFFSETY, '-12', DELAY, '700'" + ')" ' +
      lks + ' onMouseOut="nd(0);"></map><a name="top"></a><img usemap="#usgs" src="' + loc + 'banner_default.gif" width=480 height=72 border=0></a><br>';
  }
  head += '  <div id=headerCellEx></div></td>\n</tr>';
  document.writeln("<tr><td colspan=2><table cellpadding=0 cellspacing=0 border=0 id=pageheader width=100%>"+head+"</table></td></tr>");
  fwLoadMenus();
}


/*====================================================================*/
/* siteloc()                                                          */
/*====================================================================*/
  /* Inserts a line describing the user's location on the site     */
  /*---------------------------------------------------------------*/

function siteloc() {
  ar = document.URL.split('/');
  href = (ar[3]=='usgs'?'http://vs03dmdtws.er.usgs.gov/usgs':'http://md.water.usgs.gov');
  outText = '<h6 class=dir><a class=dir href="' + href + '">Home</a> &gt;&gt; ';
  for (i = (ar[3]=='usgs'?4:3); i < ar.length; i++) {
    switch (ar[i]) {
      case 'watershed' : href += '/' + ar[i]; title = 'Watershed Studies'; break;
      case 'MD118' : href += '/' + ar[i]; title = 'Chesapeake Bay River Inputs'; break;
      case 'MD126' : href += '/' + ar[i]; title = 'Baltimore Ecosystem Study'; break;
      case 'MD130' : href += '/' + ar[i]; title = 'Chesapeake Bay Ecosystem Project'; break;
      case 'MD136' : href += '/' + ar[i]; title = 'Pesticides in Reservoirs Pilot'; break;
      case 'MD149' : href += '/' + ar[i]; title = 'Delaware Inland Bays Watershed Model'; break;
      case 'MD151' : href += '/' + ar[i]; title = 'Potomac Water Quality Monitoring Project'; break;
      case 'MD163' : href += '/' + ar[i]; title = 'Potomac Watershed Model'; break;
      case 'MD169' : href += '/' + ar[i]; title = 'Riparian Restoration'; break;
      case 'MD172' : href += '/' + ar[i]; title = 'Chesapeake Bay Sediment Sources'; break;
      case 'MD200' : href += '/' + ar[i]; title = 'PODL NAWQA'; break;
      case '9B209' : href += '/' + ar[i]; title = 'Anacostia River'; break;
      case '9B211' : href += '/' + ar[i]; title = 'Mattawoman Creek'; break;
      case '9B504' : href += '/' + ar[i]; title = 'Assateague Island'; break;
      case 'tools' : href += '/' + ar[i] + '.html'; title = 'Resources'; break;
      case 'data.html' : href += '/' + ar[i] + '.html'; title = 'Data'; break;
      case 'documents.html' : href += '/' + ar[i] + '.html'; title = 'Project Documentation'; break;
      case 'gages.html' : href += '/' + ar[i] + '.html'; title = 'Project Gages'; break;
      case 'contacts.html' : href += '/' + ar[i] + '.html'; title = 'Contact Information'; break;
      case 'methods.html' : href += '/' + ar[i] + '.html'; title = 'Project Methods'; break;
      default : href += '/' + ar[i]; title = ar[i].split('.')[0];
    }

    if (ar[i+1] == 'index.html') {
      outText += title;
    } else if (title != 'index' && title != '') {
      outText += (i+1<ar.length)?'<a class=dir href="'+href+'" style="text-transform: capitalize;">'+title+'</a> &gt;&gt; ':title;
    }
  }
  outText += '</h6>\n<div class=high height=2></div>\n';
  document.writeln(outText);
}


/*====================================================================*/
/* coop <> Generates standardized links to cooperators                */
/*====================================================================*/
  /* Cooperators occasionally change their website address when    */
  /* updating their technology. Use this script to maintain links  */
  /* to cooperator websites. Cooperators must be identified in the */
  /* html document using the following codes                       */
  /*                                                               */
  /*     DDNR     Delaware Department of Natural Resources         */
  /*     DGS      Delaware Geological Survey                       */
  /*     EPA      U.S. Environmental Protection Agency             */
  /*     CBP      US EPA, Chesapeake Bay Program                   */
  /*     IES      Institute of Ecosystem Studies                   */
  /*     MDE      Maryland Department of the Environment           */
  /*     MDNR     Maryland Department of Natural Resources         */
  /*     MGS      Maryland Geological Survey                       */
  /*     UMBC     University of Maryland, Baltimore County         */
  /*     USGS     United States Geological Survey                  */
  /*              F1E8DB  (new tan color?)                         */
  /*---------------------------------------------------------------*/

function coop() {
  var ar = arguments;
  var loc = ar[0];
  var outText = '';

  for (i = 1; i < ar.length; i++) {
    outText += '<a class=l target=';
    switch (ar[i]) {
      case ('USGS' || 'all') :
        var epa = '<p class=ll>';
        for (x = 1; x < ar.length; x++) {
          if (ar[x] == 'IES') {
            epa += '<a target=USGS href=http://md.water.usgs.gov/BES/>Baltimore Ecosystem Study</a></p><p class=ll>';
          }
        }
        epa += '<a target=USGS href=http://md.usgs.gov/>MD-DE-DC Water Science Center</a>' +
          '</p><p class=ll>' +
          '<a target=USGS href=http://water.usgs.gov/>Water Resources Division</a>' +
          '</p><p class=ll>' +
          '<a target=USGS href=http://www.usgs.gov/>USGS National Homepage</a>' +
          '</p><p class=ll>' +
          '<a target=USGS href=http://www.doi.gov/>US Department of the Interior</a>' +
          '</p>';
        outText += '"" href="javascript:void(0)" onClick="return overlib(' +
          "'" + epa + "', CAPTION, 'USGS Links', STICKY, TEXTCOLOR, '#006F41', CLOSECOLOR, '#FFEFD4', FGCOLOR, '#FFEFD4', BGCOLOR, '#006F41', BORDER, '1', OFFSETY, '6', WIDTH, '250')" +
          '" onMouseOut="nd(0);">U.S. Geological Survey';
        break;
      case ('AINS' || 'all') :
        outText += '"AINS" href="http://www.nps.gov/asis/">Assateague Island National Seashore';
        break;
      case ('IHN' || 'all') :
        outText += '"IHN">Indian Head Naval Ordnance Station';
        break;
      case ('WDC' || 'all') :
        outText += '"WDC">District of Columbia';
        break;
      case ('MWCG' || 'all') :
        outText += '"MWCG">Metropolitan Washington Council of Governments';
        break;
      case ('ABD' || 'all') :
        outText += '"ABD">City of Aberdeen';
        break;
      case ('APG' || 'all') :
        outText += '"APG">U.S. Army, Aberdeen Proving Ground';
        break;
      case ('AAC' || 'all') :
        outText += '"AAC">Anne Arundel County';
        break;
      case ('MOC' || 'all') :
        outText += '"MOC">Montgomery County';
        break;
      case ('PGC' || 'all') :
        outText += '"PGC">Prince Georges County';
        break;
      case ('WSSC' || 'all') :
        outText += '"WSSC">Washington Suburban Sanitary Commission';
        break;
      case ('UPRB' || 'all') :
        outText += '"UPRB">Upper Potomac River Commission';
        break;
      case ('NWS' || 'all') :
        outText += '"NWS" href="http://www.weather.gov">National Weather Service';
        break;
      case ('BDEP' || 'all') :
        outText += '"BDEP">Balto Co Dept of Environment Protection';
        break;
      case ('HAC' || 'all') :
        outText += '"HAC">Harford County';
        break;
      case ('DRB' || 'all') :
        outText += '"DRB">Delaware River Basin Commission';
        break;
      case ('BAL' || 'all') :
        outText += '"BAL">Baltimore City';
        break;
      case ('DDNR' || 'all') :
        outText += '"DDNR" href="http://www.dnrec.state.de.us/">Delaware Department of Natural Resources';
        break;
      case ('DGS' || 'all') :
        outText += '"DGS" href="http://www.udel.edu/dgs/dgs.html">Delaware Geological Survey';
        break;
      case ('CCDPGM' || 'all') :
        outText += '"CCDPGM" href="http://www.charlescounty.org/pgm/">Charles Co Dept of Planning and Growth Management';
        break;
      case ('COE' || 'all') :
        outText += '"USACE" href="http://www.usace.army.mil/">U.S. Army Corps of Engineers';
        break;
      case ('EPA' || 'all') :
        outText += '"EPA" href="http://www.epa.gov/">U.S. Environmental Protection Agency';
        break;
      case ('IES' || 'all') :
        var ies = 'IES is the coordinating organization for Baltimore Urban ' +
          'Long-Term Ecological Research (LTER) Project, a collaboration of ' +
          'Federal, State, Local, non-profit, and academic research sponsored ' +
          'by the National Science Foundation)' +
          '<p class=ll>' +
          '<a href=http://www.ecostudies.org/>Institute of Ecosystem Studies</a>' +
          '</p><p class=ll>' +
          '<a href=http://www.lternet.edu/>Long Term Ecological Research</a>' +
          '</p><p class=ll>' +
          '<a href=http://www.nsf.gov/>National Science Foundation</a>';
          '</p>';
        outText += '"" href="javascript:void(0)" onClick="return overlib(' +
          "'" + ies + "', CAPTION, 'About IES', STICKY, TEXTCOLOR, '#006F41', CLOSECOLOR, '#FFEFD4', FGCOLOR, '#FFEFD4', BGCOLOR, '#006F41', BORDER, '1', OFFSETY, '6', WIDTH, '250')" +
          '" onMouseOut="nd(0);">Institute of Ecosystem Studies';
        break;
      case ('MDE' || 'all') :
        outText += '"MDE" href="http://www.mde.state.md.us/">Maryland Department of the Environment';
        break;
      case ('MDNR' || 'all') :
        outText += '"MDNR" href="http://www.dnr.state.md.us/">Maryland Department of Natural Resources';
        break;
      case ('MGS' || 'all') :
        outText += '"MGS" href="http://www.mgs.md.gov/">Maryland Geological Survey';
        break;
      case ('MSHA' || 'all') :
        outText += '"MSHA">Maryland State Highway Administration';
        break;
      case ('MWR' || 'all') :
        outText += '"MWR">Maryland Water Resources / Bureau of Mines';
        break;
      case ('NPS' || 'all') :
        outText += '"NPS" href="http://www.nps.gov/">National Park Service';
        break;
      case ('PRB' || 'all') :
        outText += '"PRB" href="http://www.potomacriver.org/">Interstate Commission on the Potomac River Basin';
        break;
      case ('CBP' || 'all') :
        var epa = '<p class=ll>' +
          '<a target=CBP href=http://www.chesapeakebay.net/>Chesapeake Bay Program Homepage</a>' +
          '</p><p class=ll>' +
          '<a target=CBP href=http://www.epa.gov/r3chespk/>EPA - Chesapeake Bay Program Office</a>' +
          '</p><p class=ll>' +
          '<a target=CBP href=http://www.epa.gov/r3chespk/>USGS - Chesapeake Bay Ecosystem Project</a>' +
          '</p>';
        outText += '"" href="javascript:void(0)" onClick="return overlib(' +
          "'" + epa + "', CAPTION, 'CBP Links', STICKY, TEXTCOLOR, '#006F41', CLOSECOLOR, '#FFEFD4', FGCOLOR, '#FFEFD4', BGCOLOR, '#006F41', BORDER, '1', OFFSETY, '6', WIDTH, '280')" +
          '" onMouseOut="nd(0);">Chesapeake Bay Program';
        break;
      case ('UMBC' || 'all') :
        for (x = 1; x < ar.length; x++) {
          if (ar[x] == 'IES' || ar[i] == 'all') { var ies = 'true'; break; }
        }
        if (ies) {
          var ies = '<p class=ll>' +
            '<a target=BES href=http://www.ecostudies.org/bes/>Baltimore Ecosystem Study</a>' +
            '</p><p class=ll>' +
            '<a target=UMBC href=http://www.umbc.edu/>UMBC Campus Homepage</a>' +
            '</p>';
          outText += '"" href="javascript:void(0)" onClick="return overlib(' +
            "'" + ies + "', CAPTION, 'UMBC Links', STICKY, TEXTCOLOR, '#006F41', CLOSECOLOR, '#FFEFD4', FGCOLOR, '#FFEFD4', BGCOLOR, '#006F41', BORDER, '1', OFFSETY, '-18', WIDTH, '200')" +
            '" onMouseOut="nd(0);">Universty of Maryland, Baltimore County';
        } else {
          outText += '"UMBC" href="http://www.umbc.edu/">Universty of Maryland, Baltimore County';
        }
        break;
    } // END SWITCH
    outText += '</a><br>';

  } // END SELECTION LOOP

  if (loc == 'links only') {
    document.writeln(outText);
  } else {
    textbox3(loc,'Project Cooperators:',
      outText,
      'halign=left;margin=10px, 0px, 16px, 20pt;width=300;nowrap');
  }
}


/*====================================================================*/
/* xhr([loc|shorthand],[param=value;param=value],[],...)              */
/*====================================================================*/
  /* This element is based upon, but not limited to, the <hr>      */
  /* element of HTML. The xhr() program allows for special style   */
  /* parameters to create custom layout effects.                   */
  /*---------------------------------------------------------------*/

function xhr() {
  var ar = arguments;
  var text = '';

  if (ar.length == 0) {
    text = '<hr>';
  } else {
    var loc = ar[0];
    var param = new Array();

    // set defaults
    param.align     = 'center';
    param.width     = '100%';
    param.height    = '2';
    param.size      = param.height
    param.color     = ''; // #D5BE93 for WSS, else transparent
    param.aural     = 'dividing bar';
    param.margin    = '0px';
    param.padding   = '0px';
    param.classname = '';
    param.id        = '';
    param.image     = loc + 'pholder.gif';
    param.imgalign  = 'center';
    param.bgoptions = 'repeat';
    param.border    = 'none';

    // split everything into its place in param()
    for (i = 1; i < ar.length; i++) {
      sets = ar[i].split(';');
      for (j = 0; j < sets.length; j++) {
        pair = sets[j].split('=');
        if (pair.length == 1) {
          param[pair[0]] = pair[0];
        } else {
          param[pair[0]] = pair[1];
        }
      }
    }

    // translate alignment text into html parameters
    if (param.left)   { param.align = 'align="left"';   }
    if (param.center) { param.align = 'align="center"'; }
    if (param.right)  { param.align = 'align="right"';  }

    if (loc == 'solid' || loc == 'classic') {
      var type = '';
      if (loc == 'solid') {
        type = ' noshade';
        if (param.color != '' && param.color != 'transparent') {
          type += ' color="' + param.color + '"';
        }
      }
      var classiccolor = '';
      if (loc == 'classic' && param.color != '' && param.color != 'transparent') {
        classiccolor = ' background-color: ' + param.color + ';';
      }
      if (param.id) { type += ' id="' + param.id + '"'; }
      text = '<hr' + type +
        ' class="' + param.classname +
        '" align="' + param.align +
        '" size="' + param.height +
        '" width="' + param.width +
        '" style="margin: ' + param.margin +
        '; padding: ' + param.padding +
        '; border: ' + param.border + ';' + classiccolor + '">';

    } else {
      var background = '';
      if (param.color != '') {
        if (param.background != '') {
          param.background = ' url(' + param.background + ') ' +
            param.bgoptions;
        }
        background = 'background: ' + param.color + param.background;
      }

      text = '<table cellpadding=0 cellspacing=0 border=0 width="100%"><tr><td>' +
        '<table cellpadding=0 cellspacing=0 border=0 ' +
        'summary="' + param.aural +
        '" width="' + param.width +
        '" align="' + param.align +
        '" style="margin: ' + param.margin + ';">\n' +
        '<tr><td height="' + param.height +
        '" align="' + param.imgalign +
        '" id="' + param.id +
        '" class="' + param.classname +
        '" style="' + background +
        'padding: ' + param.padding +
        '; border: ' + param.border + ';">' +
        '<img src="' + param.image + '">' +
        '</td></tr></table></td></tr></table>';
    }
  }

  document.writeln(text);
}


/*====================================================================*/
/* textbox3([location],[heading],[text],[param=val;param=val],[],...) */
/*====================================================================*/
  /*---------------------------------------------------------------*/

function textbox3() {
  var ar = arguments;
  
  var param = new Array();

  // set defaults
  param.align   = '';
  param.width   = '';
  param.height  = '';
  param.summary = '';
  param.margin  = '0px';
  param.halign  = 'center';
  param.hclass  = 'heading';
  param.hpad    = '1px';
  param.hwrap   = 'nowrap';
  param.balign  = 'left';
  param.bclass  = 'normal';
  param.bpad    = '0px, 6px';
  param.nowrap  = '';

  // split everything into its place in param()
  for (i = 3; i < ar.length; i++) {
    sets = ar[i].split(';');
    for (j = 0; j < sets.length; j++) {
      pair = sets[j].split('=');
      if (pair.length == 1) {
        param[pair[0]] = pair[0];
      } else {
        param[pair[0]] = pair[1];
      }
    }
  }

  // avoid a bad parameter if wrapping changes
  if (param.hwrap != 'nowrap')  { param.hwrap  = ''; }
  if (param.nowrap != 'nowrap') { param.nowrap = ''; }

  // translate alignment text into html parameters
  if (param.left)     { param.align = 'align="left"';     }
  if (param.center)   { param.align = 'align="center"';   }
  if (param.right)    { param.align = 'align="right"';    }

  // this idea might want to be saved for later
    // add a background if requested
    //if (param.background) { param.bg = 'background: url(' + param.background + ');'; }
  
  // translate special shorthand commands into parameters
  if (param.topleft) {
    param.align = 'align="left"';
    param.margin = '0px,8px,8px,0px';
  }
  if (param.topright) {
    param.align = 'align="right"';
    param.margin = '0px,0px,8px,8px';
  }
  if (param.justify)  {
    param.align = 'align="justify"';
    param.nowrap = '';
  }

  // get the required values
  var loc = ar[0];
  var htext = ar[1];
  var btext = ar[2];
  
  var hwidth='';
  var bwidth='';
  if (param.width == '100%' || param.width.search('%') > -1) {
    var hwidth = param.width;
    var bwidth = param.width;
  } else if (param.width == '') {
    bwidth='100%';
  } else {
    var hwidth = (param.width - 14);
    var bwidth = (param.width - 2);
  }

  // decide which header line to use
  var outText = '<table ' + param.align + ' width="' + param.width + '" cellpadding=0 cellspacing=0 border=0 style="margin: ' + param.margin + ';">'
  if (htext) {
    var rowspan = '';
    if (!btext) { rowspan = ' rowspan="2" '; }
    outText += '<tr class="box1">\n' +
      '<td width=7 style="vertical-align: top; text-align: left;"><img src="' + loc + 'box1_tl.gif"></td>\n' +
      '<td ' + rowspan + 'class="' + param.hclass + '" style="text-align: ' + param.halign + '; padding: ' + param.hpad + ';" ' + param.hwrap + '>' +
      htext + '</td>\n' +
      '<td width=7 style="vertical-align: top; text-align: right;"><img src="' + loc + 'box1_tr.gif"></td>\n' +
      '</tr>\n';
  } else {
    outText += '<tr class="chart2b">\n' +
      '<td width=7 style="vertical-align: top; text-align: left;"><img src="' + loc + 'box3_tl.gif"></td>\n' +
      '<td width="100%" valign=top><img src="' + loc + 'box1_tr.gif"></td></td>\n' +
      '<td width=7 style="vertical-align: top; text-align: right;"><img src="' + loc + 'box3_tr.gif"></td>\n' +
      '</tr>\n';
  }
  
  if (btext) {
    // add the body text
    outText += '<tr>\n<td class=box2 style="border-left: 1px solid #CDCDB4;"><img src="'+loc+'pholder.gif"></td><td width="' + (param.width-14) + '">' +
      '<table width="' + bwidth + '" class="box2" cellpadding=0 cellspacing=0 border=0><tr>\n' +
      '<td class="' + param.bclass + '" style="background: transparent; padding: ' + param.bpad + '; text-align: ' + param.balign + ';" ' + param.nowrap + '>' +
      btext +
      '</td></tr></table></td><td class=box2 style="border-right: 1px solid #CDCDB4;"><img src="'+loc+'pholder.gif"></td>\n' +
      '</tr>\n';
    // close box with a footer
    outText += '<tr class=box2>\n' +
      '<td width=7 style="vertical-align: bottom; text-align: left;"><img src="' + loc + 'box3_bl.gif"></td>\n' +
      '<td width="' + hwidth + '" valign=bottom style="border-bottom: 1px solid #CDCDB4;"><img src="'+loc+'pholder.gif"></td>\n' +
      '<td width=7 style="vertical-align: bottom; text-align: right;"><img src="' + loc + 'box3_br.gif"></td>\n' +
      '</tr>\n';
  } else {
    // skip the text if there is none
    outText += '<tr class="box1">\n' +
      '<td width=7 style="vertical-align: bottom; text-align: left;"><img src="' + loc + 'box1_bl.gif"></td>\n' +
      '<td width=7 style="vertical-align: bottom; text-align: right;"><img src="' + loc + 'box1_br.gif"></td>\n' +
      '</tr>\n';
  }

  outText += '</table>\n';
  
  document.writeln(outText);
}


/*====================================================================*/
/* yesno([string])                                                    */
/*====================================================================*/
  /* Used to decide if a string is a positive or negative phrase.  */
  /*---------------------------------------------------------------*/

var positives = new Array('yes','always','true','is')
var negatives = new Array('no','never','false','was','not')

function yesno(question) {
  question = question.tolowercase();
  var answer = 1;
  if (question < 0) {
    answer = -1;
  } else {
    for (i = 0; i < negatives.length; i++) {
      if (question.search(negatives[i])) {
        answer = -1;
        break;
      }
    }
  }
  return answer;
}


/*====================================================================*/
/* .getMonthLength()       -- Method of a Date object                 */
/*====================================================================*/
  /* Returns the number of days in the month of the Date object    */
  /*---------------------------------------------------------------*/

function getMonthLength(datevar) {
  daystart = new Date(datevar);
  dayfinish = new Date(datevar);
  nextyear = daystart.getYear();
  nextmonth = daystart.getMonth() + 1;

  //ADJUST FINISH TO NEXT MONTH
  if (nextmonth == 12) { nextmonth = 0; nextyear++; }
  dayfinish.setMonth(nextmonth);
  dayfinish.setYear(nextyear);

  //SET TO MIDNIGHT ON FIRST OF MONTH FOR BOTH DAYS
  daystart.setDate(1);
  daystart.setHours(0);
  daystart.setMinutes(0);
  daystart.setSeconds(0);
  dayfinish.setDate(1);
  dayfinish.setHours(0);
  dayfinish.setMinutes(0);
  dayfinish.setSeconds(0);

  //GET MILLISECONDS IN THE START MONTH
  answer = Date.parse(dayfinish) - Date.parse(daystart);
  answer = answer / 86400000;

  //this.days = answer;
  return answer;
}


/*====================================================================*/
/* docviewer()                                                        */
/*====================================================================*/
  /* Opens a window named "docviewer" if it is not already open    */
  /* and then brings the "docviewer" window into focus.            */
  /*---------------------------------------------------------------*/

function docviewer() {
  if (!docviewer) {
    docviewer=window.open('','docviewer');
  }
  self.docviewer.focus();
}


/*====================================================================*/
/* footer()                                                           */
/*====================================================================*/
  /* Generates the standard footer for USGS pages, with links to   */
  /* information, disclaimers, and document descriptions.          */
  /*---------------------------------------------------------------*/

var loc;
var ini;

function footer(loc,ini) {
  var pageFooter;

  updated = new Date();
  Month   = mo[updated.getMonth()];
  Day     = updated.getDate();
  Year    = updated.getYear();
  Hour    = updated.getHours();
  Min     = updated.getMinutes();
  Sec     = updated.getSeconds();
  if(Year < 2000) Year += 1900;
  if(Year < 2000) Year += 100;  //Netscape 3 and IE 4.7 return 0 instead of 100 for 2000
  if(Hour < 10) Hour = "0" + Hour;
  if(Min  < 10) Min  = "0" + Min;
  if(Sec  < 10) Sec  = "0" + Sec;
  dloaded = "Downloaded: " + Day +"-"+ Month +"-"+ Year +" at "+ Hour +":"+ Min +":"+ Sec +"ET";

  updated = new Date(document.lastModified);
  Month   = mo[updated.getMonth()];
  Day     = updated.getDate();
  Year    = updated.getYear();
  Hour    = updated.getHours();
  Min     = updated.getMinutes();
  Sec     = updated.getSeconds();
  if(Year < 2000) Year += 1900;
  if(Year < 2000) Year += 100;  //Netscape 3 and IE 4.7 return 0 instead of 100 for 2000
  if(Hour < 10) Hour = "0" + Hour;
  if(Min  < 10) Min  = "0" + Min;
  if(Sec  < 10) Sec  = "0" + Sec;
  last_modified = "Last modified: " + Day +"-"+ Month +"-"+ Year +" at "+ Hour +":"+ Min +":"+ Sec +"ET";

  var disc = 'USGS provides no warranty, expressed or implied, as to the accuracy, reliability or completeness of furnished data. ' +
    'For complete official disclaimers, please visit these pages:' +
    '<p class=ll><a href=http://www.usgs.gov/privacy.html>USGS Privacy Statement</a></p>' +
    '<p class=ll><a href=http://www.usgs.gov/disclaimer.html>USGS Disclaimer Statement</a></p>' +
    '<p class=ll><a href=http://www.usgs.gov/foia/>Freedom of Information Act</a></p>';
  var firstgov = 'class="image" target="FirstGov" href="http://www.firstgov.gov" onMouseOver="return overlib(' +
    "'The official US Government website with links and searches of Federal and State agency webpages.'," +
    "LEFT, DELAY, 700, TEXTCOLOR, '#000066', FGCOLOR, '#FFFFFF', BGCOLOR, '#000066', BORDER, '2', OFFSETY, '45', WIDTH, '200')" +
    '" onMouseOut="nd(0);"';
  pageFooter = '' +
    '<tr>\n' +
    '  <td id=navsbase style="background: url(\''+loc+'graphics/bg_navbar_b2.bmp\') top left no-repeat;"><img src="'+loc+'pholder.gif" height=10></td>\n' +
    '  <td style="background: url(\''+loc+'graphics/page_r.bmp\') right repeat-y;"><img src="'+loc+'pholder.gif"></td>\n' +
    '</tr>\n' +
    '<tr>\n' +
    '  <td class="shade" colspan=2 style="padding: 1px, 14px, 1px, 0px;background: url(\''+loc+'graphics/page_r.bmp\') right repeat-y;">\n' +
    '    <table cellpadding=0 cellspacing=0 border=0 width="100%" style="filter: alpha(opacity=70);">\n' +
    '      <tr bgcolor="#A8A292" style="background:#A8A292; font-family: Trebuchet MS, sans-serif;">\n' +
    '        <td nowrap><font size=1><b>&nbsp;About these pages: &nbsp;</b></td>\n' +
    '        <td><font size=1><a href="javascript:askprint()" class=nav>printing</a></td>\n' +
    '        <td valign=center align=center><font size=1>&nbsp;||&nbsp;</td>\n' +
    '        <td><font size=1><a href="javascript:void(0);" onClick="return overlib(\'' + disc + '\',\n' +
    "          CAPTION, 'USGS Disclaimers', STICKY, TEXTCOLOR, '#006f41', FGCOLOR, '#FFEFD4', BGCOLOR, '#006F41', CLOSECOLOR, '#FFEFD4', BORDER, '2', OFFSETY, '100', WIDTH, '250')\"\n" +
    '          onMouseOut="nd(0);" class=nav>disclaimers</a></td>\n' +
    '        <td valign=center align=center><font size=1>&nbsp;||&nbsp;</td>\n' +
    '        <td><font size=1><a href="' + loc + 'feedback.html" class=nav>feedback</a></td>\n' +
    '        <td nowrap style="padding-left:30px;"><font size=1><b>&nbsp;National USGS Sites: &nbsp;</b></td>\n' +
    '        <td><font size=1><a href="http://www.usgs.gov" class=nav>USGS</a></td>\n' +
    '        <td valign=center align=center><font size=1>&nbsp;||&nbsp;</td>\n' +
    '        <td><font size=1><a href="http://water.usgs.gov" class=nav>Water</a></td>\n' +
    '        <td valign=center align=center><font size=1>&nbsp;||&nbsp;</td>\n' +
    '        <td><font size=1><a href="http://geology.usgs.gov" class=nav>Geology</a></td>\n' +
    '        <td valign=center align=center><font size=1>&nbsp;||&nbsp;</td>\n' +
    '        <td><font size=1><a href="http://mapping.usgs.gov" class=nav>Mapping</a></td>\n' +
    '        <td valign=center align=center><font size=1>&nbsp;||&nbsp;</td>\n' +
    '        <td><font size=1><a href="http://biology.usgs.gov" class=nav>Biology</a></td>\n' +
    '        <td valign=center align=center><font size=1>&nbsp;||&nbsp;</td>\n' +
    '        <td><font size=1><a href="http://www.doi.gov" class=nav>Interior</a></td>\n' +
    '        <td id=outofprint width="100%" class="text" nowrap style="text-align: right; padding: 0pt, 0pt, 0pt, 10pt;">&nbsp;</td>\n' +
    '        <td nowrap style="text-align: right; padding: 0pt, 0pt, 0pt, 10pt;"><font size=1><a href="' + loc + 'help.html#sitemap" class=nav>site map</a>&nbsp;</td>\n' +
    '      </tr>\n' +
    '    </table>\n' +
    '  </td>\n' +
    '</tr>\n\n' +
    '<tr><td colspan=2 style="padding: 0px,14px,4px,0px; background: url(\''+loc+'graphics/page_r.bmp\') right repeat-y;">\n'+
    '  <table width="100%" border="0">\n'+
//    '    <tr>\n'+
//    '      <td colspan="6"><div align="center"><strong><img src="graphics/footer/footer_hr.gif" width="320" height="7" /><font size="2" face="Trebuchet MS, Tahoma, Helvetica, Arial, sans-serif" color="#757562">&nbsp;&nbsp;&nbsp;National\n'+
//    '          Sites&nbsp;&nbsp;&nbsp;</font><img src="graphics/footer/footer_hr.gif" width="320" height="7" /></strong></div></td>\n'+
//    '    </tr>\n'+
//    '    <tr>\n'+
//    '      <td height="16"><a href="http://www.usgs.gov" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'usgs1\',\'\',\'graphics/footer/usgs_on.gif\',1)"><img src="graphics/footer/usgs.gif" name="usgs1" width="128" height="14" border="0" id="usgs1" /></a></td>\n'+
//    '      <td><a href="http://water.usgs.gov" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'water1\',\'\',\'graphics/footer/water_on.gif\',1)"><img src="graphics/footer/water.gif" name="water1" width="128" height="14" border="0" id="water1" /></a></td>\n'+
//    '      <td><a href="http://geology.usgs.gov" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'geology1\',\'\',\'graphics/footer/geology_on.gif\',1)"><img src="graphics/footer/geology.gif" name="geology1" width="128" height="14" border="0" id="geology1" /></a></td>\n'+
//    '      <td><a href="http://mapping.usgs.gov" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'mapping1\',\'\',\'graphics/footer/mapping_on.gif\',1)"><img src="graphics/footer/mapping.gif" name="mapping1" width="128" height="14" border="0" id="mapping1" /></a></td>\n'+
//    '      <td><a href="http://biology.usgs.gov" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'biology1\',\'\',\'graphics/footer/biology_on.gif\',1)"><img src="graphics/footer/biology.gif" name="biology1" width="128" height="14" border="0" id="biology1" /></a></td>\n'+
//    '      <td><a href="http://www.doi.gov" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'doi\',\'\',\'graphics/footer/interior_on.gif\',1)"><img src="graphics/footer/interior.gif" name="doi" width="128" height="14" border="0" id="doi" /></a></td>\n'+
//    '    </tr>\n'+
    '    <tr>\n'+
    '      <td height="44" colspan="2" valign="top" align="left"><font color="#757562" size="1" face="Geneva, Arial, Helvetica, sans-serif">USGS\n'+
    '          Water Resources Division MD-DE-DC<br />\n'+
    '          8987 Yellow Brick Road, Baltimore, MD 21237<br />\n'+
    '          Tel: 410-238-4200 | Fax: 410-238-4210</font></td>\n'+
    '      <td height="44" colspan="2" valign="top" align="center">\n'+
    '          <a href="http://www.firstgov.gov"><img src="graphics/footer/1st_gov.gif" width="214" height="42" border="0" /></a></td>\n'+
    '      <td height="44" colspan="2" valign="top" align="right"><font color="#757562" size="1" face="Geneva, Arial, Helvetica, sans-serif">Maintainer:\n'+
    '          <a href="mailto:webmaster@md.water.usgs.gov">webmaster@md.water.usgs.gov</a><br />\n'+
    '          ' + last_modified + " (" + ini + ")<br />\n"+
    '          <a href="http://www.usgs.gov/privacy.html">USGS Privacy</a>\n'+
    '          | <a href="http://www.usgs.gov/disclaimer.html">Disclaimer</a>\n'+
    '          | <a href="http://www.usgs.gov/foia/">FOIA</a> | <a href="http://www.doi.gov/">DOI</a>\n'+
    '          | <a href="http://www.usgs.gov/accessibility.html">508</a></font></td>\n'+
    '    </tr>\n'+
    '  </table>\n'+
    '</td></tr>\n'+
//    '<tr>\n' +
//    '  <td colspan=2 style="padding: 0px,14px,4px,0px; background: url(\''+loc+'graphics/page_r.bmp\') right repeat-y;">\n' +
//    '    <table cellpadding=0 cellspacing=0 border=0 width="100%">\n' +
//    '      <tr><td valign=bottom class="footer" colspan=2 style="padding-top: .3em;">\n' +
//    '          <address style="margin: 0pt, 10pt; text-indent: -10pt;">' +
//              '<a style="font-weight: normal;" href="http://www.doi.gov">U.S. Department of the Interior</a> || ' +
//              '<a style="font-weight: normal;" href="http://www.usgs.gov">U.S. Geological Survey</a> || ' +
//              '<a style="font-weight: normal;" href="' + getServer() + '">MD-DE-DC Water Science Center</a></address>\n' +
//            '</td>'+
//            '<td valign=bottom nowrap rowspan=2>\n' +
//              '<a class=normal ' + firstgov + '><img src="' + loc + 'firstgov.gif" border=0 align=right width=173 height=52 style="background: #FFFFFF;"></a>\n' +
//            '</td>\n' +
//          '</tr>'+
//          '<tr><td valign=bottom class="footer" style="overflow: hidden;">'+
//    '          <address id=footer_url style="margin: 0pt, 10pt; line-height: 1.2em; text-indent: -10pt;">URL: ' + document.URL + '</address>\n' +
//    '          <address style="margin: 0pt, 10pt; line-height: 1.2em; text-indent: -10pt;">Maintainer: <a style="font-weight: normal;" href="' +loc + 'feedback.html">webmaster@md.water.usgs.gov</a></address>';
//
//  pageFooter += '<address id=downloaded_at style="margin: 0pt, 10pt; line-height: 1.2em; text-indent: -10pt;">' + dloaded + '</address>\n';
//
//  pageFooter += '<address style="margin: 0pt, 10pt; line-height: 1.2em; text-indent: -10pt;">' + last_modified + (ini?" ("+ini+")":"") + '</address>\n';
//  
//  pageFooter += '</address>\n' +
//    '        </td>\n' +
//    '        <td valign=bottom nowrap class="footer">\n' +
//              '<address style="margin: 0pt, 10pt; line-height: 1.2em; text-indent: -10pt;">8987 Yellow Brick Road</address>'+
//              '<address style="margin: 0pt, 10pt; line-height: 1.2em; text-indent: -10pt;">Baltimore, MD 21237</address>'+
//              '<address style="margin: 0pt, 10pt; line-height: 1.2em; text-indent: -10pt;">Tel: 410-238-4200 | Fax: 410-238-4210</address>\n' +
//    '        </td>\n' +
//    '      </tr>\n' +
//    '    </table>\n' +
//    '  </td>\n' +
//    '</tr>' +
    '<tr>\n' +
    '  <td align=right colspan=2 style="background: url(\''+loc+'graphics/page_b.gif\') right repeat-x;"><img src="'+loc+'graphics/page_br.gif"></td>\n' +
    '</tr>\n';
  document.writeln(pageFooter);
}

function askprint() {
  printnow = window.confirm("For best printing results, adjust your " +
    "browser to print background\nimages and colors. The site map and " +
    "\"Site Help\" file (help.html) have\ninstructions if you are not " +
    "sure how to adjust your browser.\n\n" +
    "Do you wish to print now?");
  if (printnow) {
    print();
  } else {
  }
}


/*====================================================================*/
/* datePeriod()                                                       */
/*====================================================================*/
  /* Converts a two-part date string into date obects and returns  */
  /* them in an array:                                             */
  /*   .start  = start date                                        */
  /*   .finish = end date                                          */
  /*   .abrev  = abreviated text string                            */
  /*---------------------------------------------------------------*/

function datePeriod(string) {

  period = string.split("-");

  if (period[0]) {
    period.start = new Date(period[0].substring(0, 4), (period[0].substring(4, 6) - 1), period[0].substring(6, 8));
  }
  if (period[1]) {
    period.finish = new Date(period[1].substring(0, 4), (period[1].substring(4, 6) - 1), period[1].substring(6, 8));
  }

  period.abrev = 'Xperiod';

  if (period.start && period.start.getYear() <= 99) {
    period.abrev = period.start.getDate() +" "+ ma[period.start.getMonth()] +" "+ '19' + period.start.getYear();
  } else if (period.start) {
    period.abrev = period.start.getYear();
  }

  if (period.start && !period.finish) {
    period.abrev += ' thru Present';
  } else if (period.finish && period.finish.getYear() <= 99) {
    period.abrev += ' thru ' + period.finish.getDate() +" "+ ma[period.finish.getMonth()] +" " + '19' + period.finish.getYear();
  } else if (period.finish) {
    period.abrev += ' thru ' + period.finish.getDate() +" "+ ma[period.finish.getMonth()] +" " + period.finish.getYear();
  }

  return period;
}

/*====================================================================*/
/* getServer()                                                        */
/*====================================================================*/
  /* Returns a string value that represents the document's server. */
  /* Note: This only works within the MD-DE-DC site.               */
  /*---------------------------------------------------------------*/

function getServer() {
  pageURL = document.URL.split('/');
  if (pageURL[3]=='usgs') return pageURL[0] + '//' + pageURL[2] + '/usgs';
  else return pageURL[0] + '//' + pageURL[2];
}


/*====================================================================*/
/* grayscale()                                                        */
/*====================================================================*/
  /*---------------------------------------------------------------*/

var isgray = false;
function grayscale() {
  if (isgray) {
    document.body.style.filter = '';
    isgray = false;
    colorblind.innerHTML = 'Grayscale';
  } else {
    document.body.style.filter = 'Gray';
    isgray = true;
    colorblind.innerHTML = 'Colorize';
  }
}