// *****************************************************************************
//      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 monDateNow = new Date(2010,8,1);


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

    var monBaseYear        = 2010;

    var monDropDownYears   = 1;

    var monLanguage;

    function monSetDefaultLanguage()
        {try
            {monSetLanguage();}
         catch (exception)
            {// Deutsch
             monToday               = 'Heute:';
             monClear               = 'Clear';
             monDrag                = 'click here to drag';
             monArrMonthNames       = ['Jan','Feb','Mar','Apr','Mai','Jun',
                                       'Jul','Aug','Sep','Okt','Nov','Dez'];
             monArrWeekInits        = ['So','Mo','Di','Mi','Do','Fr','Sa'];
             monInvalidDateMsg      = 'Das eigetragene Datum ist ungültig.\n';
             monOutOfRangeMsg       = 'Das eigetragene Datum ist ausserhalb des möglichen Zeitraums.';
             monDoesNotExistMsg     = 'Das eigetragene Datum existiert nicht.';
             monInvalidAlert        = ['Ungültiges Datum (',') ignoriert.'];
             monDateDisablingError  = ['Fehler ',' ist kein Datum.'];
             monRangeDisablingError = ['Fehler ',
                                       ' should consist of two elements.'];
            }
        };

    var monWeekStart       =    1;

    var monWeekNumberDisplay    = false;

    var monWeekNumberBaseDay    = 4;

    var monShowInvalidDateMsg       = false,
        monShowOutOfRangeMsg        = false,
        monShowDoesNotExistMsg      = false,
        monShowInvalidAlert         = false,
        monShowDateDisablingError   = false,
        monShowRangeDisablingError  = false;

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

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

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

    var monZindex          = 1;

    var monBlnStrict       = false;

    var monClearButton     = true;

    var monAutoPosition    = true;

    var monEnabledDay      = [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 monDisabledDates   = new Array();

    monDisabledDates[1] = [new Date(2010,0,1),new Date(2010,3,30)];
    monDisabledDates[2] = [new Date(2010,4,1),new Date(2010,8,8)];
    monDisabledDates[3] = new Date(2010,9,9);
    monDisabledDates[4] = new Date(2010,11,18);
    monDisabledDates[5] = new Date(2010,10,20);


    var monActiveToday = false;
    var monOutOfMonthDisable = false;
    var monOutOfMonthHide    = true;
    var monOutOfRangeDisable = true;
    var monFormatTodayCell = true;
    var monTodayCellBorderColour = 'red';
    var monAllowDrag = false;
    var monClickToHide = true;


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

    document.writeln(
        '<style type="text/css">'                                       +
            '/* IMPORTANT:  The SCW calendar script requires all '      +
            '               the classes defined here.'                  +
            '*/'                                                        +
            'table.mon      {padding:       1px;'                       +
                            'vertical-align:middle;'                    +
                            'border:        ridge 2px;'                 +
                            'font-size:     10pt;'                      +
                            'font-family:   ' +
                                   'Verdana,Arial,Helvetica,Sans-Serif;'+
                            'font-weight:   bold;}'                     +
            'td.monDrag,'                                               +
            'td.monHead                 {padding:       0px 0px;'       +
                                        'text-align:    center;}'       +
            'td.monDrag                 {font-size:     8pt;}'          +
            'select.monHead             {margin:        3px 1px;'       +
                                        'text-align:    center;}'       +
            'input.monHead              {height:        22px;'          +
                                        'width:         22px;'          +
                                        'vertical-align:middle;'        +
                                        'text-align:    center;'        +
                                        'margin:        2px 1px;'       +
                                        'font-weight:   bold;'          +
                                        'font-size:     10pt;'          +
                                        'font-family:   fixedSys;}'     +
            'td.monWeekNumberHead,'                                     +
            'td.monWeek                 {padding:       0px;'           +
                                        'text-align:    center;'        +
                                        'font-weight:   bold;}'         +
            'td.monNow,'                                                +
            'td.monNowHover,'                                           +
            'td.monNow:hover,'                                          +
            'td.monNowDisabled          {padding:       0px;'           +
                                        'text-align:    center;'        +
                                        'vertical-align:middle;'        +
                                        'font-weight:   normal;}'       +
            'table.monCells             {text-align:    right;'         +
                                        'font-size:     8pt;'           +
                                        'width:         96%;}'          +
            'td.monCells,'                  +
            'td.monCellsHover,'             +
            'td.monCells:hover,'            +
            'td.monCellsDisabled,'          +
            'td.monCellsExMonth,'           +
            'td.monCellsExMonthHover,'      +
            'td.monCellsExMonth:hover,'     +
            'td.monCellsExMonthDisabled,'   +
            'td.monCellsWeekend,'           +
            'td.monCellsWeekendHover,'      +
            'td.monCellsWeekend:hover,'     +
            'td.monCellsWeekendDisabled,'   +
            'td.monInputDate,'              +
            'td.monInputDateHover,'         +
            'td.monInputDate:hover,'        +
            'td.monInputDateDisabled,'      +
            'td.monWeekNo,'                 +
            'td.monWeeks                {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.mon                  {background-color:  #0040FF;}'  +
            '/* Drag Handle */'                                         +
            'td.monDrag                 {background-color:  #9999CC;'   +
                                        'color:             #CCCCFF;}'  +
            '/* Week number heading */'                                 +
            'td.monWeekNumberHead       {color:             #6666CC;}'  +
            '/* Week day headings */'                                   +
            'td.monWeek                 {color:             #CCCCCC;}'  +
            '/* Week numbers */'                                        +
            'td.monWeekNo               {background-color:  #776677;'   +
                                        'color:             #CCCCCC;}'  +
            '/* Enabled Days */'                                        +
            '/* Week Day */'                                            +
            'td.monCells                {background-color:  #A0FF00;'   +
                                        'color:             #000000;}'  +
            '/* Day matching the input date */'                         +
            'td.monInputDate            {background-color:  #CC9999;'   +
                                        'color:             #FF0000;}'  +
            '/* Weekend Day */'                                         +
            'td.monCellsWeekend         {background-color:  #A0FF00;'   +
                                        'color:             #CC6666;}'  +
            '/* Day outside the current Month */'                       +
            'td.monCellsExMonth         {background-color:  #CCCCCC;'   +
                                        'color:             #666666;}'  +
            '/* Today selector */'                                      +
            'td.monNow                  {background-color:  #6666CC;'   +
                                        'color:             #FFFFFF;}'  +
            '/* Clear Button */'                                        +
            'td.monClear                {padding:           0px;}'      +
            'input.monClear             {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.monCells:hover,'                                        +
            'td.monCellsHover           {background-color:  #FFFF00;'   +
                                        'cursor:            pointer;'   +
                                        'color:             #000000;}'  +
            '/* Day matching the input date */'                         +
            'td.monInputDate:hover,'                                    +
            'td.monInputDateHover       {background-color:  #FFFF00;'   +
                                        'cursor:            pointer;'   +
                                        'color:             #000000;}'  +
            '/* Weekend cells */'                                       +
            'td.monCellsWeekend:hover,'                                 +
            'td.monCellsWeekendHover    {background-color:  #FFFF00;'   +
                                        'cursor:            pointer;'   +
                                        'color:             #000000;}'  +
            '/* Day outside the current Month */'                       +
            'td.monCellsExMonth:hover,'                                 +
            'td.monCellsExMonthHover    {background-color:  #FFFF00;'   +
                                        'cursor:            pointer;'   +
                                        'color:             #000000;}'  +
            '/* Today selector */'                                      +
            'td.monNow:hover,'                                          +
            'td.monNowHover             {color:             #FFFF00;'   +
                                        'cursor:            pointer;'   +
                                        'font-weight:       bold;}'     +
            '/* Disabled cells */'                                      +
            '/* Week Day */'                                            +
            '/* Day matching the input date */'                         +
            'td.monInputDateDisabled    {background-color:  #999999;'   +
                                        'color:             #000000;}'  +
            'td.monCellsDisabled        {background-color:  #999999;'   +
                                        'color:             #000000;}'  +
            '/* Weekend Day */'                                         +
            'td.monCellsWeekendDisabled {background-color:  #999999;'   +
                                        'color:             #CC6666;}'  +
            '/* Day outside the current Month */'                       +
            'td.monCellsExMonthDisabled {background-color:  #999999;'   +
                                        'color:             #666666;}'  +
            'td.monNowDisabled          {background-color:  #6666CC;'   +
                                        'color:             #FFFFFF;}'  +
        '</style>'
                    );

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

    var monTargetEle,
        monTriggerEle,
        monMonthSum            = 0,
        monBlnFullInputDate    = false,
        monPassEnabledDay      = new Array(),
        monSeedDate            = new Date(),
        monParmActiveToday     = true,
        monWeekStart           = monWeekStart%7,
        monToday,
        monClear,
        monDrag,
        monArrMonthNames,
        monArrWeekInits,
        monInvalidDateMsg,
        monOutOfRangeMsg,
        monDoesNotExistMsg,
        monInvalidAlert,
        monDateDisablingError,
        monRangeDisablingError;

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

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

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

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

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

    String.prototype.monPadLeft =
        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()==monTriggerEle)?func.apply(this, args):null;
                        };
                    };

    function monID(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 monNextActionReturn, monNextAction;

    function showCal(monEle,monSource) {monShow(monEle,monSource);};
    function monShow(monEle,monSource)
        {if (!monSource) {monSource = window.event;}

         if (monSource.tagName)
            {var monSourceEle = monSource;

             if (monID('monIE'))  {window.event.cancelBubble = true;}
             else {monSourceEle.parentNode.addEventListener('click',monStopPropagation,false);}
            }
         else
            {var monSourceEle = (monSource.target)
                                    ?monSource.target
                                    :monSource.srcElement;

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

         monTriggerEle = monSourceEle;

         monParmActiveToday = true;

         for (var i=0;i<7;i++)
            {monPassEnabledDay[(i+7-monWeekStart)%7] = true;
             for (var j=2;j<arguments.length;j++)
                {if (arguments[j]==i)
                    {monPassEnabledDay[(i+7-monWeekStart)%7] = false;
                     if (monDateNow.getDay()==i) {monParmActiveToday = false;}
                    }
                }
            }

         monSeedDate = monDateNow;

         var monDateValue = '';

         if (monEle.value) {monDateValue = monEle.value.replace(/^\s+/,'').replace(/\s+$/,'');}
         else   {if (typeof monEle.value == 'undefined')
                    {var monChildNodes = monEle.childNodes;
                     for (var i=0;i<monChildNodes.length;i++)
                        {if (monChildNodes[i].nodeType == 3)
                            {monDateValue = monChildNodes[i].nodeValue.replace(/^\s+/,'').replace(/\s+$/,'');
                             if (monDateValue.length > 0)
                                {monTriggerEle.monTextNode = monChildNodes[i];
                                 monTriggerEle.monLength   = monChildNodes[i].nodeValue.length;
                                 break;
                                }
                            }
                        }
                    }
                }

         monSetDefaultLanguage();

         monID('monDragText').innerHTML = monDrag;

         monID('monMonths').options.length = 0;
         for (var i=0;i<monArrMonthNames.length;i++)
            {monID('monMonths').options[i] = new Option(monArrMonthNames[i],monArrMonthNames[i]);}

         monID('monYears').options.length = 0;
         for (var i=0;i<monDropDownYears;i++)
            {monID('monYears').options[i] =  new Option((monBaseYear+i),(monBaseYear+i));}

         for (var i=0;i<monArrWeekInits.length;i++)
            {monID('monWeekInit' + i).innerHTML = monArrWeekInits[(i+monWeekStart)%monArrWeekInits.length];}

         if (((new Date(monBaseYear + monDropDownYears, 0, 0)) > monDateNow &&
              (new Date(monBaseYear, 0, 0))                    < monDateNow) ||
             (monClearButton && (monEle.readOnly || monEle.disabled))
            )   {monID('monFoot').style.display = '';
                 monID('monNow').innerHTML = '<p onclick=monHide()>Kalender ausblenden';
                 monID('monClearButton').value = monClear;
                 if ((new Date(monBaseYear + monDropDownYears, 0, 0)) > monDateNow &&
                     (new Date(monBaseYear, 0, 0))                    < monDateNow
                    )   {monID('monNow').style.display = '';
                         if (monClearButton && (monEle.readOnly || monEle.disabled))
                                {monID('monClear').style.display   = '';
                                 monID('monClear').style.textAlign = 'left';
                                 monID('monNow').style.textAlign   = 'right';
                                }
                         else   {monID('monClear').style.display = 'none';
                                 monID('monNow').style.textAlign = 'center';
                                }
                        }
                 else   {monID('monClear').style.textAlign = 'center';
                         monID('monClear').style.display = '';
                         monID('monNow').style.display = 'none';
                        }
                }
         else   {monID('monFoot').style.display = 'none';}

         if (monDateValue.length==0)
            {
             monBlnFullInputDate=false;

             if ((new Date(monBaseYear+monDropDownYears,0,0))<monSeedDate ||
                 (new Date(monBaseYear,0,1))                 >monSeedDate
                )
                {monSeedDate = new Date(monBaseYear + Math.floor(monDropDownYears / 2), 5, 1);}
            }
         else
            {function monInputFormat()
                {var monArrSeed = new Array(),
                     monArrInput = monDateValue.split(new RegExp('[\\'+monArrDelimiters.join('\\')+']+','g'));

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

                 monBlnFullInputDate = false;

                 monDateOutputFormat = monDateOutputFormat.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 (monDateOutputFormat.search(template[i])>-1)
                        {result[monDateOutputFormat.search(template[i])] = template[i];}
                    }

                 var monDateSequence = result.join('');

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

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

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

                         if (monArrInput[0].length==monDateOutputFormat.length) {monBlnFullInputDate = true;}
                         break;
                        }
                     case 2:
                        {// Year and Month entry
                         monArrSeed[0] =
                             parseInt(monArrInput[monDateSequence.
                                                    replace(/D/i,'').
                                                    search(/Y/i)],10);  // Year
                         monArrSeed[1] = monArrInput[monDateSequence.
                                                    replace(/D/i,'').
                                                    search(/M/i)];      // Month
                         monArrSeed[2] = 1;                             // Day
                         break;
                        }
                     case 3:
                        {// Day Month and Year entry

                         monArrSeed[0] =
                             parseInt(monArrInput[monDateSequence.
                                                    search(/Y/i)],10);  // Year
                         monArrSeed[1] = monArrInput[monDateSequence.
                                                    search(/M/i)];      // Month
                         monArrSeed[2] =
                             parseInt(monArrInput[monDateSequence.
                                                    search(/D/i)],10);  // Day

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


                 var monExpValDay    = new RegExp('^(0?[1-9]|[1-2][0-9]|3[0-1])$'),
                     monExpValMonth  = new RegExp('^(0?[1-9]|1[0-2]|'        +
                                                  monArrMonthNames.join('|') +
                                                  ')$','i'),
                     monExpValYear   = new RegExp('^([0-9]{1,2}|[0-9]{4})$');


                 if (monExpValYear.exec(monArrSeed[0])  == null ||
                     monExpValMonth.exec(monArrSeed[1]) == null ||
                     monExpValDay.exec(monArrSeed[2])   == null
                    )
                    {if (monShowInvalidDateMsg)
                        {alert(monInvalidDateMsg  +
                               monInvalidAlert[0] + monDateValue +
                               monInvalidAlert[1]);}
                     monBlnFullInputDate = false;
                     monArrSeed[0] = monBaseYear +
                                     Math.floor(monDropDownYears/2); // Year
                     monArrSeed[1] = '6';                            // Month
                     monArrSeed[2] = 1;                              // Day
                    }


                 return monArrSeed;
                };


             monArrSeedDate = monInputFormat();


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


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

             monSeedDate = new Date(monArrSeedDate[0],monArrSeedDate[1]-1,monArrSeedDate[2]);
            }

         if (isNaN(monSeedDate))
            {if (monShowInvalidDateMsg) {alert(monInvalidDateMsg + monInvalidAlert[0] + monDateValue + monInvalidAlert[1]);}
             monSeedDate = new Date(monBaseYear + Math.floor(monDropDownYears/2),5,1);
             monBlnFullInputDate=false;
            }
         else
            {
             if ((new Date(monBaseYear,0,1)) > monSeedDate)
                {if (monBlnStrict && monShowOutOfRangeMsg) {alert(monOutOfRangeMsg);}
                 monSeedDate = new Date(monBaseYear,0,1);
                 monBlnFullInputDate=false;
                }
             else
                {if ((new Date(monBaseYear+monDropDownYears,0,0))<monSeedDate)
                    {if (monBlnStrict && monShowOutOfRangeMsg) {alert(monOutOfRangeMsg);}
                     monSeedDate = new Date(monBaseYear + Math.floor(monDropDownYears)-1,11,1);
                     monBlnFullInputDate=false;
                    }
                 else
                    {if (monBlnStrict && monBlnFullInputDate &&
                          (monSeedDate.getDate()      != monArrSeedDate[2] ||
                           (monSeedDate.getMonth()+1) != monArrSeedDate[1] ||
                           monSeedDate.getFullYear()  != monArrSeedDate[0]
                          )
                        )
                        {if (monShowDoesNotExistMsg) alert(monDoesNotExistMsg);
                         monSeedDate = new Date(monSeedDate.getFullYear(),monSeedDate.getMonth()-1,1);
                         monBlnFullInputDate=false;
                        }
                    }
                }
            }


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

                     if (monDisabledDates[i].length !=2)
                        {if (monShowRangeDisablingError)
                            {alert(monRangeDisablingError[0] + monDisabledDates[i] + monRangeDisablingError[1]);}
                         monPass = false;
                        }
                     else
                        {for (var j=0;j<monDisabledDates[i].length;j++)
                            {if (!((typeof monDisabledDates[i][j] == 'object') && (monDisabledDates[i][j].constructor == Date)))
                                {if (monShowRangeDisablingError)
                                    {alert(  monDateDisablingError[0] + monDisabledDates[i][j] + monDateDisablingError[1]);}
                                 monPass = false;
                                }
                            }
                        }

                     if (monPass && (monDisabledDates[i][0] > monDisabledDates[i][1])) {monDisabledDates[i].reverse();}
                    }
                 else
                    {if (monShowRangeDisablingError) {alert(monDateDisablingError[0] + monDisabledDates[i] + monDateDisablingError[1]);}}
                }
            }

         monMonthSum =  12*(monSeedDate.getFullYear()-monBaseYear)+monSeedDate.getMonth();

         monID('monYears' ).options.selectedIndex = Math.floor(monMonthSum/12);
         monID('monMonths').options.selectedIndex = (monMonthSum%12);
         monID('monDrag').style.display=(monAllowDrag)?'':'none';

         monShowMonth(0);

         monTargetEle=monEle;

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

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

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

         if (monAutoPosition)
             {var monWidth      = parseInt(monID('mon').offsetWidth, 10),
                  monHeight     = parseInt(monID('mon').offsetHeight,10),
                  monWindowLeft =
                     (document.body && document.body.scrollLeft)
                          ?document.body.scrollLeft                  //DOM compliant
                          :(document.documentElement && document.documentElement.scrollLeft)
                              ?document.documentElement.scrollLeft   //IE6+ standards compliant
                              :0,                                    //Failed
                  monWindowWidth =
                      (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
                  monWindowTop =
                      (document.body && document.body.scrollTop)
                          ?document.body.scrollTop                   //DOM compliant
                          :(document.documentElement && document.documentElement.scrollTop)
                              ?document.documentElement.scrollTop    //IE6+ standards compliant
                              :0,                                    //Failed
                  monWindowHeight =
                      (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 - monWidth + parseInt(monTargetEle.offsetWidth,10) >= monWindowLeft &&
                             offsetLeft + monWidth > monWindowLeft + monWindowWidth
                            )?(monWidth - parseInt(monTargetEle.offsetWidth,10)):0;

              offsetTop -= (offsetTop - monHeight - parseInt(monTargetEle.offsetHeight,10) >= monWindowTop &&
                            offsetTop + monHeight > monWindowTop + monWindowHeight
                           )?(monHeight + parseInt(monTargetEle.offsetHeight,10)):0;
             }

         monID('mon').style.top         = offsetTop+'px';
         monID('mon').style.left        = offsetLeft+'px';
         monID('monIframe').style.top   = offsetTop+'px';
         monID('monIframe').style.left  = offsetLeft+'px';

         monID('monIframe').style.width =(monID('mon').offsetWidth-(monID('monIE')?2:4))+'px';
         monID('monIframe').style.height=(monID('mon').offsetHeight-(monID('monIE')?2:4))+'px';
         monID('monIframe').style.visibility='inherit';

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

    function monHide()
        {monID('mon').style.visibility='hidden';
         monID('monIframe').style.visibility='hidden';
         if (typeof monNextAction!='undefined' && monNextAction!=null)
             {monNextActionReturn = monNextAction();
              // Explicit null set to prevent closure causing memory leak
              monNextAction = null;
             }
        };

    function monCancel(monEvt)
        {if (monClickToHide) {monHide();}
         monStopPropagation(monEvt);
        };

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

    function monBeginDrag(event)
        {var elementToDrag = monID('mon');

         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();
                }

         monStopPropagation(event);

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

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

             monID('monIframe').style.left = (monEvt.clientX - deltaX) + 'px';
             monID('monIframe').style.top  = (monEvt.clientY - deltaY) + 'px';

             monStopPropagation(monEvt);
            };

         function upHandler(monEvt)
            {if (!monEvt) monEvt = 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();
                    }

             monStopPropagation(monEvt);
            };
        };

    function monShowMonth(monBias)
        {

         var monShowDate  = new Date(Date.parse(new Date().toDateString())),
             monStartDate = new Date();

         monShowDate.setHours(12);

         monSelYears  = monID('monYears');
         monSelMonths = monID('monMonths');

         if (monSelYears.options.selectedIndex>-1)
            {monMonthSum=12*(monSelYears.options.selectedIndex)+monBias;
             if (monSelMonths.options.selectedIndex>-1) {monMonthSum+=monSelMonths.options.selectedIndex;}
            }
         else
            {if (monSelMonths.options.selectedIndex>-1) {monMonthSum+=monSelMonths.options.selectedIndex;}}

         monShowDate.setFullYear(monBaseYear + Math.floor(monMonthSum/12),(monMonthSum%12),1);

         monID('monWeek_').style.display=(monWeekNumberDisplay)?'':'none';

         if (window.opera)
            {monID('monMonths').style.display = 'inherit';
             monID('monYears' ).style.display = 'inherit';
           }

         monTemp = (12*parseInt((monShowDate.getFullYear()-monBaseYear),10)) + parseInt(monShowDate.getMonth(),10);

         if (monTemp > -1 && monTemp < (12*monDropDownYears))
            {monSelYears.options.selectedIndex=Math.floor(monMonthSum/12);
             monSelMonths.options.selectedIndex=(monMonthSum%12);

             monCurMonth = monShowDate.getMonth();

             monShowDate.setDate((((monShowDate.
                                    getDay()-monWeekStart)<0)?-6:1)+
                                 monWeekStart-monShowDate.getDay());

             var monCompareDateValue = new Date(monShowDate.getFullYear(),
                                                monShowDate.getMonth(),
                                                monShowDate.getDate()).valueOf();

             monStartDate = new Date(monShowDate);

             if ((new Date(monBaseYear + monDropDownYears, 0, 0)) > monDateNow &&
                 (new Date(monBaseYear, 0, 0))                    < monDateNow)
                {var monNow = monID('monNow');

                 function monNowOutput() {monSetOutput(monDateNow);};

                 if (monDisabledDates.length==0)
                    {if (monActiveToday && monParmActiveToday)
                        {monNow.onclick     = monNowOutput;
                         monNow.className   = 'monNow';

                         if (monID('monIE'))
                            {monNow.onmouseover  = monChangeClass;
                             monNow.onmouseout   = monChangeClass;
                            }

                        }
                     else
                        {monNow.onclick     = null;
                         monNow.className   = 'monNowDisabled';

                         if (monID('monIE'))
                            {monNow.onmouseover  = null;
                             monNow.onmouseout   = null;
                            }

                         if (document.addEventListener)
                                {monNow.addEventListener('click',monStopPropagation,false);}
                         else   {monNow.attachEvent('onclick',monStopPropagation);}
                        }
                    }
                 else
                    {for (var k=0;k<monDisabledDates.length;k++)
                        {if (!monActiveToday || !monParmActiveToday ||
                             ((typeof monDisabledDates[k] == 'object')                   &&
                                 (((monDisabledDates[k].constructor == Date)             &&
                                   monDateNow.valueOf() == monDisabledDates[k].valueOf()
                                  ) ||
                                  ((monDisabledDates[k].constructor == Array)               &&
                                   monDateNow.valueOf() >= monDisabledDates[k][0].valueOf() &&
                                   monDateNow.valueOf() <= monDisabledDates[k][1].valueOf()
                                  )
                                 )
                             )
                            )
                            {monNow.onclick     = null;
                             monNow.className   = 'monNowDisabled';

                             if (monID('monIE'))
                                {monNow.onmouseover  = null;
                                 monNow.onmouseout   = null;
                                }

                             if (document.addEventListener)
                                    {monNow.addEventListener('click',monStopPropagation,false);}
                             else   {monNow.attachEvent('onclick',monStopPropagation);}
                             break;
                            }
                         else
                            {monNow.onclick=monNowOutput;
                             monNow.className='monNow';

                             if (monID('monIE'))
                                {monNow.onmouseover  = monChangeClass;
                                 monNow.onmouseout   = monChangeClass;
                                }
                            }
                        }
                    }
                }

             function monSetOutput(monOutputDate)
                {if (typeof monTargetEle.value == 'undefined')
                      {monTriggerEle.monTextNode.replaceData(0,monTriggerEle.monLength,monOutputDate.monFormat(monDateOutputFormat));}
                 else {monTargetEle.value = monOutputDate.monFormat(monDateOutputFormat);}
                 monHide();
                };

             function monCellOutput(monEvt)
                {var monEle = monEventTrigger(monEvt),
                     monOutputDate = new Date(monStartDate);

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

                 monOutputDate.setDate(monStartDate.getDate() + parseInt(monEle.id.substr(8),10));

                 monSetOutput(monOutputDate);
                };

             function monChangeClass(monEvt)
                {var monEle = monEventTrigger(monEvt);

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

                 switch (monEle.className)
                    {case 'monCells':
                        monEle.className = 'monCellsHover';
                        break;
                     case 'monCellsHover':
                        monEle.className = 'monCells';
                        break;
                     case 'monCellsExMonth':
                        monEle.className = 'monCellsExMonthHover';
                        break;
                     case 'monCellsExMonthHover':
                        monEle.className = 'monCellsExMonth';
                        break;
                     case 'monCellsWeekend':
                        monEle.className = 'monCellsWeekendHover';
                        break;
                     case 'monCellsWeekendHover':
                        monEle.className = 'monCellsWeekend';
                        break;
                     case 'monNow':
                        monEle.className = 'monNowHover';
                        break;
                     case 'monNowHover':
                        monEle.className = 'monNow';
                        break;
                     case 'monInputDate':
                        monEle.className = 'monInputDateHover';
                        break;
                     case 'monInputDateHover':
                        monEle.className = 'monInputDate';
                    }

                 return true;
                }

             function monEventTrigger(monEvt)
                {if (!monEvt) {monEvt = event;}
                 return monEvt.target||monEvt.srcElement;
                };

             function monWeekNumber(monInDate)
                {// The base day in the week of the input date
                 var monInDateWeekBase = new Date(monInDate);

                 monInDateWeekBase.setDate(monInDateWeekBase.getDate()
                                            - monInDateWeekBase.getDay()
                                            + monWeekNumberBaseDay
                                            + ((monInDate.getDay()>
                                                monWeekNumberBaseDay)?7:0));

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

                 monFirstBaseDay.setDate(monFirstBaseDay.getDate()
                                            - monFirstBaseDay.getDay()
                                            + monWeekNumberBaseDay
                                        );

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

                 var monStartWeekOne = new Date(monFirstBaseDay
                                                - monWeekNumberBaseDay
                                                + monInDate.getDay());

                 if (monStartWeekOne > monFirstBaseDay)
                    {monStartWeekOne.setDate(monStartWeekOne.getDate()-7);}

                 var monWeekNo = '0' + (Math.round((monInDateWeekBase - monFirstBaseDay)/604800000,0) + 1);

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

             var monCells = monID('monCells');

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

                     for (j=1;j<monRows.childNodes.length;j++)
                        {var monCols = monRows.childNodes[j];
                         if (monCols.nodeType==1 && monCols.tagName=='TD')
                            {monRows.childNodes[j].innerHTML=
                                monShowDate.getDate();
                             var monCell=monRows.childNodes[j],
                                 monDisabled =
                                    ((monOutOfRangeDisable &&
                                        (monShowDate <
                                            (new Date(monBaseYear,0,1,
                                                      monShowDate.getHours()))
                                         ||
                                         monShowDate >
                                            (new Date(monBaseYear+
                                                      monDropDownYears,0,0,
                                                      monShowDate.getHours()))
                                        )
                                     ) ||
                                     (monOutOfMonthDisable &&
                                        (monShowDate <
                                            (new Date(monShowDate.getFullYear(),
                                                      monCurMonth,1,
                                                      monShowDate.getHours()))
                                         ||
                                         monShowDate >
                                            (new Date(monShowDate.getFullYear(),
                                                      monCurMonth+1,0,
                                                      monShowDate.getHours()))
                                        )
                                     )
                                    )?true:false;

                             monCell.style.visibility =
                                (monOutOfMonthHide &&
                                    (monShowDate <
                                        (new Date(monShowDate.getFullYear(),
                                                  monCurMonth,1,
                                                  monShowDate.getHours()))
                                     ||
                                     monShowDate >
                                        (new Date(monShowDate.getFullYear(),
                                                  monCurMonth+1,0,
                                                  monShowDate.getHours()))
                                    )
                                )?'hidden':'inherit';

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

                             if (monDisabled ||
                                 !monEnabledDay[j-1+(7*((i*monCells.childNodes.length)/6))] ||
                                 !monPassEnabledDay[(j-1+(7*(i*monCells.childNodes.length/6)))%7]
                                )
                                {monRows.childNodes[j].onclick = null;

                                 if (monID('monIE'))
                                    {monRows.childNodes[j].onmouseover  = null;
                                     monRows.childNodes[j].onmouseout   = null;
                                    }

                                 monCell.className=
                                    (monShowDate.getMonth()!=monCurMonth)
                                        ?'monCellsExMonthDisabled'
                                        :(monBlnFullInputDate &&
                                          monShowDate.toDateString()==
                                          monSeedDate.toDateString())
                                            ?'monInputDateDisabled'
                                            :(monShowDate.getDay()%6==0)
                                                ?'monCellsWeekendDisabled'
                                                :'monCellsDisabled';

                                 monCell.style.borderColor =
                                     (monFormatTodayCell && monShowDate.toDateString()==monDateNow.toDateString())
                                        ?monTodayCellBorderColour
                                        :(monCell.currentStyle)
                                            ?monCell.currentStyle['backgroundColor']
                                            :(window.getComputedStyle)
                                                ?document.defaultView.getComputedStyle(monCell,null).getPropertyValue('background-color')
                                                :'';
                                }
                             else
                                {monRows.childNodes[j].onclick=monCellOutput;

                                 if (monID('monIE'))
                                    {monRows.childNodes[j].onmouseover  = monChangeClass;
                                     monRows.childNodes[j].onmouseout   = monChangeClass;
                                    }

                                 monCell.className=
                                     (monShowDate.getMonth()!=monCurMonth)
                                        ?'monCellsExMonth'
                                        :(monBlnFullInputDate &&
                                          monShowDate.toDateString()==
                                          monSeedDate.toDateString())
                                            ?'monInputDate'
                                            :(monShowDate.getDay()%6==0)
                                                ?'monCellsWeekend'
                                                :'monCells';

                                 monCell.style.borderColor =
                                     (monFormatTodayCell && monShowDate.toDateString() == monDateNow.toDateString())
                                        ?monTodayCellBorderColour
                                        :(monCell.currentStyle)
                                            ?monCell.currentStyle['backgroundColor']
                                            :(window.getComputedStyle)
                                                ?document.defaultView.getComputedStyle(monCell,null).getPropertyValue('background-color')
                                                :'';
                               }

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

         if (window.opera)
            {monID('monMonths').style.display = 'inline';
             monID('monYears' ).style.display = 'inline';
             monID('mon').style.visibility='hidden';
             monID('mon').style.visibility='inherit';
           }
        };

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

    document.writeln("<!--[if IE]><div id='monIE'></div><![endif]-->");
    document.writeln("<!--[if lt IE 7]><div id='monIElt7'></div><![endif]-->");
    document.write(
     "<iframe class='mon' " + (monID('monIElt7')?"src='/monblank.html '":'') +
             "id='monIframe' name='monIframe' frameborder='0'>" +
     "</iframe>" +
     "<table id='mon' class='mon'>" +
       "<tr class='mon'>" +
         "<td class='mon'>" +
           "<table class='monHead' id='monHead' width='100%' " +
                    "cellspacing='0' cellpadding='0'>" +
            "<tr id='monDrag' style='display:none;'>" +
                "<td colspan='4' class='monDrag' " +
                    "onmousedown='monBeginDrag(event);'>" +
                    "<span id='monDragText'></span>" +
                "</td>" +
            "</tr>" +
            "<tr class='monHead' >" +
                 "<td class='monHead'>" +
                    "<input class='monHead' id='monHeadLeft' type='button' value='<' " +
                            "onclick='monShowMonth(-1);'  /></td>" +
                 "<td class='monHead'>" +
                    "<select id='monMonths' class='monHead' " +
                            "onchange='monShowMonth(0);'>" +
                    "</select>" +
                 "</td>" +
                 "<td class='monHead'>" +
                    "<select id='monYears' class='monHead' " +
                            "onchange='monShowMonth(0);'>" +
                    "</select>" +
                 "</td>" +
                 "<td class='monHead'>" +
                    "<input class='monHead' id='monHeadRight' type='button' value='>' " +
                            "onclick='monShowMonth(1);' /></td>" +
                "</tr>" +
              "</table>" +
            "</td>" +
          "</tr>" +
          "<tr class='mon'>" +
            "<td class='mon'>" +
              "<table class='monCells' align='center'>" +
                "<thead>" +
                  "<tr><td class='monWeekNumberHead' id='monWeek_' ></td>");

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

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

    for (i=0;i<6;i++)
        {document.write(
                    "<tr>" +
                      "<td class='monWeekNo' id='monWeek_" + i + "'></td>");
         for (j=0;j<7;j++)
            {document.write(
                        "<td class='monCells' id='monCell_" + (j+(i*7)) +
                        "'></td>");
            }

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

    document.write(
                "</tbody>" +
                "<tfoot>" +
                  "<tr id='monFoot'>" +
                    "<td colspan='8' style='padding:0px;'>" +
                      "<table width='100%'>" +
                        "<tr>" +
                          "<td id='monClear' class='monClear'>" +
                            "<input type='button' id='monClearButton' class='monClear' " +
                                   "onclick='monTargetEle.value = \"\";monHide();' />" +
                          "</td>" +
                          "<td class='monNow' id='monNow'></td>" +
                        "</tr>" +
                      "</table>" +
                    "</td>" +
                  "</tr>" +
                "</tfoot>" +
              "</table>" +
            "</td>" +
          "</tr>" +
        "</table>");

    if (document.addEventListener)
            {monID('mon'         ).addEventListener('click',monCancel,false);
             monID('monHeadLeft' ).addEventListener('click',monStopPropagation,false);
             monID('monMonths'   ).addEventListener('click',monStopPropagation,false);
             monID('monMonths'   ).addEventListener('change',monStopPropagation,false);
             monID('monYears'    ).addEventListener('click',monStopPropagation,false);
             monID('monYears'    ).addEventListener('change',monStopPropagation,false);
             monID('monHeadRight').addEventListener('click',monStopPropagation,false);
            }
    else    {monID('mon'         ).attachEvent('onclick',monCancel);
             monID('monHeadLeft' ).attachEvent('onclick',monStopPropagation);
             monID('monMonths'   ).attachEvent('onclick',monStopPropagation);
             monID('monMonths'   ).attachEvent('onchange',monStopPropagation);
             monID('monYears'    ).attachEvent('onclick',monStopPropagation);
             monID('monYears'    ).attachEvent('onchange',monStopPropagation);
             monID('monHeadRight').attachEvent('onclick',monStopPropagation);
            }

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

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

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