// ___________________________________________________________________________
// 
// Name:        lnllconfig.js 
//
// Author:      Tim Schramer - bifftoe@yahoo.com
//
// Description: Common settings for Laguna Niguel Little League Website.
//              Included in web pages to standardize common values. 
//
// Usage:       This file is auto-generated off-line from the "lnllconfig.ini"
//              settings file and sent to the website by the "LNLLConfig"
//              program. Variables below may be edited directly and this file 
//              transferred to the website manually if bypassing the automatic
//              update method.
//
//              To insert one of the preset values into a webpage,
//              first insert the line:
//
//  <SCRIPT LANGUAGE="JavaScript" SRC="./lnllconfig.js"></SCRIPT> 
//
//              within the <HEAD></HEAD> section near the top of the page.
//              Then add lines to refer to the variables below with the
//              following syntax (example Year):
//
//  <SCRIPT LANGUAGE="JavaScript">document.writeln(lnllconfig.Year);</SCRIPT>
//
//              Some variable are arrays and need looping to access values.
//              (example, for each Division print all the Team Managers): 
//
//  <SCRIPT LANGUAGE="JavaScript">
//    for (var i=0; i<lnllconfig.Divisions.length; i++) {
//      document.writeln(lnllconfig.Divisions[i].Name);
//      document.writeln(lnllconfig.Divisions[i].Commissioner);
//      for (var j=0; j<lnllconfig.Divisions[i].Teams.length; j++) {
//        document.writeln(lnllconfig.Divisions[i].Teams[j].Manager);
//      }
//    }
//  </SCRIPT>
//
// ___________________________________________________________________________

var lnllconfig;
var uDivision="",uTeam="",uLeague="",uDate1="",uDate2="",uOther="";

if(lnllconfig==null) lnllconfig = new makeAdmin();
getURLParameters();

// Make a top-level object with all site information.
// ___________________________________________________________________________
function makeAdmin() {
  var BoardMembers=new Array();
  var Divisions=new Array();
  var Sponsors=new Array();
  var nb=0,nd=0,ns=0;

//(The code above this line may be overwritten by the contents of a file named "C:\lnlladmin\LNLLConfig.js1".)
//............(End Section 1)
  this.Year=             '2011';
  this.Address1=         'P.O. Box 6985';
  this.Address2=         'Laguna Niguel, CA 92607';
  this.Phone=            '';
  this.Website=          'www.lnll.org';
  this.Email=            'webmaster@lnll.org';
  this.Sponsorname=      'GotData.com';
  this.Sponsorlink=      'www.gotdata.com';
  this.Openingday=       '20110201';
  this.Allowinterleague= 'No';

  BoardMembers[nb++]=new makeBoardMember('President',
                                         'Erica Hoopes',
                                         'ericahoopes@gmail.com');

  BoardMembers[nb++]=new makeBoardMember('Vice President',
                                         'Greg Fisher',
                                         'grjf@cox.net');

  BoardMembers[nb++]=new makeBoardMember('Treasurer',
                                         'Mike Gartlan',
                                         'mgartlan@kbhome.com');

  BoardMembers[nb++]=new makeBoardMember('Secretary',
                                         'Paul Van Hoomissen',
                                         'pvanhoomissen@muchshelist.com');

  BoardMembers[nb++]=new makeBoardMember('Player Agent',
                                         'Bill Quinley',
                                         'xtremequinley@cox.net');

  BoardMembers[nb++]=new makeBoardMember('League Information Officer',
                                         'Brian Pike',
                                         'brian@pikedesign.net');

  BoardMembers[nb++]=new makeBoardMember('City Liaison',
                                         'Rich McKeown',
                                         'apinc@mac.com');

  BoardMembers[nb++]=new makeBoardMember('Operations Director - Equipment and Uniforms',
                                         'Ron Hoopes',
                                         'ron@1cd.com');

  BoardMembers[nb++]=new makeBoardMember('Special Events Coordinator',
                                         'Julie Wagener',
                                         'jwagener@cox.net');

  BoardMembers[nb++]=new makeBoardMember('Sponsorship Director',
                                         'Eric Anderson',
                                         'lnllbaseball@gmail.com');

  BoardMembers[nb++]=new makeBoardMember('Operations Director - Safety/Fields',
                                         'Shauna Atchity',
                                         'atchityoc@yahoo.com');

  BoardMembers[nb++]=new makeBoardMember('Chief Umpire',
                                         'Dave Alldredge|Mark Casazza ',
                                       'david.alldredge@te.com|mcdirt@cox.net');

  BoardMembers[nb++]=new makeBoardMember('Snack Bar Director',
                                         'Julie Zwahlen|Rachel Snyder',
                            			 'juliezwahlen@cox.net|rachelcsnyder@yahoo.com');
                            			 
   BoardMembers[nb++]=new makeBoardMember('Departmental Liaison',
                                         'Stacey Healey',
                            			 'staceyhealey@cox.net');                          			 

  BoardMembers[nb++]=new makeBoardMember('Seniors & Juniors Commissioner',
                                         'Bob Fulton',
                                         'lnlljuniors@gmail.com');

  BoardMembers[nb++]=new makeBoardMember('Majors Commissioner',
                                         'Ira Hermann',
                                         'irahermann@aol.com');

  BoardMembers[nb++]=new makeBoardMember('AAA Commissioner',
                                         'Todd Gallina',
                                         'gallina@gmail.com');

  BoardMembers[nb++]=new makeBoardMember('AA Commissioner',
                                         'Bito Borovinsky',
                                         'Bito.Borovinsky@marsh.com');

  BoardMembers[nb++]=new makeBoardMember('A Commissioner',
                                         'Steve Jenner',
                                         'sajenner@cox.net');

  BoardMembers[nb++]=new makeBoardMember('Coach Pitch Commissioner',
                                         'Bill Stairs',
                                         'wcstairs@aol.com');

  BoardMembers[nb++]=new makeBoardMember('T-Ball Commissioner',
                                         'Larry Wagner',
                                         'larrywagner4@gmail.com');


  Sponsors[ns++]=new makeSponsor('Platinum',
                                 '',
                                 '',
                                 '',
                                 unescape('Dicks%20Sporting%20Goods'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Platinum',
                                 '',
                                 '',
                                 '',
                                 unescape('Sports%20Authority'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Platinum',
                                 '',
                                 '',
                                 '',
                                 unescape('Cox%20Media'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Platinum',
                                 '',
                                 '',
                                 '',
                                 unescape('Ira%20Hermann'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Gold',
                                 '',
                                 '',
                                 '',
                                 unescape('All%20American%20Plumbing'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Gold',
                                 '',
                                 '',
                                 '',
                                 unescape('Laguna%20Niguel%20Rotary%20Club'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Gold',
                                 '',
                                 '',
                                 '',
                                 unescape('Newport%20Lexus'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Gold',
                                 '',
                                 '',
                                 '',
                                 unescape('Wizard%20Sports%20Equipment'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Silver',
                                 '',
                                 '',
                                 '',
                                 unescape('PCM'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Silver',
                                 '',
                                 '',
                                 'The Swanson Family',
                                 unescape(''),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Silver',
                                 '',
                                 '',
                                 '',
                                 unescape('Century%20%32%31%20%28Boggs%20Nakamura%29'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Silver',
                                 '',
                                 '',
                                 '',
                                 unescape('JLC%20Associates%2C%20Inc%2E'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Silver',
                                 '',
                                 '',
                                 '',
                                 unescape('Plum%20District'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Silver',
                                 '',
                                 '',
                                 '',
                                 unescape('Ball%20Park%20Pizza'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Silver',
                                 '',
                                 '',
                                 '',
                                 unescape('Amore%20Pizza'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Silver',
                                 '',
                                 '',
                                 '',
                                 unescape('Bats%34sale%2Ecom'),
                                 '',
                                 'Bats4sale.com',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Brian%20Egan%20Photography'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Dave%20Bang'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Zazen'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Gibson%20Dunn'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('SOC%20Cardiology%20Group'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('MobiSurg'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Darras%20Law'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Marina%20Hills%20Animal%20Hospital'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Rausch%20PT'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Chick%20Fil%20A'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Mission%20Viejo%20Motors%2C%20Inc%2E'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('LA%20County%20Fire%20Department%20Station%20%33%39'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Pacific%20Roofing%20Systems'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('PCM'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('YMCA%20%2D%20South%20Orange%20County'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('EZ%20Lettering'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Pretzel%20Crisps'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('American%20Auto%20Financing'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Winthrop%20Couchot%20Professional%20Corporation'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Performance%20Roofing%20Company'),
                                 '',
                                 '',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('ZigZag%20Inc%2E'),
                                 '',
                                 'www.zigzaginc.com',
                                 '');

  Sponsors[ns++]=new makeSponsor('Bronze',
                                 '',
                                 '',
                                 '',
                                 unescape('Travis%20and%20Sharon%20Wilson'),
                                 '',
                                 '',
                                 '');


  Divisions[nd++]=new makeDivision('Seniors',
                                   'Bob Fulton',
                                	'lnlljuniors@gmail.com',
                                   	'20110503',
                                   unescape('Prepare%20your%20player%20for%20the%20next%20level%20with%20the%20LNLL%20Seniors%20Division%2E%20District%20%35%35%20invited%20LNLL%20to%20join%20Seniors%20due%20to%20the%20quality%20of%20our%20program%2C%20the%20number%20of%20players%20in%20our%20league%2C%20and%20the%20competitiveness%20of%20LNLL%20teams%2E%20LNLL%20Seniors%20will%20play%20teams%20from%20other%20District%20%35%35%20Leagues%2E%20Seniors%20is%20OPEN%20to%20all%20League%20Age%20%31%35%20and%20%31%36%20year%20olds%20that%20live%20with%20in%20the%20LNLL%20approved%20borders%2E%20Players%20that%20have%20been%20grandfathered%20in%20to%20LNLL%20due%20to%20relocation%20are%20also%20welcome%2E%20Seniors%20Division%20is%20a%20great%20opportunity%20to%20challenge%20players%20to%20experience%20the%20next%20level%20of%20baseball%20as%20a%20member%20of%20LNLL%2E%20From%20field%20dimension%20size%2C%20to%20competing%20against%20players%20from%20other%20leagues%2C%20while%20working%20with%20some%20of%20the%20most%20committed%20managers%20and%20coaches%2E'),
                                   '15 & 16 year olds',
                                   '-GtTs-');

  Divisions[nd++]=new makeDivision('Juniors',
                                  'Bob Fulton',
                                	'lnlljuniors@gmail.com',
                                   '20110503',
                                   unescape('Prepare%20your%20player%20for%20the%20next%20level%20with%20the%20LNLL%20Juniors%20Division%2E%20LNLL%20Juniors%20offers%20a%20quality%2C%20competitive%20program%20for%20%31%33%20and%20%31%34%20year%20olds%20with%20LNLL%20having%20the%20most%20number%20of%20Juniors%20teams%20and%20players%20in%20District%20%35%35%2E%20Junior%20tryouts%20are%20OPEN%20to%20all%20League%20Age%20%31%33%20and%20%31%34%20year%20olds%20that%20live%20with%20in%20the%20LNLL%20approved%20borders%2E%20Players%20that%20have%20been%20grandfathered%20in%20to%20LNLL%20due%20to%20relocation%20are%20also%20welcome%2E%20Juniors%20Division%20is%20a%20great%20opportunity%20to%20challenge%20players%20to%20experience%20the%20next%20level%20of%20baseball%20as%20a%20member%20of%20LNLL%2E%20All%20Juniors%20teams%20will%20compete%20in%20the%20District%20%35%35%20TOC%20Tournament%20in%20June%20against%20all%20other%20leagues%20within%20District%20%35%35%2E%20%20From%20field%20dimension%20size%2C%20to%20competing%20against%20players%20from%20other%20leagues%2C%20while%20working%20with%20some%20of%20the%20most%20committed%20managers%20and%20coaches%2C%20LNLL%20Juniors%20program%20has%20a%20lot%20to%20offer%20your%20player%2E'),
                                   '13 & 14 year olds',
                                   '-GtTs-');

  Divisions[nd++]=new makeDivision('Majors',
                                   'Ira Hermann',
                                    'irahermann@aol.com',
                                   '20110501',
                                   unescape('The%20Major%20League%20is%20the%20top%20of%20the%20heap%20in%20Little%20League%20Baseball%2E%20%20In%20the%20Majors%2C%20players%20ages%20%31%31%20%26%20%31%32%20try%20out%20and%20are%20evaluated%20and%20drafted%20according%20to%20the%20Official%20Rules%20of%20Little%20League%20Baseball%20of%20Williamsport%2C%20PA%2E%20%20At%20the%20Major%20league%20level%20the%20focus%20is%20on%20mastering%20the%20fundamentals%20of%20the%20game%2C%20as%20well%20as%20developing%20advanced%20skills%20and%20strategies%20of%20the%20game%20in%20a%20competitive%20environment%20and%20to%20prepare%20players%20to%20move%20on%20to%20the%20next%20level%20of%20play%20including%20Little%20League%27s%20own%20Junior%20Division%2E'),
                                   '11 & 12 year olds',
                                   '-QtBs-');

  Divisions[nd++]=new makeDivision('AAA',
                                    'Todd Gallina',
                                    'gallina@gmail.com',
                                   '20110429',
                                   unescape('The%20Triple%2DA%20division%20serves%20as%20the%20final%20%22minor%20league%22%20division%20for%20the%20next%20step%20into%20Majors%2E%20%20The%20Triple%2DA%20level%20is%20designed%20to%20give%20players%20the%20ability%20to%20play%20in%20a%20Major%20League%20atmosphere%20while%20playing%20at%20their%20appropriate%20skill%20level%2E%20The%20Triple%2DA%20focus%20is%20on%20continuing%20the%20development%20of%20the%20fundamentals%20of%20the%20game%20while%20introducing%20game%20strategy%20and%20competition%20to%20the%20game%2E'),
                                   '9 - 12 year olds',
                                   '-HtIs-');

  Divisions[nd++]=new makeDivision('AA',
                                  	'Bito Borovinsky',
                                	'Bito.Borovinsky@marsh.com',
                                   '20110429',
                                   unescape('At%20the%20Double%2DA%20level%2C%20the%20rules%20are%20basically%20the%20same%20as%20Single%2DA%2C%20with%20one%20notable%20difference%2C%20player%20pitching%20is%20introduced%20into%20the%20game%2E%20%20This%20gives%20both%20the%20batters%20and%20the%20pitchers%20the%20first%20real%20opportunity%20to%20learn%20how%20to%20play%20the%20game%20in%20a%20competitive%20environment%2E%20%20At%20this%20level%2C%20the%20focus%20is%20on%20the%20continuation%20of%20learning%20the%20fundamentals%20of%20the%20game%2C%20including%20offensive%20and%20defensive%20positioning%2E'),
                                   '8 - 11 year olds',
                                   '-MtRs-');

  Divisions[nd++]=new makeDivision('A',
                                   'Steve Jenner',
                                	'sajenner@cox.net',
                                   '20110520',
                                   unescape('The%20Single%2DA%20division%20takes%20players%20that%20have%20graduated%20from%20the%20Coach%2DPitch%20level%20and%20puts%20them%20on%20the%20playing%20field%20against%20the%20pitching%20machine%2E%20Single%2DA%20serves%20as%20an%20introduction%20into%20competitive%20baseball%2E%20%20The%20Single%2DA%20level%20is%20designed%20to%20give%20players%20the%20skills%20required%20to%20be%20prepared%20to%20play%20in%20a%20player%2Dpitch%20level%2C%20while%20developing%20a%20introductory%20level%20of%20strategy%2E'),
                                   '7 - 9 year olds',
                                   '-StBs-');

  Divisions[nd++]=new makeDivision('Coach Pitch',
                                  'Bill Stairs',
                                	'wcstairs@aol.com',
                                   '20110606',
                                   unescape('The%20Coach%2DPitch%20division%20is%20a%20step%20up%20from%20the%20T%2DBall%20level%20of%20play%2E%20It%20introduces%20players%20to%20actual%20pitching%2E%20%20There%20are%20major%20differences%20at%20this%20level%20that%20separates%20it%20from%20T%2DBall%2E%20%20Essentially%2C%20the%20game%20is%20played%20with%20regulation%20rules%20with%20a%20couple%20of%20notable%20differences%2E%20Instead%20of%20players%20pitching%2C%20coaches%20pitch%2E%20This%20gives%20children%20the%20opportunity%20to%20learn%20to%20hit%20a%20pitched%20ball%20without%20fear%20of%20being%20hit%2E%20%20Balls%20and%20strikes%20are%20not%20called%2C%20however%20a%20player%20may%20strike%20out%20swinging%2E%20%20The%20focus%20of%20Coach%2DPitch%20is%20to%20learn%20the%20fundamentals%20of%20the%20game%20in%20a%20format%20that%20stresses%20learning%20the%20physical%20skills%20necessary%20to%20advance%20to%20the%20next%20level%20of%20play%2C%20Single%2DA%2E'),
                                   '6 - 7 year olds',
                                   '-BtJs-');

  Divisions[nd++]=new makeDivision('T-Ball',
                                   'Larry Wagner',
                                	'larrywagner4@gmail.com',
                                   '20110606',
                                   unescape('T%2DBall%20is%20the%20entry%20level%20to%20the%20game%20of%20baseball%20and%20softball%20for%20young%20players%2C%20usually%20five%20to%20seven%20years%20old%2E%20%20Members%20of%20two%20teams%20take%20turns%20hitting%20a%20ball%20off%20a%20batting%20tee%20set%20on%20home%20plate%2E%20%20Batters%20try%20to%20get%20on%20base%20and%20advance%20to%20home%2E%20Fielders%20try%20to%20prevent%20that%20from%20happening%2E%20%20The%20elimination%20of%20pitching%20allows%20children%20to%20participate%20without%20the%20fear%20of%20being%20hit%20by%20a%20pitched%20ball%2E%20Tee%20ball%20develops%20the%20primary%20baseball%20skills%20of%20hitting%2C%20running%2C%20fielding%20and%20throwing%2E%20%20The%20players%20gain%20an%20understanding%20of%20the%20fundamental%20rules%20of%20baseball%2C%20and%20since%20score%20is%20not%20kept%2C%20there%20are%20no%20losers%20in%20T%2DBall%2C%20only%20winners%21'),
                                   '5 - 6 year olds',
                                   '-CtJs-');

//............(End Section INI)
//(The code below this line may be overwritten by the contents of a file named "C:\lnlladmin\LNLLConfig.js2".)
  this.BoardMembers=BoardMembers;
  this.Divisions=Divisions;
  this.Sponsors=Sponsors;
  return this;
}

// Make a Board Member object.
// ___________________________________________________________________________
function makeBoardMember(Title,Name,Email) {

  this.Title=Title;
  this.Name=Name;
  this.Email=Email;
  return this;
}

// Make a Sponsor object.
// ___________________________________________________________________________
function makeSponsor(Level,Division,Team,Contact,Company,Phone,Link,Email) {

  this.Level=Level;
  this.Division=Division;
  this.Team=Team;
  this.Contact=Contact;
  this.Company=Company;
  this.Phone=Phone;
  this.Link=Link;
  this.Email=Email;
  return this;
}

// Make a Division object and add Division Teams.
// ___________________________________________________________________________
function makeDivision(Name,Commissioner,Email,Lastregularday,Comments,Ages,Version) {
  var Checkteam=null;
  var Checkname=Name;
  var Teams=new Array();
  var nt=0;

  this.Name=Name;
  this.Commissioner=Commissioner;
  this.Email=Email;
  this.Lastregularday=Lastregularday;
  this.Comments=Comments;
  this.Ages=Ages;
  this.Version=Version;

//(The code above this line may be overwritten by the contents of a file named "C:\lnlladmin\LNLLConfig.js2".)
//............(End Section 2)
  Checkteam=new addTeam(Checkname,
                       'Seniors',
                       'All',
                       'Laguna Niguel',
                       'Pete Stoeffler',
                       'coachpete24@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Juniors',
                       'All',
                       'Cal State Fullerton',
                       'Joe LoBasso',
                       'lobasso@dslextreme.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Juniors',
                       'All',
                       'Stanford',
                       'Ken Morgan',
                       'kem@morganskenderian.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Juniors',
                       'All',
                       'UCI',
                       'Ken Vause',
                       '1smrtazz@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Majors',
                       'All',
                       'Angels',
                       'Mark Williams',
                       'markwilliams4@hotmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Majors',
                       'All',
                       'Cardinals',
                       'Todd Gallina',
                       'gallina@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Majors',
                       'All',
                       'Dodgers',
                       'Travis Rodgers',
                       'travissrodgers@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Majors',
                       'All',
                       'Rangers',
                       'Ron Hoopes',
                       'ron@1cd.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Majors',
                       'All',
                       'Red Sox',
                       'Kevin Koen',
                       'kkoen4@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Majors',
                       'All',
                       'Yankees',
                       'Dave Trottman',
                       'trottmansrus@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AAA',
                       'All',
                       'Angels',
                       'John Zwahlen',
                       'jzwahlen@ur.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AAA',
                       'All',
                       'Athletics',
                       'Larry Wagner',
                       'larrywagner4@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AAA',
                       'All',
                       'Cardinals',
                       'John Healey',
                       'jchealey@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AAA',
                       'All',
                       'Dodgers',
                       'Jim Heinrich',
                       'jsurfheinrich@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AAA',
                       'All',
                       'Giants',
                       'Fred Ferketic',
                       'crownpumping1@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AAA',
                       'All',
                       'Phillies',
                       'George Ferguson',
                       'therfergusons1@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AAA',
                       'All',
                       'Rangers',
                       'Bill Dougherty',
                       'bdougherty6870@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AAA',
                       'All',
                       'Yankees',
                       'Joe Philbin',
                       'philbin.family@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AA',
                       'All',
                       'Angels',
                       'Danny Haynes',
                       'Danny.Haynes@gmacrescap.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AA',
                       'All',
                       'Athletics',
                       'Kevin Berry',
                       'kberry@brocade.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AA',
                       'All',
                       'Dodgers',
                       'Sam Auriemma',
                       'usc6@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AA',
                       'All',
                       'Giants',
                       'Matt Dickson',
                       'ninermatt@sbcglobal.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AA',
                       'All',
                       'Phillies',
                       'Brian Pike',
                       'brian@pikedesign.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AA',
                       'All',
                       'Rangers',
                       'Steve Mayo',
                       'spmayo@parker.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'AA',
                       'All',
                       'Yankees',
                       'Eric Anderson',
                       'eanderson@mfs.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'A',
                       'All',
                       'Angels',
                       'Drew Votroubek',
                       'drew.votroubek@fedex.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'A',
                       'All',
                       'Athletics',
                       'David Mann',
                       'davidpmann@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'A',
                       'All',
                       'Cardinals',
                       'Steve Shaver',
                       'spsosprey@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'A',
                       'All',
                       'Dodgers',
                       'Wade Ison',
                       'wison@cisco.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'A',
                       'All',
                       'Giants',
                       'Mike Rodgers',
                       'devinchasetwn@aol.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'A',
                       'All',
                       'Rangers',
                       'Brad Bolter',
                       'bradbolter@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'A',
                       'All',
                       'Red Sox',
                       'Dan Anderson',
                       'socaldanderson@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Coach Pitch',
                       'All',
                       'Angels',
                       'Felix Martinez',
                       'fmartinez23@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Coach Pitch',
                       'All',
                       'Athletics',
                       'Osvaldo Cruz',
                       'Osvaldocruz4@yahoo.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Coach Pitch',
                       'All',
                       'Cardinals',
                       'Rob Newkirk',
                       'Newk888@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Coach Pitch',
                       'All',
                       'Dodgers',
                       'Josh Stabile',
                       'josh@iconmotoring.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Coach Pitch',
                       'All',
                       'Indians',
                       'Trey Thompson',
                       'andrea.trey@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'Coach Pitch',
                       'All',
                       'Nationals',
                       'Richard Golubow',
                       'rgolubow@winthropcouchot.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;
  
  Checkteam=new addTeam(Checkname,
                       'Coach Pitch',
                       'All',
                       'Padres',
                       'Rocky Murray',
                       'rkmurray4@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;
  
  Checkteam=new addTeam(Checkname,
                       'Coach Pitch',
                       'All',
                       'Rangers',
                       'Brad Ward',
                       'bradward@ymail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;
  
  Checkteam=new addTeam(Checkname,
                       'Coach Pitch',
                       'All',
                       'Red Sox',
                       'Ken Kalfin',
                       'kkalfin@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;
  
   Checkteam=new addTeam(Checkname,
                       'Coach Pitch',
                       'All',
                       'Yankees',
                       'Jim Nielsen',
                       'jim.nielsen@mac.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'T-Ball',
                       'All',
                       'Angels',
                       'Liz Ludwig',
                       'lizanneludwig@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'T-Ball',
                       'All',
                       'Athletics',
                       'Ira Hermann',
                       'irahermann@aol.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'T-Ball',
                       'All',
                       'Cardinals',
                       'Alan Perrego',
                       'aperrego@lbschools.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'T-Ball',
                       'All',
                       'Dodgers',
                       'Joshua Bateson',
                       'jjbbateson@yahoo.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'T-Ball',
                       'All',
                       'Giants',
                       'Bruce Goodfield',
                       'brucegoodfield@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'T-Ball',
                       'All',
                       'Indians',
                       'Brian Fischer',
                       'brianfischer@cox.net',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'T-Ball',
                       'All',
                       'Nationals',
                       'Eli Marcus',
                       'eli.marcus@cbsinteractive.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'T-Ball',
                       'All',
                       'Padres',
                       'Paul Buie',
                       'pauldbuie@gmail.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'T-Ball',
                       'All',
                       'Rangers',
                       'Roger Swift',
                       'roger.swift@yahoo.com',
                       '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

  Checkteam=new addTeam(Checkname,
                       'T-Ball',
                       'All',
                       'Red Sox',
                       'Tim Hoferer',
                       'calgoldrealty@yahoo.com',
                    '');
  if(Checkteam.Key!='') Teams[nt++]=Checkteam;

//............(End Section INI)
//(The code below this line may be overwritten by the contents of a file named "C:\lnlladmin\LNLLConfig.js3".)
  this.Teams=Teams;
  return this;
}

// Make a Team object with team related information.
// ___________________________________________________________________________
function addTeam(Checkname,Division,League,Name,Manager,Email,Link) {
  var nt=0;

// Define team only for the division passed in.
  if(Checkname != Division) {
    this.Key='';
    return this;
  }

  this.Key=1;
  this.Division=Division;
  this.League=League;
  this.Name=Name;
  this.Manager=Manager;
  this.Email=Email;
  this.Link=Link;

// Record info added later.
  this.Won=0;
  this.Loss=0;
  this.Tie=0;
  this.Total=0;
  this.Pct=0;
  this.GB=0;
  this.Steak='-';
  this.Overall='0-0';
  return this;
}

// Return set of teams given Divsion and optional League.
// ___________________________________________________________________________
function getTeams(Division,League) {
  var nt=0;
  var Teams=new Array();

// Gather teams.
  for (var i=0; i<lnllconfig.Divisions.length; i++) {
    if(lnllconfig.Divisions[i].Name==Division) {
      for (var j=0; j<lnllconfig.Divisions[i].Teams.length; j++) {
        if(League=='' || lnllconfig.Divisions[i].Teams[j].League==League) {
          Teams[nt++]=lnllconfig.Divisions[i].Teams[j];
        }
      }
      break;
    }
  }

  return Teams;
}

// Get Sponsors for this division sorted by Team.
// ___________________________________________________________________________
function getSponsors(Level,Division,Team) {
  var Sponsors=new Array();
  var ns=0;

// Look through all Sponsors and grab those in matching input criteria.
  for(var i=0; i<lnllconfig.Sponsors.length; i++) {

// Level specified
    if(Level && Level.length>0) {
      if(lnllconfig.Sponsors[i].Level==Level) {
// Level and Division specified
        if(Division && Division.length>0) {
          if(lnllconfig.Sponsors[i].Division==Division) {
// Level, Division and Team specified
            if(Team && Team.length>0) {
              if(lnllconfig.Sponsors[i].Team==Team)
                Sponsors[ns++]=lnllconfig.Sponsors[i];
            }
            else Sponsors[ns++]=lnllconfig.Sponsors[i];
          }
        }
// Level and Team specified
        else if(Team && Team.length>0) {
          if(lnllconfig.Sponsors[i].Team==Team)
            Sponsors[ns++]=lnllconfig.Sponsors[i];
        }
        else Sponsors[ns++]=lnllconfig.Sponsors[i];
      }
    }
// Division specified
    else if(Division && Division.length>0) {
      if(lnllconfig.Sponsors[i].Division==Division) {
// Division and Team specified
        if(Team && Team.length>0) {
          if(lnllconfig.Sponsors[i].Team==Team)
            Sponsors[ns++]=lnllconfig.Sponsors[i];
        }
        else Sponsors[ns++]=lnllconfig.Sponsors[i];
      }
    }
// Team specified
    else if(Team && Team.length>0) {
      if(lnllconfig.Sponsors[i].Team==Team)
        Sponsors[ns++]=lnllconfig.Sponsors[i];
    }
// Nothing specified, gather all sponsors
    else Sponsors[ns++]=lnllconfig.Sponsors[i];
  }

// Sort Sponsors by Level if specified otherwise Team. 
  if(Level && Level.length>0)
    Sponsors.sort(sortByContact);
  else
    Sponsors.sort(sortByTeam);

  this.Sponsors=Sponsors;
  return this;
}

// Sort routine for Sponsors array. 
// ___________________________________________________________________________
function sortByTeam(a,b) {
  var x = a.Team;
  var y = b.Team;
  return ((x<y) ? -1 : ((x>y) ? 1 : 0));
}

// Sort routine for Sponsors array.
// ___________________________________________________________________________
function sortByContact(a,b) {
  var x = a.Contact;
  var y = b.Contact;
  return ((x<y) ? -1 : ((x>y) ? 1 : 0));
}

// Parse current URL to get parameters
// ___________________________________________________________________________
function getURLParameters()
{
  var url_string = "";
  var val_string1 = "";
  var val_string2 = "";

  url_string = window.location.toString();
  if(url_string.indexOf('?') == -1) return;

  val_string1=url_string.substring(url_string.indexOf('?')+1);
  val_string2=val_string1;
  if(val_string2.indexOf('#')>0) val_string2=val_string1.substring(0,val_string1.indexOf('#'));

  uDivision=unescape(pairValue(val_string2,'division'));
  uTeam=unescape(pairValue(val_string2,'team'));
  uLeague=unescape(pairValue(val_string2,'league'));
  uDate1=unescape(pairValue(val_string2,'date1'));
  uDate2=unescape(pairValue(val_string2,'date2'));
  uOther=unescape(pairValue(val_string2,'other'));
}

// Given Name=Value pairs in ampersand delimited string, get Value give Name.
// ___________________________________________________________________________
function pairValue(instring,param)
{
  var begin,end;

  if(instring.length>1) {
    if(instring.indexOf(param)==-1) return'';
    begin=instring.indexOf(param) + param.length+1;
    end=instring.indexOf('&',begin);
    if(end==(-1)) end=instring.length;
    return(instring.substring(begin,end));
  }
  else return('');
}

// Return current day in YYYYMMDD format.
// ___________________________________________________________________________
function getDay() {
  var today=new Date();
  var mathday=0;
  var mathmonth=0;
  var mathyear=0;
  var calday='';
  var calmonth='';
  var calyear='';
  mathday=today.getDate();
  calday=mathday.toString();
  if(mathday < 10) calday='0' + calday;
  mathmonth=(today.getMonth()+1);
  calmonth=mathmonth.toString();
  if(mathmonth < 10) calmonth='0' + calmonth;
  mathyear=today.getYear();
  if(mathyear < 1000) mathyear=mathyear + 1900;
  calyear=mathyear.toString();
  return calyear+calmonth+calday;
}

// Return current month in YYYYMM format.
// ___________________________________________________________________________
function getMonth() {
  var today=new Date();
  var mathmonth=0;
  var mathyear=0;
  var calmonth='';
  var calyear='';
  mathmonth=(today.getMonth()+1);
  calmonth=mathmonth.toString();
  if(mathmonth < 10) calmonth='0' + calmonth;
  mathyear=today.getYear();
  if(mathyear < 1000) mathyear=mathyear + 1900;
  calyear=mathyear.toString();
  return calyear+calmonth;
}

// Set defaults on date pulldowns given 2 dates in yyyymm format.
// ___________________________________________________________________________
function setDate(frm_name,date1) {
  var yy=0;
  var mm=0;
  var dd=0;
  var form=document.forms[frm_name]
  if(form) {
    if(date1 !='') {
      if(date1.indexOf('/')==-1 ) {
        yy=date1.substr(0,4);
        mm=date1.substr(4,2);
        if(form.Month1) form.Month1.selectedIndex=mm - 1;
        if(form.Year1)  {
          if(form.Year1.type.indexOf('select') > -1)  {
            form.Year1.selectedIndex=yy - form.Year1.options[0].value;
          }
          else form.Year1.value=yy;
        }
        if(date1.length==8) {
          dd=date1.substr(6,2);
          if(form.Day1)  form.Day1.selectedIndex=dd - 1;
        }
      }
    }
  }
}

// Make sure a selected date is valid.
// ___________________________________________________________________________
function checkValidDate(mm,dd,yy) {
  datevalue=dd + mm + yy;
     
  if(datevalue.length > 0 && datevalue.length < 9) {
    alert('Invalid Date Length');
    return false;
  }
  if((mm=='apr' || mm=='jun' || mm=='sep' || mm=='nov') && dd > 30) {
    alert(mm + ' has only 30 days');
    return false;
  } else {
    if(dd > 31) {
      alert(mm + ' has only 31 days');
      return false;
    }
  }
  if(mm=='feb') {
    if(yy  > 0 && dd > 28) {
      alert('February of ' + yy + ' has only 28 days');
      return false;
    } else {
      if(dd > 29) {
        alert('February of ' + yy + ' has only 29 days');
        return false;
      }
    }
  }
  return true;
}

// Return mm/dd/yyyy format given yyyymmdd format
// ___________________________________________________________________________
function niceDate(day) {
  var yy=0;
  var mm=0;
  var dd=0;
  if(day!='') {
    if(day.indexOf('/')==-1 ) {
      yy=day.substr(0,4);
      mm=day.substr(4,2);
      dd=day.substr(6,2);
      return mm+'/'+dd+'/'+yy;
    }
    else {
      return day;
    }
  }
  return '';
}

// Return integer day of week given YYYYMMDD string.
// ___________________________________________________________________________
function getDOW(datstr) {
  var tmpdate = new Date(niceDate(datstr));
  var intDay = tmpdate.getDay();
  var DayArray = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday',
                           'Thursday', 'Friday', 'Saturday');
  return DayArray[intDay];
}

// Return Monday date given any day this week..
// ___________________________________________________________________________
function getPreviousMonday(datstr) {
  var tmpdate1 = new Date(niceDate(datstr));
  var intDay = tmpdate1.getDay();
  if(intDay==0) intDay=7;
  var delta = intDay - 1;
  var tmpdate2 = new Date(tmpdate1.getTime()-(delta * 86400000));
  var yy = tmpdate2.getYear();
  var mm = tmpdate2.getMonth() + 1;
  var dd = tmpdate2.getDate();

  if(yy<1000) yy+=1900;
  if(mm<10)   mm='0'+mm;
  if(dd<10)   dd='0'+dd;

  return (yy+''+mm+''+dd);
}

// Return YYYYMMDD of last Monday given Saturday
// ___________________________________________________________________________
function mondayDate(datstr) {
  var tmpdate1 = new Date(niceDate(datstr));
  var tmpdate2 = new Date(tmpdate1.getTime()-432000000);
  var yy = tmpdate2.getYear();
  var mm = tmpdate2.getMonth()+1;
  var dd = tmpdate2.getDate();

  if(yy<1000) yy+=1900;
  if(mm<10)   mm='0'+mm;
  if(dd<10)   dd='0'+dd;

  return (yy+''+mm+''+dd);
}

// Return YYYYMMDD of next Saturday given Monday
// ___________________________________________________________________________
function saturdayDate(datstr) {
  var tmpdate1 = new Date(niceDate(datstr));
  var tmpdate2 = new Date(tmpdate1.getTime()+432000000);
  var yy = tmpdate2.getYear();
  var mm = tmpdate2.getMonth()+1;
  var dd = tmpdate2.getDate();

  if(yy<1000) yy+=1900;
  if(mm<10)   mm='0'+mm;
  if(dd<10)   dd='0'+dd;

  return (yy+''+mm+''+dd);
}

// Return YYYYMMDD of date number of weeks from another date.
// ___________________________________________________________________________
function weekDate(datstr,weeksfrom) {
  var tmpdate1 = new Date(niceDate(datstr));
  var tmpdate2 = new Date(tmpdate1.getTime()+(weeksfrom * 604800000));
  var yy = tmpdate2.getYear();
  var mm = tmpdate2.getMonth()+1;
  var dd = tmpdate2.getDate();

  if(yy<1000) yy+=1900;
  if(mm<10)   mm='0'+mm;
  if(dd<10)   dd='0'+dd;

  return (yy+''+mm+''+dd);
}

// Return YYYYMMDD after adding a number of days to it.
// ___________________________________________________________________________
function addDays(datstr,numday) {
  if(numday==0) return datstr;
  var tmpdate1 = new Date(niceDate(datstr));
  var tmpdate2 = new Date(tmpdate1.getTime()+(numday*86400000));
  var yy = tmpdate2.getYear();
  var mm = tmpdate2.getMonth()+1;
  var dd = tmpdate2.getDate();

  if(yy<1000) yy+=1900;
  if(mm<10)   mm='0'+mm;
  if(dd<10)   dd='0'+dd;

  return (yy+''+mm+''+dd);
}

// Days between 2 dates in YYYYMMDD format.
// ___________________________________________________________________________
function diffDate(datstr1,datstr2) {
  var tmpdate1 = new Date(niceDate(datstr1));
  var tmpdate2 = new Date(niceDate(datstr2));
  var timediff = tmpdate1.getTime()-tmpdate2.getTime();

  if(timediff<0) timediff = -timediff;
  var daydiff = timediff/86400000;

  return daydiff;
}

// Return alpha month and day string given YYYYMMDD string.
// ___________________________________________________________________________
function monthDate(datstr) {
  var MonthArray = new Array('Jan', 'Feb', 'Mar',
                             'Apr', 'May', 'June', 'July',
                             'Aug', 'Sep', 'Oct',
                             'Nov', 'Dec');
  var mm=datstr.substr(4,2);
  var dd=datstr.substr(6,2);
  var mc=parseInt(mm,10)-1;

  return MonthArray[mc]+' '+parseInt(dd,10);
}

// lTrim(string) : Returns a copy of a string without leading spaces.
// ___________________________________________________________________________
function lTrim(str) {
   var whitespace = new String(' \t\n\r');
   var s = new String(str);

// We have a string with leading blank(s)...
   if (whitespace.indexOf(s.charAt(0)) != -1) {
     var j=0, i = s.length;

// Iterate from the far left of string until we don't have any more whitespace.
     while (j < i && whitespace.indexOf(s.charAt(j)) != -1) j++;

// Get the substring from the first non-whitespace character to the end of
// the string... 
     s = s.substring(j, i);
   }
   return s;
}

// tTrim(string) : Returns a copy of a string without trailing spaces.
// ___________________________________________________________________________
function tTrim(str) {
// We don't want to trip JUST spaces, but also tabs, line feeds, etc.
// Add anything else you want to trim here in Whitespace
   var whitespace = new String(' \t\n\r');
   var s = new String(str);

// We have a string with trailing blank(s)...
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {

// Get length of string
      var i = s.length - 1;

// Iterate from the far right until we don't have any more whitespace.
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) i--;

// Get the substring from the front of the string to where the last
// non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}

// ltTrim(string) : Returns a copy of a string w/o leading or trailing spaces
// ___________________________________________________________________________
function ltTrim(str) {
   return tTrim(lTrim(str));
}
// stringReverse(string) : Returns a copy of a string with characters reversed
// ___________________________________________________________________________
function stringReverse(str) {
  var s = '';
  var i = str.length;
  while (i>0) {
    s += str.substring(i-1,i);
    i--;
  }
  return s;
}

