// *****************************************************************************
//      Simple Calendar Widget - Cross-Browser Javascript pop-up calendar.
//
//   Copyright (C) 2005-2007  Anthony Garrett
//
//   This library is free software; you can redistribute it and/or
//   modify it under the terms of the GNU Lesser General Public
//   License as published by the Free Software Foundation; either
//   version 2.1 of the License, or (at your option) any later version.
//
//   This library is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//   Lesser General Public License for more details.
//
//   You should have received a copy of the GNU Lesser General Public
//   License along with this library; if not, it is available at
//   the GNU web site (http://www.gnu.org/) or by writing to the
//   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
//   Boston, MA  02110-1301  USA
//
// *****************************************************************************
//

// ************************************
// Start of Simple Calendar Widget Code
// ************************************

// This date is used throughout to determine today's date.

    var botDateNow = new Date(Date.parse(new Date().toDateString()));

//******************************************************************************
//------------------------------------------------------------------------------
// Customisation section
//------------------------------------------------------------------------------
//******************************************************************************

    var botBaseYear        = 2010;

    var botDropDownYears   = 1;

    var botLanguage;

    function botSetDefaultLanguage()
        {try
            {botSetLanguage();}
         catch (exception)
            {// Deutsch
             botToday               = 'Heute:';
             botClear               = 'Clear';
             botDrag                = 'click here to drag';
             botArrMonthNames       = ['Jan','Feb','Mar','Apr','Mai','Jun',
                                       'Jul','Aug','Sep','Okt','Nov','Dez'];
             botArrWeekInits        = ['So','Mo','Di','Mi','Do','Fr','Sa'];
             botInvalidDateMsg      = 'Das eigetragene Datum ist ungültig.\n';
             botOutOfRangeMsg       = 'Das eigetragene Datum ist ausserhalb des möglichen Zeitraums.';
             botDoesNotExistMsg     = 'Das eigetragene Datum existiert nicht.';
             botInvalidAlert        = ['Ungültiges Datum (',') ignoriert.'];
             botDateDisablingError  = ['Fehler ',' ist kein Datum.'];
             botRangeDisablingError = ['Fehler ',
                                       ' should consist of two elements.'];
            }
        };

    var botWeekStart       =    1;

    var botWeekNumberDisplay    = false;

    var botWeekNumberBaseDay    = 4;

    var botShowInvalidDateMsg       = false,
        botShowOutOfRangeMsg        = false,
        botShowDoesNotExistMsg      = false,
        botShowInvalidAlert         = false,
        botShowDateDisablingError   = false,
        botShowRangeDisablingError  = false;

    var botArrDelimiters   = ['/','-','.',',',' '];

    var botDateDisplayFormat = 'dd-mm-yy';     // e.g. 'MMM-DD-YYYY' for the US

    var botDateOutputFormat  = 'DD.MM.YYYY'; // e.g. 'MMM-DD-YYYY' for the US

    var botZindex          = 1;

    var botBlnStrict       = false;

    var botClearButton     = true;

    var botAutoPosition    = true;

    var botEnabledDay      = [true, true, true, true, true, true, true,
                              true, true, true, true, true, true, true,
                              true, true, true, true, true, true, true,
                              true, true, true, true, true, true, true,
                              true, true, true, true, true, true, true,
                              true, true, true, true, true, true, true];

    var botDisabledDates   = new Array();

    botDisabledDates[1] = [new Date(2011,0,1),new Date(2011,0,22)];
    botDisabledDates[2] = [new Date(2011,0,23),new Date(2011,1,17)];
    botDisabledDates[3] = [new Date(2011,2,1),new Date(2011,2,8)];
    botDisabledDates[4] = [new Date(2011,2,17),new Date(2011,2,28)];
    botDisabledDates[5] = [new Date(2011,4,1),new Date(2011,7,31)];
    botDisabledDates[6] = new Date(2011,0,1);


    var botActiveToday = false;
    var botOutOfMonthDisable = false;
    var botOutOfMonthHide    = true;
    var botOutOfRangeDisable = true;
    var botFormatTodayCell = true;
    var botTodayCellBorderColour = 'red';
    var botAllowDrag = false;
    var botClickToHide = true;


    document.writeln(
        '<style type="text/css">'                                       +
            '.bot           {padding:1px;vertical-align:middle;}'       +
            'iframe.bot     {position:absolute;z-index:' + botZindex    +
                            ';top:0px;left:0px;visibility:hidden;'      +
                            'width:1px;height:1px;}'                    +
            'table.bot      {padding:0px;visibility:hidden;'            +
                            'position:absolute;cursor:default;'         +
                            'width:200px;top:0px;left:0px;'             +
                            'z-index:' + (botZindex+1)                  +
                            ';text-align:center;}'                      +
        '</style>'  );

    document.writeln(
        '<style type="text/css">'                                       +
            '/* IMPORTANT:  The SCW calendar script requires all '      +
            '               the classes defined here.'                  +
            '*/'                                                        +
            'table.bot      {padding:       1px;'                       +
                            'vertical-align:middle;'                    +
                            'border:        ridge 2px;'                 +
                            'font-size:     10pt;'                      +
                            'font-family:   ' +
                                   'Verdana,Arial,Helvetica,Sans-Serif;'+
                            'font-weight:   bold;}'                     +
            'td.botDrag,'                                               +
            'td.botHead                 {padding:       0px 0px;'       +
                                        'text-align:    center;}'       +
            'td.botDrag                 {font-size:     8pt;}'          +
            'select.botHead             {margin:        3px 1px;'       +
                                        'text-align:    center;}'       +
            'input.botHead              {height:        22px;'          +
                                        'width:         22px;'          +
                                        'vertical-align:middle;'        +
                                        'text-align:    center;'        +
                                        'margin:        2px 1px;'       +
                                        'font-weight:   bold;'          +
                                        'font-size:     10pt;'          +
                                        'font-family:   fixedSys;}'     +
            'td.botWeekNumberHead,'                                     +
            'td.botWeek                 {padding:       0px;'           +
                                        'text-align:    center;'        +
                                        'font-weight:   bold;}'         +
            'td.botNow,'                                                +
            'td.botNowHover,'                                           +
            'td.botNow:hover,'                                          +
            'td.botNowDisabled          {padding:       0px;'           +
                                        'text-align:    center;'        +
                                        'vertical-align:middle;'        +
                                        'font-weight:   normal;}'       +
            'table.botCells             {text-align:    right;'         +
                                        'font-size:     8pt;'           +
                                        'width:         96%;}'          +
            'td.botCells,'                  +
            'td.botCellsHover,'             +
            'td.botCells:hover,'            +
            'td.botCellsDisabled,'          +
            'td.botCellsExMonth,'           +
            'td.botCellsExMonthHover,'      +
            'td.botCellsExMonth:hover,'     +
            'td.botCellsExMonthDisabled,'   +
            'td.botCellsWeekend,'           +
            'td.botCellsWeekendHover,'      +
            'td.botCellsWeekend:hover,'     +
            'td.botCellsWeekendDisabled,'   +
            'td.botInputDate,'              +
            'td.botInputDateHover,'         +
            'td.botInputDate:hover,'        +
            'td.botInputDateDisabled,'      +
            'td.botWeekNo,'                 +
            'td.botWeeks                {padding:           3px;'       +
                                        'width:             16px;'      +
                                        'height:            16px;'      +
                                        'border-width:      1px;'       +
                                        'border-style:      solid;'     +
                                        'font-weight:       bold;'      +
                                        'vertical-align:    middle;}'   +
            '/* Blend the colours into your page here...    */'         +
            '/* Calendar background */'                                 +
            'table.bot                  {background-color:  #0040FF;}'  +
            '/* Drag Handle */'                                         +
            'td.botDrag                 {background-color:  #9999CC;'   +
                                        'color:             #CCCCFF;}'  +
            '/* Week number heading */'                                 +
            'td.botWeekNumberHead       {color:             #6666CC;}'  +
            '/* Week day headings */'                                   +
            'td.botWeek                 {color:             #CCCCCC;}'  +
            '/* Week numbers */'                                        +
            'td.botWeekNo               {background-color:  #776677;'   +
                                        'color:             #CCCCCC;}'  +
            '/* Enabled Days */'                                        +
            '/* Week Day */'                                            +
            'td.botCells                {background-color:  #A0FF00;'   +
                                        'color:             #000000;}'  +
            '/* Day matching the input date */'                         +
            'td.botInputDate            {background-color:  #CC9999;'   +
                                        'color:             #FF0000;}'  +
            '/* Weekend Day */'                                         +
            'td.botCellsWeekend         {background-color:  #A0FF00;'   +
                                        'color:             #CC6666;}'  +
            '/* Day outside the current month */'                       +
            'td.botCellsExMonth         {background-color:  #CCCCCC;'   +
                                        'color:             #666666;}'  +
            '/* Today selector */'                                      +
            'td.botNow                  {background-color:  #6666CC;'   +
                                        'color:             #FFFFFF;}'  +
            '/* Clear Button */'                                        +
            'td.botClear                {padding:           0px;}'      +
            'input.botClear             {padding:           0px;'       +
                                        'text-align:        center;'    +
                                        'font-size:         8pt;}'      +
            '/* MouseOver/Hover formatting '                            +
            '       If you want to "turn off" any of the formatting '   +
            '       then just set to the same as the standard format'   +
            '       above.'                                             +
            ' '                                                         +
            '       Note: The reason that the following are'            +
            '       implemented using both a class and a :hover'        +
            '       pseudoclass is because Opera handles the rendering' +
            '       involved in the class swap very poorly and IE6 '    +
            '       (and below) only implements pseudoclasses on the'   +
            '       anchor tag.'                                        +
            '*/'                                                        +
            '/* Active cells */'                                        +
            'td.botCells:hover,'                                        +
            'td.botCellsHover           {background-color:  #FFFF00;'   +
                                        'cursor:            pointer;'   +
                                        'color:             #000000;}'  +
            '/* Day matching the input date */'                         +
            'td.botInputDate:hover,'                                    +
            'td.botInputDateHover       {background-color:  #FFFF00;'   +
                                        'cursor:            pointer;'   +
                                        'color:             #000000;}'  +
            '/* Weekend cells */'                                       +
            'td.botCellsWeekend:hover,'                                 +
            'td.botCellsWeekendHover    {background-color:  #FFFF00;'   +
                                        'cursor:            pointer;'   +
                                        'color:             #000000;}'  +
            '/* Day outside the current month */'                       +
            'td.botCellsExMonth:hover,'                                 +
            'td.botCellsExMonthHover    {background-color:  #FFFF00;'   +
                                        'cursor:            pointer;'   +
                                        'color:             #000000;}'  +
            '/* Today selector */'                                      +
            'td.botNow:hover,'                                          +
            'td.botNowHover             {color:             #FFFF00;'   +
                                        'cursor:            pointer;'   +
                                        'font-weight:       bold;}'     +
            '/* Disabled cells */'                                      +
            '/* Week Day */'                                            +
            '/* Day matching the input date */'                         +
            'td.botInputDateDisabled    {background-color:  #999999;'   +
                                        'color:             #000000;}'  +
            'td.botCellsDisabled        {background-color:  #999999;'   +
                                        'color:             #000000;}'  +
            '/* Weekend Day */'                                         +
            'td.botCellsWeekendDisabled {background-color:  #999999;'   +
                                        'color:             #CC6666;}'  +
            '/* Day outside the current month */'                       +
            'td.botCellsExMonthDisabled {background-color:  #999999;'   +
                                        'color:             #666666;}'  +
            'td.botNowDisabled          {background-color:  #6666CC;'   +
                                        'color:             #FFFFFF;}'  +
        '</style>'
                    );

//******************************************************************************
//------------------------------------------------------------------------------
// End of customisation section
//------------------------------------------------------------------------------
//******************************************************************************

    var botTargetEle,
        botTriggerEle,
        botMonthSum            = 0,
        botBlnFullInputDate    = false,
        botPassEnabledDay      = new Array(),
        botSeedDate            = new Date(),
        botParmActiveToday     = true,
        botWeekStart           = botWeekStart%7,
        botToday,
        botClear,
        botDrag,
        botArrMonthNames,
        botArrWeekInits,
        botInvalidDateMsg,
        botOutOfRangeMsg,
        botDoesNotExistMsg,
        botInvalidAlert,
        botDateDisablingError,
        botRangeDisablingError;

    Date.prototype.botFormat =
        function(botFormat)
            {var charCount = 0,
                 codeChar  = '',
                 result    = '';

             for (var i=0;i<=botFormat.length;i++)
                {if (i<botFormat.length && botFormat.charAt(i)==codeChar)
                        {charCount++;
                        }
                 else   {switch (codeChar)
                            {case 'y': case 'Y':
                                result += (this.getFullYear()%Math.
                                            pow(10,charCount)).toString().
                                            botPadLeft(charCount);
                                break;
                             case 'm': case 'M':
                                result += (charCount<3)
                                            ?(this.getMonth()+1).
                                                toString().botPadLeft(charCount)
                                            :botArrMonthNames[this.getMonth()];
                                break;
                             case 'd': case 'D':

                                result += this.getDate().toString().
                                            botPadLeft(charCount);
                                break;
                             default:

                                while (charCount-- > 0) {result += codeChar;}
                            }

                         if (i<botFormat.length)
                            {// Store the character we have just worked on
                             codeChar  = botFormat.charAt(i);
                             charCount = 1;
                            }
                        }
                }
             return result;
            };

    String.prototype.botPadLeft =
        function(padToLength)
            {var result = '';
             for (var i=0;i<(padToLength - this.length);i++) {result += '0';}
             return (result + this);
            };

    Function.prototype.runsAfterSCW =
        function()  {var func = this,
                         args = new Array(arguments.length);

                     for (var i=0;i<args.length;++i) {args[i] = arguments[i];}

                     return function()
                        {for (var i=0;i<arguments.length;++i) {args[args.length] = arguments[i];}
                         return (args.shift()==botTriggerEle)?func.apply(this, args):null;
                        };
                    };

    function botID(id)
        {if (document.getElementById(id) || (!document.getElementById(id) && document.getElementsByName(id).length==0))
                {return document.getElementById(id);}
         else   {if (document.getElementsByName(id).length==1)
                       {return document.getElementsByName(id)[0];}
                 else   {if (document.getElementsByName(id).length>1)
                            {
                             alert( 'SCW' +
                                    ' \nCannot uniquely identify element named: ' + id +
                                    '.\nMore than one identical NAME attribute defined' +
                                    '.\nSolution: Assign the required element a unique ID attribute value.');
                            }
                        }
                }
        };

    var botNextActionReturn, botNextAction;

    function showCal(botEle,botSource) {botShow(botEle,botSource);};
    function botShow(botEle,botSource)
        {if (!botSource) {botSource = window.event;}

         if (botSource.tagName)
            {var botSourceEle = botSource;

             if (botID('botIE'))  {window.event.cancelBubble = true;}
             else {botSourceEle.parentNode.addEventListener('click',botStopPropagation,false);}
            }
         else
            {var botSourceEle = (botSource.target)
                                    ?botSource.target
                                    :botSource.srcElement;

             if (botSource.stopPropagation) {botSource.stopPropagation();}
             else                           {botSource.cancelBubble = true;}
            }

         botTriggerEle = botSourceEle;

         botParmActiveToday = true;

         for (var i=0;i<7;i++)
            {botPassEnabledDay[(i+7-botWeekStart)%7] = true;
             for (var j=2;j<arguments.length;j++)
                {if (arguments[j]==i)
                    {botPassEnabledDay[(i+7-botWeekStart)%7] = false;
                     if (botDateNow.getDay()==i) {botParmActiveToday = false;}
                    }
                }
            }

         botSeedDate = botDateNow;

         var botDateValue = '';

         if (botEle.value) {botDateValue = botEle.value.replace(/^\s+/,'').replace(/\s+$/,'');}
         else   {if (typeof botEle.value == 'undefined')
                    {var botChildNodes = botEle.childNodes;
                     for (var i=0;i<botChildNodes.length;i++)
                        {if (botChildNodes[i].nodeType == 3)
                            {botDateValue = botChildNodes[i].nodeValue.replace(/^\s+/,'').replace(/\s+$/,'');
                             if (botDateValue.length > 0)
                                {botTriggerEle.botTextNode = botChildNodes[i];
                                 botTriggerEle.botLength   = botChildNodes[i].nodeValue.length;
                                 break;
                                }
                            }
                        }
                    }
                }

         botSetDefaultLanguage();

         botID('botDragText').innerHTML = botDrag;

         botID('botMonths').options.length = 0;
         for (var i=0;i<botArrMonthNames.length;i++)
            {botID('botMonths').options[i] = new Option(botArrMonthNames[i],botArrMonthNames[i]);}

         botID('botYears').options.length = 0;
         for (var i=0;i<botDropDownYears;i++)
            {botID('botYears').options[i] =  new Option((botBaseYear+i),(botBaseYear+i));}

         for (var i=0;i<botArrWeekInits.length;i++)
            {botID('botWeekInit' + i).innerHTML = botArrWeekInits[(i+botWeekStart)%botArrWeekInits.length];}

         if (((new Date(botBaseYear + botDropDownYears, 0, 0)) > botDateNow &&
              (new Date(botBaseYear, 0, 0))                    < botDateNow) ||
             (botClearButton && (botEle.readOnly || botEle.disabled))
            )   {botID('botFoot').style.display = '';
                 botID('botNow').innerHTML = '<p onclick=botHide()>Kalender ausblenden';
                 botID('botClearButton').value = botClear;
                 if ((new Date(botBaseYear + botDropDownYears, 0, 0)) > botDateNow &&
                     (new Date(botBaseYear, 0, 0))                    < botDateNow
                    )   {botID('botNow').style.display = '';
                         if (botClearButton && (botEle.readOnly || botEle.disabled))
                                {botID('botClear').style.display   = '';
                                 botID('botClear').style.textAlign = 'left';
                                 botID('botNow').style.textAlign   = 'right';
                                }
                         else   {botID('botClear').style.display = 'none';
                                 botID('botNow').style.textAlign = 'center';
                                }
                        }
                 else   {botID('botClear').style.textAlign = 'center';
                         botID('botClear').style.display = '';
                         botID('botNow').style.display = 'none';
                        }
                }
         else   {botID('botFoot').style.display = 'none';}

         if (botDateValue.length==0)
            {
             botBlnFullInputDate=false;

             if ((new Date(botBaseYear+botDropDownYears,0,0))<botSeedDate ||
                 (new Date(botBaseYear,0,1))                 >botSeedDate
                )
                {botSeedDate = new Date(botBaseYear + Math.floor(botDropDownYears / 2), 5, 1);}
            }
         else
            {function botInputFormat()
                {var botArrSeed = new Array(),
                     botArrInput = botDateValue.split(new RegExp('[\\'+botArrDelimiters.join('\\')+']+','g'));

                 if (botArrInput[0]!=null)
                    {if (botArrInput[0].length==0)                      {botArrInput.splice(0,1);}
                     if (botArrInput[botArrInput.length-1].length==0)   {botArrInput.splice(botArrInput.length-1,1);}
                    }

                 botBlnFullInputDate = false;

                 botDateOutputFormat = botDateOutputFormat.toUpperCase();

                 // List all the allowed letters in the date format
                 var template = ['D','M','Y'];

                 // Prepare the sequence of date input elements
                 var result = new Array();

                 for (var i=0;i<template.length;i++)
                    {if (botDateOutputFormat.search(template[i])>-1)
                        {result[botDateOutputFormat.search(template[i])] = template[i];}
                    }

                 var botDateSequence = result.join('');

                 // Separate the elements of the date input
                 switch (botArrInput.length)
                    {case 1:
                        {if (botDateOutputFormat.indexOf('Y')>-1 &&
                             botArrInput[0].length>botDateOutputFormat.lastIndexOf('Y'))
                            {botArrSeed[0] = parseInt(botArrInput[0].substring(botDateOutputFormat.indexOf('Y'),
                                                                               botDateOutputFormat.lastIndexOf('Y')+1),10);
                            }
                         else   {botArrSeed[0] = 0;}

                         if (botDateOutputFormat.indexOf('M')>-1 &&
                             botArrInput[0].length>botDateOutputFormat.lastIndexOf('M'))
                            {botArrSeed[1] = botArrInput[0].substring(botDateOutputFormat.indexOf('M'),
                                                                      botDateOutputFormat.lastIndexOf('M')+1);
                            }
                         else   {botArrSeed[1] = '6';}

                         if (botDateOutputFormat.indexOf('D')>-1 &&
                             botArrInput[0].length>botDateOutputFormat.lastIndexOf('D'))
                            {botArrSeed[2] = parseInt(botArrInput[0].substring(botDateOutputFormat.indexOf('D'),
                                                                               botDateOutputFormat.lastIndexOf('D')+1),10);
                            }
                         else   {botArrSeed[2] = 1;}

                         if (botArrInput[0].length==botDateOutputFormat.length) {botBlnFullInputDate = true;}
                         break;
                        }
                     case 2:
                        {// Year and Month entry
                         botArrSeed[0] =
                             parseInt(botArrInput[botDateSequence.
                                                    replace(/D/i,'').
                                                    search(/Y/i)],10);  // Year
                         botArrSeed[1] = botArrInput[botDateSequence.
                                                    replace(/D/i,'').
                                                    search(/M/i)];      // Month
                         botArrSeed[2] = 1;                             // Day
                         break;
                        }
                     case 3:
                        {// Day Month and Year entry

                         botArrSeed[0] =
                             parseInt(botArrInput[botDateSequence.
                                                    search(/Y/i)],10);  // Year
                         botArrSeed[1] = botArrInput[botDateSequence.
                                                    search(/M/i)];      // Month
                         botArrSeed[2] =
                             parseInt(botArrInput[botDateSequence.
                                                    search(/D/i)],10);  // Day

                         botBlnFullInputDate = true;
                         break;
                        }
                     default:
                        {
                         botArrSeed[0] = 0;     // Year
                         botArrSeed[1] = 0;     // Month
                         botArrSeed[2] = 0;     // Day
                        }
                    }


                 var botExpValDay    = new RegExp('^(0?[1-9]|[1-2][0-9]|3[0-1])$'),
                     botExpValMonth  = new RegExp('^(0?[1-9]|1[0-2]|'        +
                                                  botArrMonthNames.join('|') +
                                                  ')$','i'),
                     botExpValYear   = new RegExp('^([0-9]{1,2}|[0-9]{4})$');


                 if (botExpValYear.exec(botArrSeed[0])  == null ||
                     botExpValMonth.exec(botArrSeed[1]) == null ||
                     botExpValDay.exec(botArrSeed[2])   == null
                    )
                    {if (botShowInvalidDateMsg)
                        {alert(botInvalidDateMsg  +
                               botInvalidAlert[0] + botDateValue +
                               botInvalidAlert[1]);}
                     botBlnFullInputDate = false;
                     botArrSeed[0] = botBaseYear +
                                     Math.floor(botDropDownYears/2); // Year
                     botArrSeed[1] = '6';                            // Month
                     botArrSeed[2] = 1;                              // Day
                    }


                 return botArrSeed;
                };


             botArrSeedDate = botInputFormat();


             if (botArrSeedDate[0]<100) {botArrSeedDate[0] += (botArrSeedDate[0]>50)?1900:2000;}


             if (botArrSeedDate[1].search(/\d+/)<0)
                {for (i=0;i<botArrMonthNames.length;i++)
                    {if (botArrSeedDate[1].toUpperCase()==botArrMonthNames[i].toUpperCase())
                        {botArrSeedDate[1]=i+1;
                         break;
                        }
                    }
                }

             botSeedDate = new Date(botArrSeedDate[0],botArrSeedDate[1]-1,botArrSeedDate[2]);
            }

         if (isNaN(botSeedDate))
            {if (botShowInvalidDateMsg) {alert(botInvalidDateMsg + botInvalidAlert[0] + botDateValue + botInvalidAlert[1]);}
             botSeedDate = new Date(botBaseYear + Math.floor(botDropDownYears/2),5,1);
             botBlnFullInputDate=false;
            }
         else
            {
             if ((new Date(botBaseYear,0,1)) > botSeedDate)
                {if (botBlnStrict && botShowOutOfRangeMsg) {alert(botOutOfRangeMsg);}
                 botSeedDate = new Date(botBaseYear,0,1);
                 botBlnFullInputDate=false;
                }
             else
                {if ((new Date(botBaseYear+botDropDownYears,0,0))<botSeedDate)
                    {if (botBlnStrict && botShowOutOfRangeMsg) {alert(botOutOfRangeMsg);}
                     botSeedDate = new Date(botBaseYear + Math.floor(botDropDownYears)-1,11,1);
                     botBlnFullInputDate=false;
                    }
                 else
                    {if (botBlnStrict && botBlnFullInputDate &&
                          (botSeedDate.getDate()      != botArrSeedDate[2] ||
                           (botSeedDate.getMonth()+1) != botArrSeedDate[1] ||
                           botSeedDate.getFullYear()  != botArrSeedDate[0]
                          )
                        )
                        {if (botShowDoesNotExistMsg) alert(botDoesNotExistMsg);
                         botSeedDate = new Date(botSeedDate.getFullYear(),botSeedDate.getMonth()-1,1);
                         botBlnFullInputDate=false;
                        }
                    }
                }
            }


         for (var i=0;i<botDisabledDates.length;i++)
            {if (!((typeof botDisabledDates[i] == 'object') && (botDisabledDates[i].constructor == Date)))
                {if ((typeof botDisabledDates[i] == 'object') && (botDisabledDates[i].constructor == Array))
                    {var botPass = true;

                     if (botDisabledDates[i].length !=2)
                        {if (botShowRangeDisablingError)
                            {alert(botRangeDisablingError[0] + botDisabledDates[i] + botRangeDisablingError[1]);}
                         botPass = false;
                        }
                     else
                        {for (var j=0;j<botDisabledDates[i].length;j++)
                            {if (!((typeof botDisabledDates[i][j] == 'object') && (botDisabledDates[i][j].constructor == Date)))
                                {if (botShowRangeDisablingError)
                                    {alert(  botDateDisablingError[0] + botDisabledDates[i][j] + botDateDisablingError[1]);}
                                 botPass = false;
                                }
                            }
                        }

                     if (botPass && (botDisabledDates[i][0] > botDisabledDates[i][1])) {botDisabledDates[i].reverse();}
                    }
                 else
                    {if (botShowRangeDisablingError) {alert(botDateDisablingError[0] + botDisabledDates[i] + botDateDisablingError[1]);}}
                }
            }

         botMonthSum =  12*(botSeedDate.getFullYear()-botBaseYear)+botSeedDate.getMonth();

         botID('botYears' ).options.selectedIndex = Math.floor(botMonthSum/12);
         botID('botMonths').options.selectedIndex = (botMonthSum%12);
         botID('botDrag').style.display=(botAllowDrag)?'':'none';

         botShowMonth(0);

         botTargetEle=botEle;

         var offsetTop =parseInt(botEle.offsetTop ,10) + parseInt(botEle.offsetHeight,10),
             offsetLeft=parseInt(botEle.offsetLeft,10);

         if (!window.opera)
             {while (botEle.tagName!='BODY' && botEle.tagName!='HTML')
                 {offsetTop -=parseInt(botEle.scrollTop, 10);
                  offsetLeft-=parseInt(botEle.scrollLeft,10);
                  botEle=botEle.parentNode;
                 }
              botEle=botTargetEle;
             }

         do {botEle=botEle.offsetParent;
             offsetTop +=parseInt(botEle.offsetTop, 10);
             offsetLeft+=parseInt(botEle.offsetLeft,10);
            }
         while (botEle.tagName!='BODY' && botEle.tagName!='HTML');

         if (botAutoPosition)
             {var botWidth      = parseInt(botID('bot').offsetWidth, 10),
                  botHeight     = parseInt(botID('bot').offsetHeight,10),
                  botWindowLeft =
                     (document.body && document.body.scrollLeft)
                          ?document.body.scrollLeft                  //DOM compliant
                          :(document.documentElement && document.documentElement.scrollLeft)
                              ?document.documentElement.scrollLeft   //IE6+ standards compliant
                              :0,                                    //Failed
                  botWindowWidth =
                      (typeof(innerWidth) == 'number')
                          ?innerWidth                                //DOM compliant
                          :(document.documentElement && document.documentElement.clientWidth)
                              ?document.documentElement.clientWidth  //IE6+ standards compliant
                              :(document.body && document.body.clientWidth)
                                  ?document.body.clientWidth         //IE non-compliant
                                  :0,                                //Failed
                  botWindowTop =
                      (document.body && document.body.scrollTop)
                          ?document.body.scrollTop                   //DOM compliant
                          :(document.documentElement && document.documentElement.scrollTop)
                              ?document.documentElement.scrollTop    //IE6+ standards compliant
                              :0,                                    //Failed
                  botWindowHeight =
                      (typeof(innerHeight) == 'number')
                          ?innerHeight                               //DOM compliant
                          :(document.documentElement && document.documentElement.clientHeight)
                              ?document.documentElement.clientHeight //IE6+ standards compliant
                              :(document.body && document.body.clientHeight)
                                  ?document.body.clientHeight        //IE non-compliant
                                  :0;                                //Failed

              offsetLeft -= (offsetLeft - botWidth + parseInt(botTargetEle.offsetWidth,10) >= botWindowLeft &&
                             offsetLeft + botWidth > botWindowLeft + botWindowWidth
                            )?(botWidth - parseInt(botTargetEle.offsetWidth,10)):0;

              offsetTop -= (offsetTop - botHeight - parseInt(botTargetEle.offsetHeight,10) >= botWindowTop &&
                            offsetTop + botHeight > botWindowTop + botWindowHeight
                           )?(botHeight + parseInt(botTargetEle.offsetHeight,10)):0;
             }

         botID('bot').style.top         = offsetTop+'px';
         botID('bot').style.left        = offsetLeft+'px';
         botID('botIframe').style.top   = offsetTop+'px';
         botID('botIframe').style.left  = offsetLeft+'px';

         botID('botIframe').style.width =(botID('bot').offsetWidth-(botID('botIE')?2:4))+'px';
         botID('botIframe').style.height=(botID('bot').offsetHeight-(botID('botIE')?2:4))+'px';
         botID('botIframe').style.visibility='inherit';

         // Show it on the page
         botID('bot').style.visibility='inherit';
        };

    function botHide()
        {botID('bot').style.visibility='hidden';
         botID('botIframe').style.visibility='hidden';
         if (typeof botNextAction!='undefined' && botNextAction!=null)
             {botNextActionReturn = botNextAction();
              // Explicit null set to prevent closure causing memory leak
              botNextAction = null;
             }
        };

    function botCancel(botEvt)
        {if (botClickToHide) {botHide();}
         botStopPropagation(botEvt);
        };

    function botStopPropagation(botEvt)
        {if (botEvt.stopPropagation)
                {botEvt.stopPropagation();}     // Capture phase
         else   {botEvt.cancelBubble = true;}   // Bubbling phase
        };

    function botBeginDrag(event)
        {var elementToDrag = botID('bot');

         var deltaX    = event.clientX,
             deltaY    = event.clientY,
             offsetEle = elementToDrag;

         do {deltaX   -= parseInt(offsetEle.offsetLeft,10);
             deltaY   -= parseInt(offsetEle.offsetTop ,10);
             offsetEle = offsetEle.offsetParent;
            }
         while (offsetEle.tagName!='BODY' &&
                offsetEle.tagName!='HTML');

         if (document.addEventListener)
                {document.addEventListener('mousemove',moveHandler,true);        // Capture phase
                 document.addEventListener('mouseup',  upHandler,  true);        // Capture phase
                }
         else   {elementToDrag.attachEvent('onmousemove',moveHandler); // Bubbling phase
                 elementToDrag.attachEvent('onmouseup',  upHandler);   // Bubbling phase
                 elementToDrag.setCapture();
                }

         botStopPropagation(event);

         function moveHandler(botEvt)
            {if (!botEvt) botEvt = window.event;

             elementToDrag.style.left = (botEvt.clientX - deltaX) + 'px';
             elementToDrag.style.top  = (botEvt.clientY - deltaY) + 'px';

             botID('botIframe').style.left = (botEvt.clientX - deltaX) + 'px';
             botID('botIframe').style.top  = (botEvt.clientY - deltaY) + 'px';

             botStopPropagation(botEvt);
            };

         function upHandler(botEvt)
            {if (!botEvt) botEvt = window.event;

             if (document.removeEventListener)
                    {document.removeEventListener('mousemove',moveHandler,true);     // Capture phase
                     document.removeEventListener('mouseup',  upHandler,  true);     // Capture phase
                    }
             else   {elementToDrag.detachEvent('onmouseup',  upHandler);   // Bubbling phase
                     elementToDrag.detachEvent('onmousemove',moveHandler); // Bubbling phase
                     elementToDrag.releaseCapture();
                    }

             botStopPropagation(botEvt);
            };
        };

    function botShowMonth(botBias)
        {

         var botShowDate  = new Date(Date.parse(new Date().toDateString())),
             botStartDate = new Date();

         botShowDate.setHours(12);

         botSelYears  = botID('botYears');
         botSelMonths = botID('botMonths');

         if (botSelYears.options.selectedIndex>-1)
            {botMonthSum=12*(botSelYears.options.selectedIndex)+botBias;
             if (botSelMonths.options.selectedIndex>-1) {botMonthSum+=botSelMonths.options.selectedIndex;}
            }
         else
            {if (botSelMonths.options.selectedIndex>-1) {botMonthSum+=botSelMonths.options.selectedIndex;}}

         botShowDate.setFullYear(botBaseYear + Math.floor(botMonthSum/12),(botMonthSum%12),1);

         botID('botWeek_').style.display=(botWeekNumberDisplay)?'':'none';

         if (window.opera)
            {botID('botMonths').style.display = 'inherit';
             botID('botYears' ).style.display = 'inherit';
           }

         botTemp = (12*parseInt((botShowDate.getFullYear()-botBaseYear),10)) + parseInt(botShowDate.getMonth(),10);

         if (botTemp > -1 && botTemp < (12*botDropDownYears))
            {botSelYears.options.selectedIndex=Math.floor(botMonthSum/12);
             botSelMonths.options.selectedIndex=(botMonthSum%12);

             botCurMonth = botShowDate.getMonth();

             botShowDate.setDate((((botShowDate.
                                    getDay()-botWeekStart)<0)?-6:1)+
                                 botWeekStart-botShowDate.getDay());

             var botCompareDateValue = new Date(botShowDate.getFullYear(),
                                                botShowDate.getMonth(),
                                                botShowDate.getDate()).valueOf();

             botStartDate = new Date(botShowDate);

             if ((new Date(botBaseYear + botDropDownYears, 0, 0)) > botDateNow &&
                 (new Date(botBaseYear, 0, 0))                    < botDateNow)
                {var botNow = botID('botNow');

                 function botNowOutput() {botSetOutput(botDateNow);};

                 if (botDisabledDates.length==0)
                    {if (botActiveToday && botParmActiveToday)
                        {botNow.onclick     = botNowOutput;
                         botNow.className   = 'botNow';

                         if (botID('botIE'))
                            {botNow.onmouseover  = botChangeClass;
                             botNow.onmouseout   = botChangeClass;
                            }

                        }
                     else
                        {botNow.onclick     = null;
                         botNow.className   = 'botNowDisabled';

                         if (botID('botIE'))
                            {botNow.onmouseover  = null;
                             botNow.onmouseout   = null;
                            }

                         if (document.addEventListener)
                                {botNow.addEventListener('click',botStopPropagation,false);}
                         else   {botNow.attachEvent('onclick',botStopPropagation);}
                        }
                    }
                 else
                    {for (var k=0;k<botDisabledDates.length;k++)
                        {if (!botActiveToday || !botParmActiveToday ||
                             ((typeof botDisabledDates[k] == 'object')                   &&
                                 (((botDisabledDates[k].constructor == Date)             &&
                                   botDateNow.valueOf() == botDisabledDates[k].valueOf()
                                  ) ||
                                  ((botDisabledDates[k].constructor == Array)               &&
                                   botDateNow.valueOf() >= botDisabledDates[k][0].valueOf() &&
                                   botDateNow.valueOf() <= botDisabledDates[k][1].valueOf()
                                  )
                                 )
                             )
                            )
                            {botNow.onclick     = null;
                             botNow.className   = 'botNowDisabled';

                             if (botID('botIE'))
                                {botNow.onmouseover  = null;
                                 botNow.onmouseout   = null;
                                }

                             if (document.addEventListener)
                                    {botNow.addEventListener('click',botStopPropagation,false);}
                             else   {botNow.attachEvent('onclick',botStopPropagation);}
                             break;
                            }
                         else
                            {botNow.onclick=botNowOutput;
                             botNow.className='botNow';

                             if (botID('botIE'))
                                {botNow.onmouseover  = botChangeClass;
                                 botNow.onmouseout   = botChangeClass;
                                }
                            }
                        }
                    }
                }

             function botSetOutput(botOutputDate)
                {if (typeof botTargetEle.value == 'undefined')
                      {botTriggerEle.botTextNode.replaceData(0,botTriggerEle.botLength,botOutputDate.botFormat(botDateOutputFormat));}
                 else {botTargetEle.value = botOutputDate.botFormat(botDateOutputFormat);}
                 botHide();
                };

             function botCellOutput(botEvt)
                {var botEle = botEventTrigger(botEvt),
                     botOutputDate = new Date(botStartDate);

                 if (botEle.nodeType==3) botEle=botEle.parentNode;

                 botOutputDate.setDate(botStartDate.getDate() + parseInt(botEle.id.substr(8),10));

                 botSetOutput(botOutputDate);
                };

             function botChangeClass(botEvt)
                {var botEle = botEventTrigger(botEvt);

                 if (botEle.nodeType==3) {botEle=botEle.parentNode;}

                 switch (botEle.className)
                    {case 'botCells':
                        botEle.className = 'botCellsHover';
                        break;
                     case 'botCellsHover':
                        botEle.className = 'botCells';
                        break;
                     case 'botCellsExMonth':
                        botEle.className = 'botCellsExMonthHover';
                        break;
                     case 'botCellsExMonthHover':
                        botEle.className = 'botCellsExMonth';
                        break;
                     case 'botCellsWeekend':
                        botEle.className = 'botCellsWeekendHover';
                        break;
                     case 'botCellsWeekendHover':
                        botEle.className = 'botCellsWeekend';
                        break;
                     case 'botNow':
                        botEle.className = 'botNowHover';
                        break;
                     case 'botNowHover':
                        botEle.className = 'botNow';
                        break;
                     case 'botInputDate':
                        botEle.className = 'botInputDateHover';
                        break;
                     case 'botInputDateHover':
                        botEle.className = 'botInputDate';
                    }

                 return true;
                }

             function botEventTrigger(botEvt)
                {if (!botEvt) {botEvt = event;}
                 return botEvt.target||botEvt.srcElement;
                };

             function botWeekNumber(botInDate)
                {// The base day in the week of the input date
                 var botInDateWeekBase = new Date(botInDate);

                 botInDateWeekBase.setDate(botInDateWeekBase.getDate()
                                            - botInDateWeekBase.getDay()
                                            + botWeekNumberBaseDay
                                            + ((botInDate.getDay()>
                                                botWeekNumberBaseDay)?7:0));

                 // The first Base Day in the year
                 var botFirstBaseDay = new Date(botInDateWeekBase.getFullYear(),0,1);

                 botFirstBaseDay.setDate(botFirstBaseDay.getDate()
                                            - botFirstBaseDay.getDay()
                                            + botWeekNumberBaseDay
                                        );

                 if (botFirstBaseDay < new Date(botInDateWeekBase.getFullYear(),0,1))
                    {botFirstBaseDay.setDate(botFirstBaseDay.getDate()+7);}

                 var botStartWeekOne = new Date(botFirstBaseDay
                                                - botWeekNumberBaseDay
                                                + botInDate.getDay());

                 if (botStartWeekOne > botFirstBaseDay)
                    {botStartWeekOne.setDate(botStartWeekOne.getDate()-7);}

                 var botWeekNo = '0' + (Math.round((botInDateWeekBase - botFirstBaseDay)/604800000,0) + 1);

                 return botWeekNo.substring(botWeekNo.length-2, botWeekNo.length);
                };

             var botCells = botID('botCells');

             for (i=0;i<botCells.childNodes.length;i++)
                {var botRows = botCells.childNodes[i];
                 if (botRows.nodeType==1 && botRows.tagName=='TR')
                    {if (botWeekNumberDisplay)
                        {//Calculate the week number using botShowDate
                         botTmpEl = botRows.childNodes[0];
                         botTmpEl.innerHTML = botWeekNumber(botShowDate);
                         botTmpEl.style.borderColor =
                             (botTmpEl.currentStyle)
                                ?botTmpEl.currentStyle['backgroundColor']
                                :(window.getComputedStyle)
                                    ?document.defaultView.getComputedStyle(botTmpEl,null).getPropertyValue('background-color')
                                    :'';
                         botTmpEl.style.display='';
                        }
                     else
                        {botRows.childNodes[0].style.display='none';}

                     for (j=1;j<botRows.childNodes.length;j++)
                        {var botCols = botRows.childNodes[j];
                         if (botCols.nodeType==1 && botCols.tagName=='TD')
                            {botRows.childNodes[j].innerHTML=
                                botShowDate.getDate();
                             var botCell=botRows.childNodes[j],
                                 botDisabled =
                                    ((botOutOfRangeDisable &&
                                        (botShowDate <
                                            (new Date(botBaseYear,0,1,
                                                      botShowDate.getHours()))
                                         ||
                                         botShowDate >
                                            (new Date(botBaseYear+
                                                      botDropDownYears,0,0,
                                                      botShowDate.getHours()))
                                        )
                                     ) ||
                                     (botOutOfMonthDisable &&
                                        (botShowDate <
                                            (new Date(botShowDate.getFullYear(),
                                                      botCurMonth,1,
                                                      botShowDate.getHours()))
                                         ||
                                         botShowDate >
                                            (new Date(botShowDate.getFullYear(),
                                                      botCurMonth+1,0,
                                                      botShowDate.getHours()))
                                        )
                                     )
                                    )?true:false;

                             botCell.style.visibility =
                                (botOutOfMonthHide &&
                                    (botShowDate <
                                        (new Date(botShowDate.getFullYear(),
                                                  botCurMonth,1,
                                                  botShowDate.getHours()))
                                     ||
                                     botShowDate >
                                        (new Date(botShowDate.getFullYear(),
                                                  botCurMonth+1,0,
                                                  botShowDate.getHours()))
                                    )
                                )?'hidden':'inherit';

                             for (var k=0;k<botDisabledDates.length;k++)
                                {if ((typeof botDisabledDates[k]=='object') &&
                                     (botDisabledDates[k].constructor == Date) &&
                                     botCompareDateValue == botDisabledDates[k].valueOf()
                                    )
                                    {botDisabled = true;}
                                 else
                                    {if ((typeof botDisabledDates[k]=='object') &&
                                         (botDisabledDates[k].constructor == Array) &&
                                         botCompareDateValue >= botDisabledDates[k][0].valueOf() &&
                                         botCompareDateValue <= botDisabledDates[k][1].valueOf()
                                        )
                                        {botDisabled = true;}
                                    }
                                }

                             if (botDisabled ||
                                 !botEnabledDay[j-1+(7*((i*botCells.childNodes.length)/6))] ||
                                 !botPassEnabledDay[(j-1+(7*(i*botCells.childNodes.length/6)))%7]
                                )
                                {botRows.childNodes[j].onclick = null;

                                 if (botID('botIE'))
                                    {botRows.childNodes[j].onmouseover  = null;
                                     botRows.childNodes[j].onmouseout   = null;
                                    }

                                 botCell.className=
                                    (botShowDate.getMonth()!=botCurMonth)
                                        ?'botCellsExMonthDisabled'
                                        :(botBlnFullInputDate &&
                                          botShowDate.toDateString()==
                                          botSeedDate.toDateString())
                                            ?'botInputDateDisabled'
                                            :(botShowDate.getDay()%6==0)
                                                ?'botCellsWeekendDisabled'
                                                :'botCellsDisabled';

                                 botCell.style.borderColor =
                                     (botFormatTodayCell && botShowDate.toDateString()==botDateNow.toDateString())
                                        ?botTodayCellBorderColour
                                        :(botCell.currentStyle)
                                            ?botCell.currentStyle['backgroundColor']
                                            :(window.getComputedStyle)
                                                ?document.defaultView.getComputedStyle(botCell,null).getPropertyValue('background-color')
                                                :'';
                                }
                             else
                                {botRows.childNodes[j].onclick=botCellOutput;

                                 if (botID('botIE'))
                                    {botRows.childNodes[j].onmouseover  = botChangeClass;
                                     botRows.childNodes[j].onmouseout   = botChangeClass;
                                    }

                                 botCell.className=
                                     (botShowDate.getMonth()!=botCurMonth)
                                        ?'botCellsExMonth'
                                        :(botBlnFullInputDate &&
                                          botShowDate.toDateString()==
                                          botSeedDate.toDateString())
                                            ?'botInputDate'
                                            :(botShowDate.getDay()%6==0)
                                                ?'botCellsWeekend'
                                                :'botCells';

                                 botCell.style.borderColor =
                                     (botFormatTodayCell && botShowDate.toDateString() == botDateNow.toDateString())
                                        ?botTodayCellBorderColour
                                        :(botCell.currentStyle)
                                            ?botCell.currentStyle['backgroundColor']
                                            :(window.getComputedStyle)
                                                ?document.defaultView.getComputedStyle(botCell,null).getPropertyValue('background-color')
                                                :'';
                               }

                             botShowDate.setDate(botShowDate.getDate()+1);
                             botCompareDateValue = new Date(botShowDate.getFullYear(),botShowDate.getMonth(),botShowDate.getDate()).valueOf();
                            }
                        }
                    }
                }
            }

         if (window.opera)
            {botID('botMonths').style.display = 'inline';
             botID('botYears' ).style.display = 'inline';
             botID('bot').style.visibility='hidden';
             botID('bot').style.visibility='inherit';
           }
        };

// *************************
//  End of Function Library
// *************************
// ***************************
// Start of Calendar structure
// ***************************

    document.writeln("<!--[if IE]><div id='botIE'></div><![endif]-->");
    document.writeln("<!--[if lt IE 7]><div id='botIElt7'></div><![endif]-->");
    document.write(
     "<iframe class='bot' " + (botID('botIElt7')?"src='/botblank.html '":'') +
             "id='botIframe' name='botIframe' frameborder='0'>" +
     "</iframe>" +
     "<table id='bot' class='bot'>" +
       "<tr class='bot'>" +
         "<td class='bot'>" +
           "<table class='botHead' id='botHead' width='100%' " +
                    "cellspacing='0' cellpadding='0'>" +
            "<tr id='botDrag' style='display:none;'>" +
                "<td colspan='4' class='botDrag' " +
                    "onmousedown='botBeginDrag(event);'>" +
                    "<span id='botDragText'></span>" +
                "</td>" +
            "</tr>" +
            "<tr class='botHead' >" +
                 "<td class='botHead'>" +
                    "<input class='botHead' id='botHeadLeft' type='button' value='<' " +
                            "onclick='botShowMonth(-1);'  /></td>" +
                 "<td class='botHead'>" +
                    "<select id='botMonths' class='botHead' " +
                            "onchange='botShowMonth(0);'>" +
                    "</select>" +
                 "</td>" +
                 "<td class='botHead'>" +
                    "<select id='botYears' class='botHead' " +
                            "onchange='botShowMonth(0);'>" +
                    "</select>" +
                 "</td>" +
                 "<td class='botHead'>" +
                    "<input class='botHead' id='botHeadRight' type='button' value='>' " +
                            "onclick='botShowMonth(1);' /></td>" +
                "</tr>" +
              "</table>" +
            "</td>" +
          "</tr>" +
          "<tr class='bot'>" +
            "<td class='bot'>" +
              "<table class='botCells' align='center'>" +
                "<thead>" +
                  "<tr><td class='botWeekNumberHead' id='botWeek_' ></td>");

    for (i=0;i<7;i++)
        {document.write(
                      "<td class='botWeek' id='botWeekInit" + i + "'></td>");
        }

    document.write("</tr>" +
                "</thead>" +
                "<tbody id='botCells' onClick='botStopPropagation(event);'>");

    for (i=0;i<6;i++)
        {document.write(
                    "<tr>" +
                      "<td class='botWeekNo' id='botWeek_" + i + "'></td>");
         for (j=0;j<7;j++)
            {document.write(
                        "<td class='botCells' id='botCell_" + (j+(i*7)) +
                        "'></td>");
            }

         document.write(
                    "</tr>");
        }

    document.write(
                "</tbody>" +
                "<tfoot>" +
                  "<tr id='botFoot'>" +
                    "<td colspan='8' style='padding:0px;'>" +
                      "<table width='100%'>" +
                        "<tr>" +
                          "<td id='botClear' class='botClear'>" +
                            "<input type='button' id='botClearButton' class='botClear' " +
                                   "onclick='botTargetEle.value = \"\";botHide();' />" +
                          "</td>" +
                          "<td class='botNow' id='botNow'></td>" +
                        "</tr>" +
                      "</table>" +
                    "</td>" +
                  "</tr>" +
                "</tfoot>" +
              "</table>" +
            "</td>" +
          "</tr>" +
        "</table>");

    if (document.addEventListener)
            {botID('bot'         ).addEventListener('click',botCancel,false);
             botID('botHeadLeft' ).addEventListener('click',botStopPropagation,false);
             botID('botMonths'   ).addEventListener('click',botStopPropagation,false);
             botID('botMonths'   ).addEventListener('change',botStopPropagation,false);
             botID('botYears'    ).addEventListener('click',botStopPropagation,false);
             botID('botYears'    ).addEventListener('change',botStopPropagation,false);
             botID('botHeadRight').addEventListener('click',botStopPropagation,false);
            }
    else    {botID('bot'         ).attachEvent('onclick',botCancel);
             botID('botHeadLeft' ).attachEvent('onclick',botStopPropagation);
             botID('botMonths'   ).attachEvent('onclick',botStopPropagation);
             botID('botMonths'   ).attachEvent('onchange',botStopPropagation);
             botID('botYears'    ).attachEvent('onclick',botStopPropagation);
             botID('botYears'    ).attachEvent('onchange',botStopPropagation);
             botID('botHeadRight').attachEvent('onclick',botStopPropagation);
            }

// ***************************
//  End of Calendar structure
// ***************************
// ****************************************
// Start of document level event definition
// ****************************************

    if (document.addEventListener)
            {document.addEventListener('click',botHide, false);}
    else    {document.attachEvent('onclick',botHide);}

// ****************************************
//  End of document level event definition
// ****************************************
// ************************************
//  End of Simple Calendar Widget Code
// ************************************
