361. File Comparison Report

Produced on Mon May 12 13:05:54 2008 UTC. This report uses XHTML and CSS2, and is best viewed with a reasonably standards compliant browser such as the latest version of Firefox or Internet Explorer. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

361.1 Files compared

# Location File Last Modified
1 Mon May 12 13:05:54 2008 UTC
2 Dolphin-v.6.1.0\plugins\jquery ui.datepicker.js Thu Mar 27 04:17:52 2008 UTC

361.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 1 1553
Removed 0 0

361.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

361.4 Active regular expressions

No regular expressions were active.

361.5 Comparison detail

    1   /* jQuery  UI Date Pi cker v3.4  - previous ly jQuery  Calendar
    2      Written  by Marc G rabanski ( m@marcgrab anski.com)  and Keith  Wood (kbw ood@virgin broadband. com.au).
    3  
    4      Copyrig ht (c) 200 7 Marc Gra banski (ht tp://marcg rabanski.c om/code/ui -datepicke r)
    5      Dual li censed und er the MIT  (MIT-LICE NSE.txt)
    6      and GPL  (GPL-LICE NSE.txt) l icenses.
    7      Date: 0 9-03-2007   */
    8  
    9   /* Date pi cker manag er.
    10      Use the  singleton  instance  of this cl ass, $.dat epicker, t o interact  with the  date picke r.
    11      Setting s for (gro ups of) da te pickers  are maint ained in a n instance  object
    12      (Datepi ckerInstan ce), allow ing multip le differe nt setting s on the s ame page.  */
    13      
    14   (function( $) { // hi de the nam espace
    15  
    16   function D atepicker( ) {
    17       this.d ebug = fal se; // Cha nge this t o true to  start debu gging
    18       this._ nextId = 0 ; // Next  ID for a d ate picker  instance
    19       this._ inst = [];  // List o f instance s indexed  by ID
    20       this._ curInst =  null; // T he current  instance  in use
    21       this._ disabledIn puts = [];  // List o f date pic ker inputs  that have  been disa bled
    22       this._ datepicker Showing =  false; //  True if th e popup pi cker is sh owing , fa lse if not
    23       this._ inDialog =  false; //  True if s howing wit hin a "dia log", fals e if not
    24       this.r egional =  []; // Ava ilable reg ional sett ings, inde xed by lan guage code
    25       this.r egional['' ] = { // D efault reg ional sett ings
    26           cl earText: ' Clear', //  Display t ext for cl ear link
    27           cl earStatus:  'Erase th e current  date', //  Status tex t for clea r link
    28           cl oseText: ' Close', //  Display t ext for cl ose link
    29           cl oseStatus:  'Close wi thout chan ge', // St atus text  for close  link
    30           pr evText: '& #x3c;Prev' , // Displ ay text fo r previous  month lin k
    31           pr evStatus:  'Show the  previous m onth', //  Status tex t for prev ious month  link
    32           ne xtText: 'N ext>' , // Displ ay text fo r next mon th link
    33           ne xtStatus:  'Show the  next month ', // Stat us text fo r next mon th link
    34           cu rrentText:  'Today',  // Display  text for  current mo nth link
    35           cu rrentStatu s: 'Show t he current  month', / / Status t ext for cu rrent mont h link
    36           mo nthNames:  ['January' ,'February ','March', 'April','M ay','June' ,
    37                'July',' August','S eptember', 'October', 'November' ,'December '], // Nam es of mont hs for dro p-down and  formattin g
    38           mo nthNamesSh ort: ['Jan ', 'Feb',  'Mar', 'Ap r', 'May',  'Jun', 'J ul', 'Aug' , 'Sep', ' Oct', 'Nov ', 'Dec'],  // For fo rmatting
    39           mo nthStatus:  'Show a d ifferent m onth', //  Status tex t for sele cting a mo nth
    40           ye arStatus:  'Show a di fferent ye ar', // St atus text  for select ing a year
    41           we ekHeader:  'Wk', // H eader for  the week o f the year  column
    42           we ekStatus:  'Week of t he year',  // Status  text for t he week of  the year  column
    43           da yNames: [' Sunday', ' Monday', ' Tuesday',  'Wednesday ', 'Thursd ay', 'Frid ay', 'Satu rday'], //  For forma tting
    44           da yNamesShor t: ['Sun',  'Mon', 'T ue', 'Wed' , 'Thu', ' Fri', 'Sat '], // For  formattin g
    45           da yNamesMin:  ['Su','Mo ','Tu','We ','Th','Fr ','Sa'], / / Column h eadings fo r days sta rting at S unday
    46           da yStatus: ' Set DD as  first week  day', //  Status tex t for the  day of the  week sele ction
    47           da teStatus:  'Select DD , M d', //  Status te xt for the  date sele ction
    48           da teFormat:  'mm/dd/yy' , // See f ormat opti ons on par seDate
    49           fi rstDay: 0,  // The fi rst day of  the week,  Sun = 0,  Mon = 1, . ..
    50           in itStatus:  'Select a  date', //  Initial St atus text  on opening
    51           is RTL: false  // True i f right-to -left lang uage, fals e if left- to-right
    52       };
    53       this._ defaults =  { // Glob al default s for all  the date p icker inst ances
    54           sh owOn: 'foc us', // 'f ocus' for  popup on f ocus,
    55                // 'butt on' for tr igger butt on, or 'bo th' for ei ther
    56           sh owAnim: 's how', // N ame of jQu ery animat ion for po pup
    57           de faultDate:  null, //  Used when  field is b lank: actu al date,
    58                // +/-nu mber for o ffset from  today, nu ll for tod ay
    59           ap pendText:  '', // Dis play text  following  the input  box, e.g.  showing th e format
    60           bu ttonText:  '...', //  Text for t rigger but ton
    61           bu ttonImage:  '', // UR L for trig ger button  image
    62           bu ttonImageO nly: false , // True  if the ima ge appears  alone, fa lse if it  appears on  a button
    63           cl oseAtTop:  true, // T rue to hav e the clea r/close at  the top,
    64                // false  to have t hem at the  bottom
    65           ma ndatory: f alse, // T rue to hid e the Clea r link, fa lse to inc lude it
    66           hi deIfNoPrev Next: fals e, // True  to hide n ext/previo us month l inks
    67                // if no t applicab le, false  to just di sable them
    68           ch angeMonth:  true, //  True if mo nth can be  selected  directly,  false if o nly prev/n ext
    69           ch angeYear:  true, // T rue if yea r can be s elected di rectly, fa lse if onl y prev/nex t
    70           ye arRange: ' -10:+10',  // Range o f years to  display i n drop-dow n,
    71                // eithe r relative  to curren t year (-n n:+nn) or  absolute ( nnnn:nnnn)
    72           ch angeFirstD ay: true,  // True to  click on  day name t o change,  false to r emain as s et
    73           sh owOtherMon ths: false , // True  to show da tes in oth er months,  false to  leave blan k
    74           sh owWeeks: f alse, // T rue to sho w week of  the year,  false to o mit
    75           ca lculateWee k: this.is o8601Week,  // How to  calculate  the week  of the yea r,
    76                // takes  a Date an d returns  the number  of the we ek for it
    77           sh ortYearCut off: '+10' , // Short  year valu es < this  are in the  current c entury,
    78                // > thi s are in t he previou s century,  
    79                // strin g value st arting wit h '+' for  current ye ar + value
    80           sh owStatus:  false, //  True to sh ow status  bar at bot tom, false  to not sh ow it
    81           st atusForDat e: this.da teStatus,  // Functio n to provi de status  text for a  date -
    82                // takes  date and  instance a s paramete rs, return s display  text
    83           mi nDate: nul l, // The  earliest s electable  date, or n ull for no  limit
    84           ma xDate: nul l, // The  latest sel ectable da te, or nul l for no l imit
    85           sp eed: 'norm al', // Sp eed of dis play/closu re
    86           be foreShowDa y: null, / / Function  that take s a date a nd returns  an array  with
    87                // [0] =  true if s electable,  false if  not,
    88                // [1] =  custom CS S class na me(s) or ' ', e.g. $. datepicker .noWeekend s
    89           be foreShow:  null, // F unction th at takes a n input fi eld and
    90                // retur ns a set o f custom s ettings fo r the date  picker
    91           on Select: nu ll, // Def ine a call back funct ion when a  date is s elected
    92           on Close: nul l, // Defi ne a callb ack functi on when th e datepick er is clos ed
    93           nu mberOfMont hs: 1, //  Number of  months to  show at a  time
    94           st epMonths:  1, // Numb er of mont hs to step  back/forw ard
    95           ra ngeSelect:  false, //  Allows fo r selectin g a date r ange on on e date pic ker
    96           ra ngeSeparat or: ' - '  // Text be tween two  dates in a  range
    97       };
    98       $.exte nd(this._d efaults, t his.region al['']);
    99       this._ datepicker Div = $('< div id="da tepicker_d iv"></div> ');
    100   }
    101  
    102   $.extend(D atepicker. prototype,  {
    103       /* Cla ss name ad ded to ele ments to i ndicate al ready conf igured wit h a date p icker. */
    104       marker ClassName:  'hasDatep icker',
    105  
    106       /* Deb ug logging  (if enabl ed). */
    107       log: f unction ()  {
    108           if  (this.deb ug) {
    109                console. log.apply( '', argume nts);
    110           }
    111       },
    112       
    113       /* Reg ister a ne w date pic ker instan ce - with  custom set tings. */
    114       _regis ter: funct ion(inst)  {
    115           va r id = thi s._nextId+ +;
    116           th is._inst[i d] = inst;
    117           re turn id;
    118       },
    119  
    120       /* Ret rieve a pa rticular d ate picker  instance  based on i ts ID. */
    121       _getIn st: functi on(id) {
    122           re turn this. _inst[id]  || id;
    123       },
    124  
    125       /* Ove rride the  default se ttings for  all insta nces of th e date pic ker. 
    126          @pa ram  setti ngs  objec t - the ne w settings  to use as  defaults  (anonymous  object)
    127          @re turn the m anager obj ect */
    128       setDef aults: fun ction(sett ings) {
    129           ex tendRemove (this._def aults, set tings || { });
    130           re turn this;
    131       },
    132  
    133       /* Att ach the da te picker  to a jQuer y selectio n.
    134          @pa ram  targe t    eleme nt - the t arget inpu t field or  division  or span
    135          @pa ram  setti ngs  objec t - the ne w settings  to use fo r this dat e picker i nstance (a nonymous)  */
    136       _attac hDatepicke r: functio n(target,  settings)  {
    137           //  check for  settings  on the con trol itsel f - in nam espace 'da te:'
    138           va r inlineSe ttings = n ull;
    139           fo r (attrNam e in this. _defaults)  {
    140                var attr Value = ta rget.getAt tribute('d ate:' + at trName);
    141                if (attr Value) {
    142                    inli neSettings  = inlineS ettings ||  {};
    143                    try  {
    144                         inlineSett ings[attrN ame] = eva l(attrValu e);
    145                    }
    146                    catc h (err) {
    147                         inlineSett ings[attrN ame] = att rValue;
    148                    }
    149                }
    150           }
    151           va r nodeName  = target. nodeName.t oLowerCase ();
    152           if  (nodeName  == 'input ') {
    153                var inst Settings =  (inlineSe ttings ? $ .extend($. extend({},  settings  || {}),
    154                    inli neSettings  || {}) :  settings);  // clone  and custom ise
    155                var inst  = (inst & & !inlineS ettings ?  inst :
    156                    new  Datepicker Instance(i nstSetting s, false)) ;
    157                this._co nnectDatep icker(targ et, inst);
    158           } 
    159           el se if (nod eName == ' div' || no deName ==  'span') {
    160                var inst Settings =  $.extend( $.extend({ }, setting s || {}),
    161                    inli neSettings  || {}); / / clone an d customis e
    162                var inst  = new Dat epickerIns tance(inst Settings,  true);
    163                this._in lineDatepi cker(targe t, inst);
    164           }
    165       },
    166  
    167       /* Det ach a date picker fro m its cont rol.
    168          @pa ram  targe t    eleme nt - the t arget inpu t field or  division  or span */
    169       _destr oyDatepick er: functi on(target)  {
    170           va r $target  = $(target );
    171           va r nodeName  = target. nodeName.t oLowerCase ();
    172           va r calId =  target._ca lId;
    173           ta rget._calI d = null;
    174           if  (nodeName  == 'input ') {
    175                $target. siblings(' .datepicke r_append') .replaceWi th('');
    176                $target. siblings(' .datepicke r_trigger' ).replaceW ith('');
    177                $target. removeClas s(this.mar kerClassNa me).
    178                    unbi nd('focus' , this._sh owDatepick er).
    179                    unbi nd('keydow n', this._ doKeyDown) .
    180                    unbi nd('keypre ss', this. _doKeyPres s);
    181                var wrap per = $tar get.parent s('.datepi cker_wrap' );
    182                if (wrap per) {
    183                    wrap per.replac eWith(wrap per.html() );
    184                }
    185           } 
    186           el se if (nod eName == ' div' || no deName ==  'span') {
    187                $target. removeClas s(this.mar kerClassNa me).empty( );
    188           }
    189           if  ($('input [_calId='  + calId +  ']').lengt h == 0) {
    190                // clean  up if las t for this  ID
    191                this._in st[calId]  = null;
    192           }
    193       },
    194  
    195       /* Ena ble the da te picker  to a jQuer y selectio n.
    196          @pa ram  targe t    eleme nt - the t arget inpu t field or  division  or span */
    197       _enabl eDatepicke r: functio n(target)  {
    198           ta rget.disab led = fals e;
    199           $( target).si blings('bu tton.datep icker_trig ger').each (function( ) { this.d isabled =  false; });
    200           $( target).si blings('im g.datepick er_trigger ').css({op acity: '1. 0', cursor : ''});
    201           va r $target  = target;
    202           th is._disabl edInputs =  $.map(thi s._disable dInputs,
    203                function (value) {  return (va lue == $ta rget ? nul l : value) ; }); // d elete entr y
    204       },
    205  
    206       /* Dis able the d ate picker  to a jQue ry selecti on.
    207          @pa ram  targe t    eleme nt - the t arget inpu t field or  division  or span */
    208       _disab leDatepick er: functi on(target)  {
    209           ta rget.disab led = true ;
    210           $( target).si blings('bu tton.datep icker_trig ger').each (function( ) { this.d isabled =  true; });
    211           $( target).si blings('im g.datepick er_trigger ').css({op acity: '0. 5', cursor : 'default '});
    212           va r $target  = target;
    213           th is._disabl edInputs =  $.map($.d atepicker. _disabledI nputs,
    214                function (value) {  return (va lue == $ta rget ? nul l : value) ; }); // d elete entr y
    215           th is._disabl edInputs[$ .datepicke r._disable dInputs.le ngth] = ta rget;
    216       },
    217  
    218       /* Is  the first  field in a  jQuery co llection d isabled as  a datepic ker?
    219          @pa ram  targe t    eleme nt - the t arget inpu t field or  division  or span
    220          @re turn boole an - true  if disable d, false i f enabled  */
    221       _isDis abledDatep icker: fun ction(targ et) {
    222           if  (!target)  {
    223                return f alse;
    224           }
    225           fo r (var i =  0; i < th is._disabl edInputs.l ength; i++ ) {
    226                if (this ._disabled Inputs[i]  == target)  {
    227                    retu rn true;
    228                }
    229           }
    230           re turn false ;
    231       },
    232  
    233       /* Upd ate the se ttings for  a date pi cker attac hed to an  input fiel d or divis ion.
    234          @pa ram  targe t  element  - the tar get input  field or d ivision or  span
    235          @pa ram  name     string  - the name  of the se tting to c hange or
    236                            object  - the new  settings t o update
    237          @pa ram  value    any - t he new val ue for the  setting ( omit if ab ove is an  object) */
    238       _chang eDatepicke r: functio n(target,  name, valu e) {
    239           va r settings  = name ||  {};
    240           if  (typeof n ame == 'st ring') {
    241                settings  = {};
    242                settings [name] = v alue;
    243           }
    244           va r inst = t his._getIn st(target. _calId);
    245           if  (inst) {
    246                extendRe move(inst. _settings,  settings) ;
    247                this._up dateDatepi cker(inst) ;
    248           }
    249       },
    250  
    251       /* Set  the dates  for a jQu ery select ion.
    252          @pa ram  targe t   elemen t - the ta rget input  field or  division o r span
    253          @pa ram  date      Date -  the new d ate
    254          @pa ram  endDa te  Date -  the new e nd date fo r a range  (optional)  */
    255       _setDa teDatepick er: functi on(target,  date, end Date) {
    256           va r inst = t his._getIn st(target. _calId);
    257           if  (inst) {
    258                inst._se tDate(date , endDate) ;
    259                this._up dateDatepi cker(inst) ;
    260           }
    261       },
    262  
    263       /* Get  the date( s) for the  first ent ry in a jQ uery selec tion.
    264          @pa ram  targe t  element  - the tar get input  field or d ivision or  span
    265          @re turn Date  - the curr ent date o r
    266                   Date[ 2] - the c urrent dat es for a r ange */
    267       _getDa teDatepick er: functi on(target)  {
    268           va r inst = t his._getIn st(target. _calId);
    269           re turn (inst  ? inst._g etDate() :  null);
    270       },
    271  
    272       /* Han dle keystr okes. */
    273       _doKey Down: func tion(e) {
    274           va r inst = $ .datepicke r._getInst (this._cal Id);
    275           if  ($.datepi cker._date pickerShow ing) {
    276                switch ( e.keyCode)  {
    277                    case  9:  $.dat epicker.hi deDatepick er('');
    278                             break;  // hide o n tab out
    279                    case  13: $.dat epicker._s electDay(i nst, inst. _selectedM onth, inst ._selected Year,
    280                                 $( 'td.datepi cker_daysC ellOver',  inst._date pickerDiv) [0]);
    281                             return  false; //  don't sub mit the fo rm
    282                             break;  // select  the value  on enter
    283                    case  27: $.dat epicker.hi deDatepick er(inst._g et('speed' ));
    284                             break;  // hide o n escape
    285                    case  33: $.dat epicker._a djustDate( inst,
    286                                 (e .ctrlKey ?  -1 : -ins t._get('st epMonths') ), (e.ctrl Key ? 'Y'  : 'M'));
    287                             break;  // previo us month/y ear on pag e up/+ ctr l
    288                    case  34: $.dat epicker._a djustDate( inst,
    289                                 (e .ctrlKey ?  +1 : +ins t._get('st epMonths') ), (e.ctrl Key ? 'Y'  : 'M'));
    290                             break;  // next m onth/year  on page do wn/+ ctrl
    291                    case  35: if (e .ctrlKey)  $.datepick er._clearD ate(inst);
    292                             break;  // clear  on ctrl+en d
    293                    case  36: if (e .ctrlKey)  $.datepick er._gotoTo day(inst);
    294                             break;  // curren t on ctrl+ home
    295                    case  37: if (e .ctrlKey)  $.datepick er._adjust Date(inst,  -1, 'D');
    296                             break;  // -1 day  on ctrl+l eft
    297                    case  38: if (e .ctrlKey)  $.datepick er._adjust Date(inst,  -7, 'D');
    298                             break;  // -1 wee k on ctrl+ up
    299                    case  39: if (e .ctrlKey)  $.datepick er._adjust Date(inst,  +1, 'D');
    300                             break;  // +1 day  on ctrl+r ight
    301                    case  40: if (e .ctrlKey)  $.datepick er._adjust Date(inst,  +7, 'D');
    302                             break;  // +1 wee k on ctrl+ down
    303                }
    304           }
    305           el se if (e.k eyCode ==  36 && e.ct rlKey) { / / display  the date p icker on c trl+home
    306                $.datepi cker._show Datepicker (this);
    307           }
    308       },
    309  
    310       /* Fil ter entere d characte rs - based  on date f ormat. */
    311       _doKey Press: fun ction(e) {
    312           va r inst = $ .datepicke r._getInst (this._cal Id);
    313           va r chars =  $.datepick er._possib leChars(in st._get('d ateFormat' ));
    314           va r chr = St ring.fromC harCode(e. charCode = = undefine d ? e.keyC ode : e.ch arCode);
    315           re turn e.ctr lKey || (c hr < ' ' | | !chars | | chars.in dexOf(chr)  > -1);
    316       },
    317  
    318       /* Att ach the da te picker  to an inpu t field. * /
    319       _conne ctDatepick er: functi on(target,  inst) {
    320           va r input =  $(target);
    321           if  (input.is ('.' + thi s.markerCl assName))  {
    322                return;
    323           }
    324           va r appendTe xt = inst. _get('appe ndText');
    325           va r isRTL =  inst._get( 'isRTL');
    326           if  (appendTe xt) {
    327                if (isRT L) {
    328                    inpu t.before(' <span clas s="datepic ker_append ">' + appe ndText + ' </span>');
    329                }
    330                else {
    331                    inpu t.after('< span class ="datepick er_append" >' + appen dText + '< /span>');
    332                }
    333           }
    334           va r showOn =  inst._get ('showOn') ;
    335           if  (showOn = = 'focus'  || showOn  == 'both')  { // pop- up date pi cker when  in the mar ked field
    336                input.fo cus(this._ showDatepi cker);
    337           }
    338           if  (showOn = = 'button'  || showOn  == 'both' ) { // pop -up date p icker when  button cl icked
    339                var butt onText = i nst._get(' buttonText ');
    340                var butt onImage =  inst._get( 'buttonIma ge');
    341                var trig ger = $(in st._get('b uttonImage Only') ? ' <img class ="datepick er_trigger " src="' +
    342                    butt onImage +  '" alt="'  + buttonTe xt + '" ti tle="' + b uttonText  + '"/>' :
    343                    '<bu tton type= "button" c lass="date picker_tri gger">' +  (buttonIma ge != '' ?
    344                    '<im g src="' +  buttonIma ge + '" al t="' + but tonText +  '" title=" ' + button Text + '"/ >' :
    345                    butt onText) +  '</button> ');
    346                input.wr ap('<span  class="dat epicker_wr ap"></span >');
    347                if (isRT L) {
    348                    inpu t.before(t rigger);
    349                }
    350                else {
    351                    inpu t.after(tr igger);
    352                }
    353                trigger. click(func tion() {
    354                    if ( $.datepick er._datepi ckerShowin g && $.dat epicker._l astInput = = target)  {
    355                         $.datepick er.hideDat epicker();
    356                    } el se {
    357                         $.datepick er._showDa tepicker(t arget);
    358                    }
    359                });
    360           }
    361           in put.addCla ss(this.ma rkerClassN ame).keydo wn(this._d oKeyDown). keypress(t his._doKey Press);
    362           in put.bind(" setData.da tepicker",  function( event, key , value) {
    363                inst._se ttings[key ] = value;
    364           }) .bind("get Data.datep icker", fu nction(eve nt, key) {
    365                return i nst._get(k ey);
    366           }) ;
    367           in put[0]._ca lId = inst ._id;
    368       },
    369  
    370       /* Att ach an inl ine date p icker to a  div. */
    371       _inlin eDatepicke r: functio n(target,  inst) {
    372           va r input =  $(target);
    373           if  (input.is ('.' + thi s.markerCl assName))  {
    374                return;
    375           }
    376           in put.addCla ss(this.ma rkerClassN ame).appen d(inst._da tepickerDi v);
    377           in put.bind(" setData.da tepicker",  function( event, key , value){
    378                inst._se ttings[key ] = value;
    379           }) .bind("get Data.datep icker", fu nction(eve nt, key){
    380                return i nst._get(k ey);
    381           }) ;
    382           in put[0]._ca lId = inst ._id;
    383           th is._update Datepicker (inst);
    384           /*  @todo: fi x _inlineS how automa tic resizi ng
    385                - Endles s loop bug  in IE6.  
    386                - inst._ datepicker Div.resize  doesn't e ver fire i n firefox.   */
    387           //  inst._dat epickerDiv .resize(fu nction() {  $.datepic ker._inlin eShow(inst ); });
    388       },
    389  
    390       /* Tid y up after  displayin g the date  picker. * /
    391       _inlin eShow: fun ction(inst ) {
    392           va r numMonth s = inst._ getNumberO fMonths();  // fix wi dth for dy namic numb er of date  pickers
    393           in st._datepi ckerDiv.wi dth(numMon ths[1] * $ ('.datepic ker', inst ._datepick erDiv[0]). width());
    394       }, 
    395  
    396       /* Pop -up the da te picker  in a "dial og" box.
    397          @pa ram  dateT ext  strin g - the in itial date  to displa y (in the  current fo rmat)
    398          @pa ram  onSel ect  funct ion - the  function(d ateText) t o call whe n a date i s selected
    399          @pa ram  setti ngs  objec t - update  the dialo g date pic ker instan ce's setti ngs (anony mous objec t)
    400          @pa ram  pos        int[2 ] - coordi nates for  the dialog 's positio n within t he screen  or
    401                              event  - with x/ y coordina tes or
    402                              leave  empty for  default ( screen cen tre)
    403          @re turn the m anager obj ect */
    404       dialog Datepicker : function (dateText,  onSelect,  settings,  pos) {
    405           va r inst = t his._dialo gInst; //  internal i nstance
    406           if  (!inst) {
    407                inst = t his._dialo gInst = ne w Datepick erInstance ({}, false );
    408                this._di alogInput  = $('<inpu t type="te xt" size=" 1" style=" position:  absolute;  top: -100p x;"/>');
    409                this._di alogInput. keydown(th is._doKeyD own);
    410                $('body' ).append(t his._dialo gInput);
    411                this._di alogInput[ 0]._calId  = inst._id ;
    412           }
    413           ex tendRemove (inst._set tings, set tings || { });
    414           th is._dialog Input.val( dateText);
    415  
    416           th is._pos =  (pos ? (po s.length ?  pos : [po s.pageX, p os.pageY])  : null);
    417           if  (!this._p os) {
    418                var brow serWidth =  window.in nerWidth | | document .documentE lement.cli entWidth | |
    419                    docu ment.body. clientWidt h;
    420                var brow serHeight  = window.i nnerHeight  || docume nt.documen tElement.c lientHeigh t ||
    421                    docu ment.body. clientHeig ht;
    422                var scro llX = docu ment.docum entElement .scrollLef t || docum ent.body.s crollLeft;
    423                var scro llY = docu ment.docum entElement .scrollTop  || docume nt.body.sc rollTop;
    424                this._po s = // sho uld use ac tual width /height be low
    425                    [(br owserWidth  / 2) - 10 0 + scroll X, (browse rHeight /  2) - 150 +  scrollY];
    426           }
    427  
    428           //  move inpu t on scree n for focu s, but hid den behind  dialog
    429           th is._dialog Input.css( 'left', th is._pos[0]  + 'px').c ss('top',  this._pos[ 1] + 'px') ;
    430           in st._settin gs.onSelec t = onSele ct;
    431           th is._inDial og = true;
    432           th is._datepi ckerDiv.ad dClass('da tepicker_d ialog');
    433           th is._showDa tepicker(t his._dialo gInput[0]) ;
    434           if  ($.blockU I) {
    435                $.blockU I(this._da tepickerDi v);
    436           }
    437           re turn this;
    438       },
    439  
    440       /* Pop -up the da te picker  for a give n input fi eld.
    441          @pa ram  input   element  - the inpu t field at tached to  the date p icker or
    442                           event -  if trigger ed by focu s */
    443       _showD atepicker:  function( input) {
    444           in put = inpu t.target | | input;
    445           if  (input.no deName.toL owerCase()  != 'input ') { // fi nd from bu tton/image  trigger
    446                input =  $('input',  input.par entNode)[0 ];
    447           }
    448           if  ($.datepi cker._last Input == i nput) { //  already h ere
    449                return;
    450           }
    451           if  ($.datepi cker._isDi sabledDate picker(inp ut)) {
    452                return;
    453           }
    454           va r inst = $ .datepicke r._getInst (input._ca lId);
    455           va r beforeSh ow = inst. _get('befo reShow');
    456           ex tendRemove (inst._set tings, (be foreShow ?  beforeSho w.apply(in put, [inpu t, inst])  : {}));
    457           $. datepicker .hideDatep icker('');
    458           $. datepicker ._lastInpu t = input;
    459           in st._setDat eFromField (input);
    460           if  ($.datepi cker._inDi alog) { //  hide curs or
    461                input.va lue = '';
    462           }
    463           if  (!$.datep icker._pos ) { // pos ition belo w input
    464                $.datepi cker._pos  = $.datepi cker._find Pos(input) ;
    465                $.datepi cker._pos[ 1] += inpu t.offsetHe ight; // a dd the hei ght
    466           }
    467           va r isFixed  = false;
    468           $( input).par ents().eac h(function () {
    469                isFixed  |= $(this) .css('posi tion') ==  'fixed';
    470           }) ;
    471           if  (isFixed  && $.brows er.opera)  { // corre ction for  Opera when  fixed and  scrolled
    472                $.datepi cker._pos[ 0] -= docu ment.docum entElement .scrollLef t;
    473                $.datepi cker._pos[ 1] -= docu ment.docum entElement .scrollTop ;
    474           }
    475           in st._datepi ckerDiv.cs s('positio n', ($.dat epicker._i nDialog &&  $.blockUI  ?
    476                'static'  : (isFixe d ? 'fixed ' : 'absol ute'))).
    477                css('lef t', $.date picker._po s[0] + 'px ').css('to p', $.date picker._po s[1] + 'px ');
    478           $. datepicker ._pos = nu ll;
    479           in st._rangeS tart = nul l;
    480           $. datepicker ._updateDa tepicker(i nst);
    481           if  (!inst._i nline) {
    482                var spee d = inst._ get('speed ');
    483                var post Process =  function()  {
    484                    $.da tepicker._ datepicker Showing =  true;
    485                    $.da tepicker._ afterShow( inst);
    486                };
    487                var show Anim = ins t._get('sh owAnim') | | 'show';
    488                inst._da tepickerDi v[showAnim ](speed, p ostProcess );
    489                if (spee d == '') {
    490                    post Process();
    491                }
    492                if (inst ._input[0] .type != ' hidden') {
    493                    inst ._input[0] .focus();
    494                }
    495                $.datepi cker._curI nst = inst ;
    496           }
    497       },
    498  
    499       /* Gen erate the  date picke r content.  */
    500       _updat eDatepicke r: functio n(inst) {
    501           in st._datepi ckerDiv.em pty().appe nd(inst._g enerateDat epicker()) ;
    502           va r numMonth s = inst._ getNumberO fMonths();
    503           if  (numMonth s[0] != 1  || numMont hs[1] != 1 ) {
    504                inst._da tepickerDi v.addClass ('datepick er_multi') ;
    505           } 
    506           el se {
    507                inst._da tepickerDi v.removeCl ass('datep icker_mult i');
    508           }
    509           if  (inst._ge t('isRTL') ) {
    510                inst._da tepickerDi v.addClass ('datepick er_rtl');
    511           }
    512           el se {
    513                inst._da tepickerDi v.removeCl ass('datep icker_rtl' );
    514           }
    515           if  (inst._in put && ins t._input[0 ].type !=  'hidden')  {
    516                inst._in put[0].foc us();
    517           }
    518       },
    519  
    520       /* Tid y up after  displayin g the date  picker. * /
    521       _after Show: func tion(inst)  {
    522           va r numMonth s = inst._ getNumberO fMonths();  // fix wi dth for dy namic numb er of date  pickers
    523           in st._datepi ckerDiv.wi dth(numMon ths[1] * $ ('.datepic ker', inst ._datepick erDiv[0])[ 0].offsetW idth);
    524           if  ($.browse r.msie &&  parseInt($ .browser.v ersion) <  7) { // fi x IE < 7 s elect prob lems
    525                $('#date picker_cov er').css({ width: ins t._datepic kerDiv.wid th() + 4,
    526                    heig ht: inst._ datepicker Div.height () + 4});
    527           }
    528           //  re-positi on on scre en if nece ssary
    529           va r isFixed  = inst._da tepickerDi v.css('pos ition') ==  'fixed';
    530           va r pos = in st._input  ? $.datepi cker._find Pos(inst._ input[0])  : null;
    531           va r browserW idth = win dow.innerW idth || do cument.doc umentEleme nt.clientW idth ||
    532                document .body.clie ntWidth;
    533           va r browserH eight = wi ndow.inner Height ||  document.d ocumentEle ment.clien tHeight ||
    534                document .body.clie ntHeight;
    535           va r scrollX  = (isFixed  ? 0 : doc ument.docu mentElemen t.scrollLe ft || docu ment.body. scrollLeft );
    536           va r scrollY  = (isFixed  ? 0 : doc ument.docu mentElemen t.scrollTo p || docum ent.body.s crollTop);
    537           //  repositio n date pic ker horizo ntally if  outside th e browser  window
    538           if  ((inst._d atepickerD iv.offset( ).left + i nst._datep ickerDiv.w idth() -
    539                    (isF ixed && $. browser.ms ie ? docum ent.docume ntElement. scrollLeft  : 0)) >
    540                    (bro wserWidth  + scrollX) ) {
    541                inst._da tepickerDi v.css('lef t', Math.m ax(scrollX ,
    542                    pos[ 0] + (inst ._input ?  $(inst._in put[0]).wi dth() : nu ll) - inst ._datepick erDiv.widt h() -
    543                    (isF ixed && $. browser.op era ? docu ment.docum entElement .scrollLef t : 0)) +  'px');
    544           }
    545           //  repositio n date pic ker vertic ally if ou tside the  browser wi ndow
    546           if  ((inst._d atepickerD iv.offset( ).top + in st._datepi ckerDiv.he ight() -
    547                    (isF ixed && $. browser.ms ie ? docum ent.docume ntElement. scrollTop  : 0)) >
    548                    (bro wserHeight  + scrollY ) ) {
    549                inst._da tepickerDi v.css('top ', Math.ma x(scrollY,
    550                    pos[ 1] - (this ._inDialog  ? 0 : ins t._datepic kerDiv.hei ght()) -
    551                    (isF ixed && $. browser.op era ? docu ment.docum entElement .scrollTop  : 0)) + ' px');
    552           }
    553       },
    554       
    555       /* Fin d an objec t's positi on on the  screen. */
    556       _findP os: functi on(obj) {
    557           wh ile (obj & & (obj.typ e == 'hidd en' || obj .nodeType  != 1)) {
    558                obj = ob j.nextSibl ing;
    559           }
    560           va r curleft  = curtop =  0;
    561           if  (obj.offs etParent)  {
    562                do {
    563                    curl eft += obj .offsetLef t;
    564                    curt op += obj. offsetTop;
    565                } while  (obj = obj .offsetPar ent);
    566           }
    567           re turn [curl eft,curtop ];
    568       },
    569  
    570       /* Hid e the date  picker fr om view.
    571          @pa ram  speed   string -  the speed  at which  to close t he date pi cker
    572          @re turn void  */
    573       hideDa tepicker:  function(s peed) {
    574           va r inst = t his._curIn st;
    575           if  (!inst) {
    576                return;
    577           }
    578           va r rangeSel ect = inst ._get('ran geSelect') ;
    579           if  (rangeSel ect && thi s._stayOpe n) {
    580                this._se lectDate(i nst, inst. _formatDat e(
    581                    inst ._currentD ay, inst._ currentMon th, inst._ currentYea r));
    582           }
    583           th is._stayOp en = false ;
    584           if  (this._da tepickerSh owing) {
    585                speed =  (speed !=  null ? spe ed : inst. _get('spee d'));
    586                var show Anim = ins t._get('sh owAnim');
    587                inst._da tepickerDi v[(showAni m == 'slid eDown' ? ' slideUp' :
    588                    (sho wAnim == ' fadeIn' ?  'fadeOut'  : 'hide')) ](speed, f unction()  {
    589                    $.da tepicker._ tidyDialog (inst);
    590                });
    591                if (spee d == '') {
    592                    this ._tidyDial og(inst);
    593                }
    594                var onCl ose = inst ._get('onC lose');
    595                if (onCl ose) {
    596                    onCl ose.apply( (inst._inp ut ? inst. _input[0]  : null),
    597                         [inst._get Date(), in st]);  //  trigger cu stom callb ack
    598                }
    599                this._da tepickerSh owing = fa lse;
    600                this._la stInput =  null;
    601                inst._se ttings.pro mpt = null ;
    602                if (this ._inDialog ) {
    603                    this ._dialogIn put.css('p osition',  'absolute' ).
    604                         css('left' , '0px').c ss('top',  '-100px');
    605                    if ( $.blockUI)  {
    606                         $.unblockU I();
    607                         $('body'). append(thi s._datepic kerDiv);
    608                    }
    609                }
    610                this._in Dialog = f alse;
    611           }
    612           th is._curIns t = null;
    613       },
    614  
    615       /* Tid y up after  a dialog  display. * /
    616       _tidyD ialog: fun ction(inst ) {
    617           in st._datepi ckerDiv.re moveClass( 'datepicke r_dialog') .
    618                unbind(' .datepicke r');
    619           $( '.datepick er_prompt' , inst._da tepickerDi v).remove( );
    620       },
    621  
    622       /* Clo se date pi cker if cl icked else where. */
    623       _check ExternalCl ick: funct ion(event)  {
    624           if  (!$.datep icker._cur Inst) {
    625                return;
    626           }
    627           va r target =  $(event.t arget);
    628           if  ((target. parents("# datepicker _div").len gth == 0)  &&
    629                    (tar get.attr(' class') !=  'datepick er_trigger ') &&
    630                    $.da tepicker._ datepicker Showing &&  !($.datep icker._inD ialog && $ .blockUI))  {
    631                $.datepi cker.hideD atepicker( '');
    632           }
    633       },
    634  
    635       /* Adj ust one of  the date  sub-fields . */
    636       _adjus tDate: fun ction(id,  offset, pe riod) {
    637           va r inst = t his._getIn st(id);
    638           in st._adjust Date(offse t, period) ;
    639           th is._update Datepicker (inst);
    640       },
    641  
    642       /* Act ion for cu rrent link . */
    643       _gotoT oday: func tion(id) {
    644           va r date = n ew Date();
    645           va r inst = t his._getIn st(id);
    646           in st._select edDay = da te.getDate ();
    647           in st._drawMo nth = inst ._selected Month = da te.getMont h();
    648           in st._drawYe ar = inst. _selectedY ear = date .getFullYe ar();
    649           th is._adjust Date(inst) ;
    650       },
    651  
    652       /* Act ion for se lecting a  new month/ year. */
    653       _selec tMonthYear : function (id, selec t, period)  {
    654           va r inst = t his._getIn st(id);
    655           in st._select ingMonthYe ar = false ;
    656           in st[period  == 'M' ? ' _drawMonth ' : '_draw Year'] =
    657                select.o ptions[sel ect.select edIndex].v alue - 0;
    658           th is._adjust Date(inst) ;
    659       },
    660  
    661       /* Res tore input  focus aft er not cha nging mont h/year. */
    662       _click MonthYear:  function( id) {
    663           va r inst = t his._getIn st(id);
    664           if  (inst._in put && ins t._selecti ngMonthYea r && !$.br owser.msie ) {
    665                inst._in put[0].foc us();
    666           }
    667           in st._select ingMonthYe ar = !inst ._selectin gMonthYear ;
    668       },
    669  
    670       /* Act ion for ch anging the  first wee k day. */
    671       _chang eFirstDay:  function( id, day) {
    672           va r inst = t his._getIn st(id);
    673           in st._settin gs.firstDa y = day;
    674           th is._update Datepicker (inst);
    675       },
    676  
    677       /* Act ion for se lecting a  day. */
    678       _selec tDay: func tion(id, m onth, year , td) {
    679           if  ($(td).is ('.datepic ker_unsele ctable'))  {
    680                return;
    681           }
    682           va r inst = t his._getIn st(id);
    683           va r rangeSel ect = inst ._get('ran geSelect') ;
    684           if  (rangeSel ect) {
    685                if (!thi s._stayOpe n) {
    686                    $('. datepicker  td').remo veClass('d atepicker_ currentDay ');
    687                    $(td ).addClass ('datepick er_current Day');
    688                } 
    689                this._st ayOpen = ! this._stay Open;
    690           }
    691           in st._select edDay = in st._curren tDay = $(' a', td).ht ml();
    692           in st._select edMonth =  inst._curr entMonth =  month;
    693           in st._select edYear = i nst._curre ntYear = y ear;
    694           th is._select Date(id, i nst._forma tDate(
    695                inst._cu rrentDay,  inst._curr entMonth,  inst._curr entYear));
    696           if  (this._st ayOpen) {
    697                inst._en dDay = ins t._endMont h = inst._ endYear =  null;
    698                inst._ra ngeStart =  new Date( inst._curr entYear, i nst._curre ntMonth, i nst._curre ntDay);
    699                this._up dateDatepi cker(inst) ;
    700           }
    701           el se if (ran geSelect)  {
    702                inst._en dDay = ins t._current Day;
    703                inst._en dMonth = i nst._curre ntMonth;
    704                inst._en dYear = in st._curren tYear;
    705                inst._se lectedDay  = inst._cu rrentDay =  inst._ran geStart.ge tDate();
    706                inst._se lectedMont h = inst._ currentMon th = inst. _rangeStar t.getMonth ();
    707                inst._se lectedYear  = inst._c urrentYear  = inst._r angeStart. getFullYea r();
    708                inst._ra ngeStart =  null;
    709                if (inst ._inline)  {
    710                    this ._updateDa tepicker(i nst);
    711                }
    712           }
    713       },
    714  
    715       /* Era se the inp ut field a nd hide th e date pic ker. */
    716       _clear Date: func tion(id) {
    717           va r inst = t his._getIn st(id);
    718           th is._stayOp en = false ;
    719           in st._endDay  = inst._e ndMonth =  inst._endY ear = inst ._rangeSta rt = null;
    720           th is._select Date(inst,  '');
    721       },
    722  
    723       /* Upd ate the in put field  with the s elected da te. */
    724       _selec tDate: fun ction(id,  dateStr) {
    725           va r inst = t his._getIn st(id);
    726           da teStr = (d ateStr !=  null ? dat eStr : ins t._formatD ate());
    727           if  (inst._ra ngeStart)  {
    728                dateStr  = inst._fo rmatDate(i nst._range Start) + i nst._get(' rangeSepar ator') + d ateStr;
    729           }
    730           if  (inst._in put) {
    731                inst._in put.val(da teStr);
    732           }
    733           va r onSelect  = inst._g et('onSele ct');
    734           if  (onSelect ) {
    735                onSelect .apply((in st._input  ? inst._in put[0] : n ull), [dat eStr, inst ]);  // tr igger cust om callbac k
    736           }
    737           el se {
    738                if (inst ._input) {
    739                    inst ._input.tr igger('cha nge'); //  fire the c hange even t
    740                }
    741           }
    742           if  (inst._in line) {
    743                this._up dateDatepi cker(inst) ;
    744           }
    745           el se {
    746                if (!thi s._stayOpe n) {
    747                    this .hideDatep icker(inst ._get('spe ed'));
    748                    this ._lastInpu t = inst._ input[0];
    749                    if ( typeof(ins t._input[0 ]) != 'obj ect') {
    750                         inst._inpu t[0].focus (); // res tore focus
    751                    }
    752                    this ._lastInpu t = null;
    753                }
    754           }
    755       },
    756  
    757       /* Set  as before ShowDay fu nction to  prevent se lection of  weekends.
    758          @pa ram  date   Date - th e date to  customise
    759          @re turn [bool ean, strin g] - is th is date se lectable?,  what is i ts CSS cla ss? */
    760       noWeek ends: func tion(date)  {
    761           va r day = da te.getDay( );
    762           re turn [(day  > 0 && da y < 6), '' ];
    763       },
    764       
    765       /* Set  as calcul ateWeek to  determine  the week  of the yea r based on  the ISO 8 601 defini tion.
    766          @pa ram  date   Date - th e date to  get the we ek for
    767          @re turn  numb er - the n umber of t he week wi thin the y ear that c ontains th is date */
    768       iso860 1Week: fun ction(date ) {
    769           va r checkDat e = new Da te(date.ge tFullYear( ), date.ge tMonth(),  date.getDa te());
    770           va r firstMon  = new Dat e(checkDat e.getFullY ear(), 1 -  1, 4); //  First wee k always c ontains 4  Jan
    771           va r firstDay  = firstMo n.getDay()  || 7; //  Day of wee k: Mon = 1 , ..., Sun  = 7
    772           fi rstMon.set Date(first Mon.getDat e() + 1 -  firstDay);  // Preced ing Monday
    773           if  (firstDay  < 4 && ch eckDate <  firstMon)  { // Adjus t first th ree days i n year if  necessary
    774                checkDat e.setDate( checkDate. getDate()  - 3); // G enerate fo r previous  year
    775                return $ .datepicke r.iso8601W eek(checkD ate);
    776           }
    777           el se if (che ckDate > n ew Date(ch eckDate.ge tFullYear( ), 12 - 1,  28)) { //  Check las t three da ys in year
    778                firstDay  = new Dat e(checkDat e.getFullY ear() + 1,  1 - 1, 4) .getDay()  || 7;
    779                if (firs tDay > 4 & & (checkDa te.getDay( ) || 7) <  firstDay -  3) { // A djust if n ecessary
    780                    chec kDate.setD ate(checkD ate.getDat e() + 3);  // Generat e for next  year
    781                    retu rn $.datep icker.iso8 601Week(ch eckDate);
    782                }
    783           }
    784           re turn Math. floor(((ch eckDate -  firstMon)  / 86400000 ) / 7) + 1 ; // Weeks  to given  date
    785       },
    786       
    787       /* Pro vide statu s text for  a particu lar date.
    788          @pa ram  date   the date  to get the  status fo r
    789          @pa ram  inst   the curre nt datepic ker instan ce
    790          @re turn  the  status dis play text  for this d ate */
    791       dateSt atus: func tion(date,  inst) {
    792           re turn $.dat epicker.fo rmatDate(i nst._get(' dateStatus '), date,  inst._getF ormatConfi g());
    793       },
    794  
    795       /* Par se a strin g value in to a date  object.
    796          The  format ca n be combi nations of  the follo wing:
    797          d   - day of m onth (no l eading zer o)
    798          dd  - day of m onth (two  digit)
    799          D   - day name  short
    800          DD  - day name  long
    801          m   - month of  year (no  leading ze ro)
    802          mm  - month of  year (two  digit)
    803          M   - month na me short
    804          MM  - month na me long
    805          y   - year (tw o digit)
    806          yy  - year (fo ur digit)
    807          '.. .' - liter al text
    808          ''  - single q uote
    809  
    810          @pa ram  forma t            String -  the expec ted format  of the da te
    811          @pa ram  value              String -  the date  in the abo ve format
    812          @pa ram  setti ngs  Objec t - attrib utes inclu de:
    813                              short YearCutoff   Number -  the cutof f year for  determini ng the cen tury (opti onal)
    814                              dayNa mesShort     String[7 ] - abbrev iated name s of the d ays from S unday (opt ional)
    815                              dayNa mes          String[7 ] - names  of the day s from Sun day (optio nal)
    816                              month NamesShort   String[1 2] - abbre viated nam es of the  months (op tional)
    817                              month Names        String[1 2] - names  of the mo nths (opti onal)
    818          @re turn  Date  - the ext racted dat e value or  null if v alue is bl ank */
    819       parseD ate: funct ion (forma t, value,  settings)  {
    820           if  (format = = null ||  value == n ull) {
    821                throw 'I nvalid arg uments';
    822           }
    823   //      fo rmat = dat eFormats[f ormat] ||  format;
    824           va lue = (typ eof value  == 'object ' ? value. toString()  : value +  '');
    825           if  (value ==  '') {
    826                return n ull;
    827           }
    828           va r shortYea rCutoff =  (settings  ? settings .shortYear Cutoff : n ull) || th is._defaul ts.shortYe arCutoff;
    829           va r dayNames Short = (s ettings ?  settings.d ayNamesSho rt : null)  || this._ defaults.d ayNamesSho rt;
    830           va r dayNames  = (settin gs ? setti ngs.dayNam es : null)  || this._ defaults.d ayNames;
    831           va r monthNam esShort =  (settings  ? settings .monthName sShort : n ull) || th is._defaul ts.monthNa mesShort;
    832           va r monthNam es = (sett ings ? set tings.mont hNames : n ull) || th is._defaul ts.monthNa mes;
    833           va r year = - 1;
    834           va r month =  -1;
    835           va r day = -1 ;
    836           va r literal  = false;
    837           //  Check whe ther a for mat charac ter is dou bled
    838           va r lookAhea d = functi on(match)  {
    839                var matc hes = (iFo rmat + 1 <  format.le ngth && fo rmat.charA t(iFormat  + 1) == ma tch);
    840                if (matc hes) {
    841                    iFor mat++;
    842                }
    843                return m atches; 
    844           };
    845           //  Extract a  number fr om the str ing value
    846           va r getNumbe r = functi on(match)  {
    847                lookAhea d(match);
    848                var size  = (match  == 'y' ? 4  : 2);
    849                var num  = 0;
    850                while (s ize > 0 &&  iValue <  value.leng th &&
    851                         value.char At(iValue)  >= '0' &&  value.cha rAt(iValue ) <= '9')  {
    852                    num  = num * 10  + (value. charAt(iVa lue++) - 0 );
    853                    size --;
    854                }
    855                if (size  == (match  == 'y' ?  4 : 2)) {
    856                    thro w 'Missing  number at  position  ' + iValue ;
    857                }
    858                return n um;
    859           };
    860           //  Extract a  name from  the strin g value an d convert  to an inde x
    861           va r getName  = function (match, sh ortNames,  longNames)  {
    862                var name s = (lookA head(match ) ? longNa mes : shor tNames);
    863                var size  = 0;
    864                for (var  j = 0; j  < names.le ngth; j++)  {
    865                    size  = Math.ma x(size, na mes[j].len gth);
    866                }
    867                var name  = '';
    868                var iIni t = iValue ;
    869                while (s ize > 0 &&  iValue <  value.leng th) {
    870                    name  += value. charAt(iVa lue++);
    871                    for  (var i = 0 ; i < name s.length;  i++) {
    872                         if (name = = names[i] ) {
    873                             return  i + 1;
    874                         }
    875                    }
    876                    size --;
    877                }
    878                throw 'U nknown nam e at posit ion ' + iI nit;
    879           };
    880           //  Confirm t hat a lite ral charac ter matche s the stri ng value
    881           va r checkLit eral = fun ction() {
    882                if (valu e.charAt(i Value) !=  format.cha rAt(iForma t)) {
    883                    thro w 'Unexpec ted litera l at posit ion ' + iV alue;
    884                }
    885                iValue++ ;
    886           };
    887           va r iValue =  0;
    888           fo r (var iFo rmat = 0;  iFormat <  format.len gth; iForm at++) {
    889                if (lite ral) {
    890                    if ( format.cha rAt(iForma t) == '\''  && !lookA head('\'') ) {
    891                         literal =  false;
    892                    }
    893                    else  {
    894                         checkLiter al();
    895                    }
    896                }
    897                else {
    898                    swit ch (format .charAt(iF ormat)) {
    899                         case 'd':
    900                             day =  getNumber( 'd');
    901                             break;
    902                         case 'D': 
    903                             getNam e('D', day NamesShort , dayNames );
    904                             break;
    905                         case 'm': 
    906                             month  = getNumbe r('m');
    907                             break;
    908                         case 'M':
    909                             month  = getName( 'M', month NamesShort , monthNam es); 
    910                             break;
    911                         case 'y':
    912                             year =  getNumber ('y');
    913                             break;
    914                         case '\'':
    915                             if (lo okAhead('\ '')) {
    916                                 ch eckLiteral ();
    917                             }
    918                             else {
    919                                 li teral = tr ue;
    920                             }
    921                             break;
    922                         default:
    923                             checkL iteral();
    924                    }
    925                }
    926           }
    927           if  (year < 1 00) {
    928                year +=  new Date() .getFullYe ar() - new  Date().ge tFullYear( ) % 100 +
    929                    (yea r <= short YearCutoff  ? 0 : -10 0);
    930           }
    931           va r date = n ew Date(ye ar, month  - 1, day);
    932           if  (date.get FullYear()  != year | | date.get Month() +  1 != month  || date.g etDate() ! = day) {
    933                throw 'I nvalid dat e'; // E.g . 31/02/*
    934           }
    935           re turn date;
    936       },
    937  
    938       /* For mat a date  object in to a strin g value.
    939          The  format ca n be combi nations of  the follo wing:
    940          d   - day of m onth (no l eading zer o)
    941          dd  - day of m onth (two  digit)
    942          D   - day name  short
    943          DD  - day name  long
    944          m   - month of  year (no  leading ze ro)
    945          mm  - month of  year (two  digit)
    946          M   - month na me short
    947          MM  - month na me long
    948          y   - year (tw o digit)
    949          yy  - year (fo ur digit)
    950          '.. .' - liter al text
    951          ''  - single q uote
    952  
    953          @pa ram  forma t    Strin g - the de sired form at of the  date
    954          @pa ram  date       Date  - the date  value to  format
    955          @pa ram  setti ngs  Objec t - attrib utes inclu de:
    956                              dayNa mesShort     String[7 ] - abbrev iated name s of the d ays from S unday (opt ional)
    957                              dayNa mes          String[7 ] - names  of the day s from Sun day (optio nal)
    958                              month NamesShort   String[1 2] - abbre viated nam es of the  months (op tional)
    959                              month Names        String[1 2] - names  of the mo nths (opti onal)
    960          @re turn  Stri ng - the d ate in the  above for mat */
    961       format Date: func tion (form at, date,  settings)  {
    962           if  (!date) {
    963                return ' ';
    964           }
    965   //      fo rmat = dat eFormats[f ormat] ||  format;
    966           va r dayNames Short = (s ettings ?  settings.d ayNamesSho rt : null)  || this._ defaults.d ayNamesSho rt;
    967           va r dayNames  = (settin gs ? setti ngs.dayNam es : null)  || this._ defaults.d ayNames;
    968           va r monthNam esShort =  (settings  ? settings .monthName sShort : n ull) || th is._defaul ts.monthNa mesShort;
    969           va r monthNam es = (sett ings ? set tings.mont hNames : n ull) || th is._defaul ts.monthNa mes;
    970           //  Check whe ther a for mat charac ter is dou bled
    971           va r lookAhea d = functi on(match)  {
    972                var matc hes = (iFo rmat + 1 <  format.le ngth && fo rmat.charA t(iFormat  + 1) == ma tch);
    973                if (matc hes) {
    974                    iFor mat++;
    975                }
    976                return m atches; 
    977           };
    978           //  Format a  number, wi th leading  zero if n ecessary
    979           va r formatNu mber = fun ction(matc h, value)  {
    980                return ( lookAhead( match) &&  value < 10  ? '0' : ' ') + value ;
    981           };
    982           //  Format a  name, shor t or long  as request ed
    983           va r formatNa me = funct ion(match,  value, sh ortNames,  longNames)  {
    984                return ( lookAhead( match) ? l ongNames[v alue] : sh ortNames[v alue]);
    985           };
    986           va r output =  '';
    987           va r literal  = false;
    988           if  (date) {
    989                for (var  iFormat =  0; iForma t < format .length; i Format++)  {
    990                    if ( literal) {
    991                         if (format .charAt(iF ormat) ==  '\'' && !l ookAhead(' \'')) {
    992                             litera l = false;
    993                         }
    994                         else {
    995                             output  += format .charAt(iF ormat);
    996                         }
    997                    }
    998                    else  {
    999                         switch (fo rmat.charA t(iFormat) ) {
    1000                             case ' d':
    1001                                 ou tput += fo rmatNumber ('d', date .getDate() ); 
    1002                                 br eak;
    1003                             case ' D': 
    1004                                 ou tput += fo rmatName(' D', date.g etDay(), d ayNamesSho rt, dayNam es);
    1005                                 br eak;
    1006                             case ' m': 
    1007                                 ou tput += fo rmatNumber ('m', date .getMonth( ) + 1); 
    1008                                 br eak;
    1009                             case ' M':
    1010                                 ou tput += fo rmatName(' M', date.g etMonth(),  monthName sShort, mo nthNames);  
    1011                                 br eak;
    1012                             case ' y':
    1013                                 ou tput += (l ookAhead(' y') ? date .getFullYe ar() : 
    1014                                      (date.ge tYear() %  100 < 10 ?  '0' : '')  + date.ge tYear() %  100);
    1015                                 br eak;
    1016                             case ' \'':
    1017                                 if  (lookAhea d('\'')) {
    1018                                      output + = '\'';
    1019                                 }
    1020                                 el se {
    1021                                      literal  = true;
    1022                                 }
    1023                                 br eak;
    1024                             defaul t:
    1025                                 ou tput += fo rmat.charA t(iFormat) ;
    1026                         }
    1027                    }
    1028                }
    1029           }
    1030           re turn outpu t;
    1031       },
    1032  
    1033       /* Ext ract all p ossible ch aracters f rom the da te format.  */
    1034       _possi bleChars:  function ( format) {
    1035   //      fo rmat = dat eFormats[f ormat] ||  format;
    1036           va r chars =  '';
    1037           va r literal  = false;
    1038           fo r (var iFo rmat = 0;  iFormat <  format.len gth; iForm at++) {
    1039                if (lite ral) {
    1040                    if ( format.cha rAt(iForma t) == '\''  && !lookA head('\'') ) {
    1041                         literal =  false;
    1042                    }
    1043                    else  {
    1044                         chars += f ormat.char At(iFormat );
    1045                    }
    1046                }
    1047                else {
    1048                    swit ch (format .charAt(iF ormat)) {
    1049                         case 'd':
    1050                         case 'm': 
    1051                         case 'y':
    1052                             chars  += '012345 6789'; 
    1053                             break;
    1054                         case 'D': 
    1055                         case 'M':
    1056                             return  null; //  Accept any thing
    1057                         case '\'':
    1058                             if (lo okAhead('\ '')) {
    1059                                 ch ars += '\' ';
    1060                             }
    1061                             else {
    1062                                 li teral = tr ue;
    1063                             }
    1064                             break;
    1065                         default:
    1066                             chars  += format. charAt(iFo rmat);
    1067                    }
    1068                }
    1069           }
    1070           re turn chars ;
    1071       }
    1072   });
    1073  
    1074   /* Individ ualised se ttings for  date pick er functio nality app lied to on e or more  related in puts.
    1075      Instanc es are man aged and m anipulated  through t he Datepic ker manage r. */
    1076   function D atepickerI nstance(se ttings, in line) {
    1077       this._ id = $.dat epicker._r egister(th is);
    1078       this._ selectedDa y = 0; //  Current da te for sel ection
    1079       this._ selectedMo nth = 0; / / 0-11
    1080       this._ selectedYe ar = 0; //  4-digit y ear
    1081       this._ drawMonth  = 0; // Cu rrent mont h at start  of datepi cker
    1082       this._ drawYear =  0;
    1083       this._ input = nu ll; // The  attached  input fiel d
    1084       this._ inline = i nline; //  True if sh owing inli ne, false  if used in  a popup
    1085       this._ datepicker Div = (!in line ? $.d atepicker. _datepicke rDiv :
    1086           $( '<div id=" datepicker _div_' + t his._id +  '" class=" datepicker _inline">< /div>'));
    1087       // cus tomise the  date pick er object  - uses man ager defau lts if not  overridde n
    1088       this._ settings =  extendRem ove({}, se ttings ||  {}); // cl one
    1089       if (in line) {
    1090           th is._setDat e(this._ge tDefaultDa te());
    1091       }
    1092   }
    1093  
    1094   $.extend(D atepickerI nstance.pr ototype, {
    1095       /* Get  a setting  value, de faulting i f necessar y. */
    1096       _get:  function(n ame) {
    1097           re turn (this ._settings [name] !=  null ? thi s._setting s[name] :  $.datepick er._defaul ts[name]);
    1098       },
    1099  
    1100       /* Par se existin g date and  initialis e date pic ker. */
    1101       _setDa teFromFiel d: functio n(input) {
    1102           th is._input  = $(input) ;
    1103           va r dateForm at = this. _get('date Format');
    1104           va r dates =  this._inpu t ? this._ input.val( ).split(th is._get('r angeSepara tor')) : n ull; 
    1105           th is._endDay  = this._e ndMonth =  this._endY ear = null ;
    1106           va r date = d efaultDate  = this._g etDefaultD ate();
    1107           if  (dates.le ngth > 0)  {
    1108                var sett ings = thi s._getForm atConfig() ;
    1109                if (date s.length >  1) {
    1110                    date  = $.datep icker.pars eDate(date Format, da tes[1], se ttings) ||  defaultDa te;
    1111                    this ._endDay =  date.getD ate();
    1112                    this ._endMonth  = date.ge tMonth();
    1113                    this ._endYear  = date.get FullYear() ;
    1114                }
    1115                try {
    1116                    date  = $.datep icker.pars eDate(date Format, da tes[0], se ttings) ||  defaultDa te;
    1117                }
    1118                catch (e ) {
    1119                    $.da tepicker.l og(e);
    1120                    date  = default Date;
    1121                }
    1122           }
    1123           th is._select edDay = da te.getDate ();
    1124           th is._drawMo nth = this ._selected Month = da te.getMont h();
    1125           th is._drawYe ar = this. _selectedY ear = date .getFullYe ar();
    1126           th is._curren tDay = (da tes[0] ? d ate.getDat e() : 0);
    1127           th is._curren tMonth = ( dates[0] ?  date.getM onth() : 0 );
    1128           th is._curren tYear = (d ates[0] ?  date.getFu llYear() :  0);
    1129           th is._adjust Date();
    1130       },
    1131       
    1132       /* Ret rieve the  default da te shown o n opening.  */
    1133       _getDe faultDate:  function( ) {
    1134           va r date = t his._deter mineDate(' defaultDat e', new Da te());
    1135           va r minDate  = this._ge tMinMaxDat e('min', t rue);
    1136           va r maxDate  = this._ge tMinMaxDat e('max');
    1137           da te = (minD ate && dat e < minDat e ? minDat e : date);
    1138           da te = (maxD ate && dat e > maxDat e ? maxDat e : date);
    1139           re turn date;
    1140       },
    1141  
    1142       /* A d ate may be  specified  as an exa ct value o r a relati ve one. */
    1143       _deter mineDate:  function(n ame, defau ltDate) {
    1144           va r offsetNu meric = fu nction(off set) {
    1145                var date  = new Dat e();
    1146                date.set Date(date. getDate()  + offset);
    1147                return d ate;
    1148           };
    1149           va r offsetSt ring = fun ction(offs et, getDay sInMonth)  {
    1150                var date  = new Dat e();
    1151                var matc hes = /^([ +-]?[0-9]+ )\s*(d|D|w |W|m|M|y|Y )?$/.exec( offset);
    1152                if (matc hes) {
    1153                    var  year = dat e.getFullY ear();
    1154                    var  month = da te.getMont h();
    1155                    var  day = date .getDate() ;
    1156                    swit ch (matche s[2] || 'd ') {
    1157                         case 'd' :  case 'D'  :
    1158                             day +=  (matches[ 1] - 0); b reak;
    1159                         case 'w' :  case 'W'  :
    1160                             day +=  (matches[ 1] * 7); b reak;
    1161                         case 'm' :  case 'M'  :
    1162                             month  += (matche s[1] - 0);  
    1163                             day =  Math.min(d ay, getDay sInMonth(y ear, month ));
    1164                             break;
    1165                         case 'y':  case 'Y' :
    1166                             year + = (matches [1] - 0);
    1167                             day =  Math.min(d ay, getDay sInMonth(y ear, month ));
    1168                             break;
    1169                    }
    1170                    date  = new Dat e(year, mo nth, day);
    1171                }
    1172                return d ate;
    1173           };
    1174           va r date = t his._get(n ame);
    1175           re turn (date  == null ?  defaultDa te :
    1176                (typeof  date == 's tring' ? o ffsetStrin g(date, th is._getDay sInMonth)  :
    1177                (typeof  date == 'n umber' ? o ffsetNumer ic(date) :  date)));
    1178       },
    1179  
    1180       /* Set  the date( s) directl y. */
    1181       _setDa te: functi on(date, e ndDate) {
    1182           th is._select edDay = th is._curren tDay = dat e.getDate( );
    1183           th is._drawMo nth = this ._selected Month = th is._curren tMonth = d ate.getMon th();
    1184           th is._drawYe ar = this. _selectedY ear = this ._currentY ear = date .getFullYe ar();
    1185           if  (this._ge t('rangeSe lect')) {
    1186                if (endD ate) {
    1187                    this ._endDay =  endDate.g etDate();
    1188                    this ._endMonth  = endDate .getMonth( );
    1189                    this ._endYear  = endDate. getFullYea r();
    1190                }
    1191                else {
    1192                    this ._endDay =  this._cur rentDay;
    1193                    this ._endMonth  = this._c urrentMont h;
    1194                    this ._endYear  = this._cu rrentYear;
    1195                }
    1196           }
    1197           th is._adjust Date();
    1198       },
    1199  
    1200       /* Ret rieve the  date(s) di rectly. */
    1201       _getDa te: functi on() {
    1202           va r startDat e = (!this ._currentY ear || (th is._input  && this._i nput.val()  == '') ?  null :
    1203                new Date (this._cur rentYear,  this._curr entMonth,  this._curr entDay));
    1204           if  (this._ge t('rangeSe lect')) {
    1205                return [ startDate,  (!this._e ndYear ? n ull :
    1206                    new  Date(this. _endYear,  this._endM onth, this ._endDay)) ];
    1207           }
    1208           el se {
    1209                return s tartDate;
    1210           }
    1211       },
    1212  
    1213       /* Gen erate the  HTML for t he current  state of  the date p icker. */
    1214       _gener ateDatepic ker: funct ion() {
    1215           va r today =  new Date() ;
    1216           to day = new  Date(today .getFullYe ar(), toda y.getMonth (), today. getDate()) ; // clear  time
    1217           va r showStat us = this. _get('show Status');
    1218           va r isRTL =  this._get( 'isRTL');
    1219           //  build the  date pick er HTML
    1220           va r clear =  (this._get ('mandator y') ? '' :
    1221                '<div cl ass="datep icker_clea r"><a oncl ick="jQuer y.datepick er._clearD ate(' + th is._id + ' );"' + 
    1222                (showSta tus ? this ._addStatu s(this._ge t('clearSt atus') ||  '&#xa0;')  : '') + '> ' +
    1223                this._ge t('clearTe xt') + '</ a></div>') ;
    1224           va r controls  = '<div c lass="date picker_con trol">' +  (isRTL ? ' ' : clear)  +
    1225                '<div cl ass="datep icker_clos e"><a oncl ick="jQuer y.datepick er.hideDat epicker(); "' +
    1226                (showSta tus ? this ._addStatu s(this._ge t('closeSt atus') ||  '&#xa0;')  : '') + '> ' +
    1227                this._ge t('closeTe xt') + '</ a></div>'  + (isRTL ?  clear : ' ')  + '</d iv>';
    1228           va r prompt =  this._get ('prompt') ;
    1229           va r closeAtT op = this. _get('clos eAtTop');
    1230           va r hideIfNo PrevNext =  this._get ('hideIfNo PrevNext') ;
    1231           va r numMonth s = this._ getNumberO fMonths();
    1232           va r stepMont hs = this. _get('step Months');
    1233           va r isMultiM onth = (nu mMonths[0]  != 1 || n umMonths[1 ] != 1);
    1234           va r minDate  = this._ge tMinMaxDat e('min', t rue);
    1235           va r maxDate  = this._ge tMinMaxDat e('max');
    1236           va r drawMont h = this._ drawMonth;
    1237           va r drawYear  = this._d rawYear;
    1238           if  (maxDate)  {
    1239                var maxD raw = new  Date(maxDa te.getFull Year(),
    1240                    maxD ate.getMon th() - num Months[1]  + 1, maxDa te.getDate ());
    1241                maxDraw  = (minDate  && maxDra w < minDat e ? minDat e : maxDra w);
    1242                while (n ew Date(dr awYear, dr awMonth, 1 ) > maxDra w) {
    1243                    draw Month--;
    1244                    if ( drawMonth  < 0) {
    1245                         drawMonth  = 11;
    1246                         drawYear-- ;
    1247                    }
    1248                }
    1249           }
    1250           //  controls  and links
    1251           va r prev = ' <div class ="datepick er_prev">'  + (this._ canAdjustM onth(-1, d rawYear, d rawMonth) 
    1252                '<a oncl ick="jQuer y.datepick er._adjust Date(' + t his._id +  ', -' + st epMonths +  ', \'M\') ;"' +
    1253                (showSta tus ? this ._addStatu s(this._ge t('prevSta tus') || ' &#xa0;') :  '') + '>'  +
    1254                this._ge t('prevTex t') + '</a >' :
    1255                (hideIfN oPrevNext  ? '' : '<l abel>' + t his._get(' prevText')  + '</labe l>')) + '< /div>';
    1256           va r next = ' <div class ="datepick er_next">'  + (this._ canAdjustM onth(+1, d rawYear, d rawMonth)  ?
    1257                '<a oncl ick="jQuer y.datepick er._adjust Date(' + t his._id +  ', +' + st epMonths +  ', \'M\') ;"' +
    1258                (showSta tus ? this ._addStatu s(this._ge t('nextSta tus') || ' &#xa0;') :  '') + '>'  +
    1259                this._ge t('nextTex t') + '</a >' :
    1260                (hideIfN oPrevNext  ? '>' : '< label>' +  this._get( 'nextText' ) + '</lab el>')) + ' </div>';
    1261           va r html = ( prompt ? ' <div class ="datepick er_prompt" >' + promp t + '</div >' : '') +
    1262                (closeAt Top && !th is._inline  ? control s : '') +
    1263                '<div cl ass="datep icker_link s">' + (is RTL ? next  : prev) +
    1264                (this._i sInRange(t oday) ? '< div class= "datepicke r_current" >' +
    1265                '<a oncl ick="jQuer y.datepick er._gotoTo day(' + th is._id + ' );"' +
    1266                (showSta tus ? this ._addStatu s(this._ge t('current Status') | | '&#xa0;' ) : '') +  '>' +
    1267                this._ge t('current Text') + ' </a></div> ' : '') +  (isRTL ? p rev : next ) + '</div >';
    1268           va r showWeek s = this._ get('showW eeks');
    1269           fo r (var row  = 0; row  < numMonth s[0]; row+ +) {
    1270           fo r (var col  = 0; col  < numMonth s[1]; col+ +) {
    1271                var sele ctedDate =  new Date( drawYear,  drawMonth,  this._sel ectedDay);
    1272                html +=  '<div clas s="datepic ker_oneMon th' + (col  == 0 ? '  datepicker _newRow' :  '') + '"> ' +
    1273                    this ._generate MonthYearH eader(draw Month, dra wYear, min Date, maxD ate,
    1274                    sele ctedDate,  row > 0 ||  col > 0)  + // draw  month head ers
    1275                    '<ta ble class= "datepicke r" cellpad ding="0" c ellspacing ="0"><thea d>' + 
    1276                    '<tr  class="da tepicker_t itleRow">'  +
    1277                    (sho wWeeks ? ' <td>' + th is._get('w eekHeader' ) + '</td> ' : '');
    1278                var firs tDay = thi s._get('fi rstDay');
    1279                var chan geFirstDay  = this._g et('change FirstDay') ;
    1280                var dayN ames = thi s._get('da yNames');
    1281                var dayN amesShort  = this._ge t('dayName sShort');
    1282                var dayN amesMin =  this._get( 'dayNamesM in');
    1283                for (var  dow = 0;  dow < 7; d ow++) { //  days of t he week
    1284                    var  day = (dow  + firstDa y) % 7;
    1285                    var  status = t his._get(' dayStatus' ) || '&#xa 0;';
    1286                    stat us = (stat us.indexOf ('DD') > - 1 ? status .replace(/ DD/, dayNa mes[day])  :
    1287                         status.rep lace(/D/,  dayNamesSh ort[day])) ;
    1288                    html  += '<td'  + ((dow +  firstDay +  6) % 7 >=  5 ? ' cla ss="datepi cker_weekE ndCell"' :  '') + '>'  +
    1289                         (!changeFi rstDay ? ' <span' :
    1290                         '<a onclic k="jQuery. datepicker ._changeFi rstDay(' +  this._id  + ', ' + d ay + ');"' ) + 
    1291                         (showStatu s ? this._ addStatus( status) :  '') + ' ti tle="' + d ayNames[da y] + '">'  +
    1292                         dayNamesMi n[day] + ( changeFirs tDay ? '</ a>' : '</s pan>') + ' </td>';
    1293                }
    1294                html +=  '</tr></th ead><tbody >';
    1295                var days InMonth =  this._getD aysInMonth (drawYear,  drawMonth );
    1296                if (draw Year == th is._select edYear &&  drawMonth  == this._s electedMon th) {
    1297                    this ._selected Day = Math .min(this. _selectedD ay, daysIn Month);
    1298                }
    1299                var lead Days = (th is._getFir stDayOfMon th(drawYea r, drawMon th) - firs tDay + 7)  % 7;
    1300                var curr entDate =  (!this._cu rrentDay ?  new Date( 9999, 9, 9 ) :
    1301                    new  Date(this. _currentYe ar, this._ currentMon th, this._ currentDay ));
    1302                var endD ate = this ._endDay ?  new Date( this._endY ear, this. _endMonth,  this._end Day) : cur rentDate;
    1303                var prin tDate = ne w Date(dra wYear, dra wMonth, 1  - leadDays );
    1304                var numR ows = (isM ultiMonth  ? 6 : Math .ceil((lea dDays + da ysInMonth)  / 7)); //  calculate  the numbe r of rows  to generat e
    1305                var befo reShowDay  = this._ge t('beforeS howDay');
    1306                var show OtherMonth s = this._ get('showO therMonths ');
    1307                var calc ulateWeek  = this._ge t('calcula teWeek') | | $.datepi cker.iso86 01Week;
    1308                var date Status = t his._get(' statusForD ate') || $ .datepicke r.dateStat us;
    1309                for (var  dRow = 0;  dRow < nu mRows; dRo w++) { //  create dat e picker r ows
    1310                    html  += '<tr c lass="date picker_day sRow">' +
    1311                         (showWeeks  ? '<td cl ass="datep icker_week Col">' + c alculateWe ek(printDa te) + '</t d>' : '');
    1312                    for  (var dow =  0; dow <  7; dow++)  { // creat e date pic ker days
    1313                         var daySet tings = (b eforeShowD ay ?
    1314                             before ShowDay.ap ply((this. _input ? t his._input [0] : null ), [printD ate]) : [t rue, '']);
    1315                         var otherM onth = (pr intDate.ge tMonth() ! = drawMont h);
    1316                         var unsele ctable = o therMonth  || !daySet tings[0] | |
    1317                             (minDa te && prin tDate < mi nDate) ||  (maxDate & & printDat e > maxDat e);
    1318                         html += '< td class=" datepicker _daysCell'  +
    1319                             ((dow  + firstDay  + 6) % 7  >= 5 ? ' d atepicker_ weekEndCel l' : '') +  // highli ght weeken ds
    1320                             (other Month ? '  datepicker _otherMont h' : '') +  // highli ght days f rom other  months
    1321                             (print Date.getTi me() == se lectedDate .getTime()  && drawMo nth == thi s._selecte dMonth ?
    1322                             ' date picker_day sCellOver'  : '') + / / highligh t selected  day
    1323                             (unsel ectable ?  ' datepick er_unselec table' : ' ') +  // h ighlight u nselectabl e days
    1324                             (other Month && ! showOtherM onths ? ''  : ' ' + d aySettings [1] + // h ighlight c ustom date s
    1325                             (print Date.getTi me() >= cu rrentDate. getTime()  && printDa te.getTime () <= endD ate.getTim e() ?  //  in current  range
    1326                             ' date picker_cur rentDay' :  '') + //  highlight  selected d ay
    1327                             (print Date.getTi me() == to day.getTim e() ? ' da tepicker_t oday' : '' )) + '"' +  // highli ght today  (if differ ent)
    1328                             (unsel ectable ?  '' : ' onm ouseover=" jQuery(thi s).addClas s(\'datepi cker_daysC ellOver\') ;' +
    1329                             (!show Status ||  (otherMont h && !show OtherMonth s) ? '' :  'jQuery(\' #datepicke r_status_'  +
    1330                             this._ id + '\'). html(\'' +  (dateStat us.apply(( this._inpu t ? this._ input[0] :  null),
    1331                             [print Date, this ]) || '&#x a0;') +'\' );') + '"'  +
    1332                             ' onmo useout="jQ uery(this) .removeCla ss(\'datep icker_days CellOver\' );' +
    1333                             (!show Status ||  (otherMont h && !show OtherMonth s) ? '' :  'jQuery(\' #datepicke r_status_'  +
    1334                             this._ id + '\'). html(\'&#x a0;\');')  + '" oncli ck="jQuery .datepicke r._selectD ay(' +
    1335                             this._ id + ',' +  drawMonth  + ',' + d rawYear +  ', this);" ') + '>' +  // action s
    1336                             (other Month ? (s howOtherMo nths ? pri ntDate.get Date() : ' &#xa0;') :  // displa y for othe r months
    1337                             (unsel ectable ?  printDate. getDate()  : '<a>' +  printDate. getDate()  + '</a>'))  + '</td>' ; // displ ay for thi s month
    1338                         printDate. setDate(pr intDate.ge tDate() +  1);
    1339                    }
    1340                    html  += '</tr> ';
    1341                }
    1342                drawMont h++;
    1343                if (draw Month > 11 ) {
    1344                    draw Month = 0;
    1345                    draw Year++;
    1346                }
    1347                html +=  '</tbody>< /table></d iv>';
    1348           }
    1349           }
    1350           ht ml += (sho wStatus ?  '<div id=" datepicker _status_'  + this._id  + 
    1351                '" class ="datepick er_status" >' + (this ._get('ini tStatus')  || '&#xa0; ') + '</di v>' : '')  +
    1352                (!closeA tTop && !t his._inlin e ? contro ls : '') +
    1353                '<div st yle="clear : both;">< /div>' + 
    1354                ($.brows er.msie &&  parseInt( $.browser. version) <  7 && !thi s._inline 
    1355                '<iframe  src="java script:fal se;" class ="datepick er_cover"> </iframe>'  : '');
    1356           re turn html;
    1357       },
    1358       
    1359       /* Gen erate the  month and  year heade r. */
    1360       _gener ateMonthYe arHeader:  function(d rawMonth,  drawYear,  minDate, m axDate, se lectedDate , secondar y) {
    1361           mi nDate = (t his._range Start && m inDate &&  selectedDa te < minDa te ? selec tedDate :  minDate);
    1362           va r showStat us = this. _get('show Status');
    1363           va r html = ' <div class ="datepick er_header" >';
    1364           //  month sel ection
    1365           va r monthNam es = this. _get('mont hNames');
    1366           if  (secondar y || !this ._get('cha ngeMonth') ) {
    1367                html +=  monthNames [drawMonth ] + '&#xa0 ;';
    1368           }
    1369           el se {
    1370                var inMi nYear = (m inDate &&  minDate.ge tFullYear( ) == drawY ear);
    1371                var inMa xYear = (m axDate &&  maxDate.ge tFullYear( ) == drawY ear);
    1372                html +=  '<select c lass="date picker_new Month" ' +
    1373                    'onc hange="jQu ery.datepi cker._sele ctMonthYea r(' + this ._id + ',  this, \'M\ ');" ' +
    1374                    'onc lick="jQue ry.datepic ker._click MonthYear( ' + this._ id + ');"'  +
    1375                    (sho wStatus ?  this._addS tatus(this ._get('mon thStatus')  || '&#xa0 ;') : '')  + '>';
    1376                for (var  month = 0 ; month <  12; month+ +) {
    1377                    if ( (!inMinYea r || month  >= minDat e.getMonth ()) &&
    1378                             (!inMa xYear || m onth <= ma xDate.getM onth())) {
    1379                         html += '< option val ue="' + mo nth + '"'  +
    1380                             (month  == drawMo nth ? ' se lected="se lected"' :  '') +
    1381                             '>' +  monthNames [month] +  '</option> ';
    1382                    }
    1383                }
    1384                html +=  '</select> ';
    1385           }
    1386           //  year sele ction
    1387           if  (secondar y || !this ._get('cha ngeYear'))  {
    1388                html +=  drawYear;
    1389           }
    1390           el se {
    1391                // deter mine range  of years  to display
    1392                var year s = this._ get('yearR ange').spl it(':');
    1393                var year  = 0;
    1394                var endY ear = 0;
    1395                if (year s.length ! = 2) {
    1396                    year  = drawYea r - 10;
    1397                    endY ear = draw Year + 10;
    1398                }
    1399                else if  (years[0]. charAt(0)  == '+' ||  years[0].c harAt(0) = = '-') {
    1400                    year  = drawYea r + parseI nt(years[0 ], 10);
    1401                    endY ear = draw Year + par seInt(year s[1], 10);
    1402                }
    1403                else {
    1404                    year  = parseIn t(years[0] , 10);
    1405                    endY ear = pars eInt(years [1], 10);
    1406                }
    1407                year = ( minDate ?  Math.max(y ear, minDa te.getFull Year()) :  year);
    1408                endYear  = (maxDate  ? Math.mi n(endYear,  maxDate.g etFullYear ()) : endY ear);
    1409                html +=  '<select c lass="date picker_new Year" ' +
    1410                    'onc hange="jQu ery.datepi cker._sele ctMonthYea r(' + this ._id + ',  this, \'Y\ ');" ' +
    1411                    'onc lick="jQue ry.datepic ker._click MonthYear( ' + this._ id + ');"'  +
    1412                    (sho wStatus ?  this._addS tatus(this ._get('yea rStatus')  || '&#xa0; ') : '') +  '>';
    1413                for (; y ear <= end Year; year ++) {
    1414                    html  += '<opti on value=" ' + year +  '"' +
    1415                         (year == d rawYear ?  ' selected ="selected "' : '') +
    1416                         '>' + year  + '</opti on>';
    1417                }
    1418                html +=  '</select> ';
    1419           }
    1420           ht ml += '</d iv>'; // C lose datep icker_head er
    1421           re turn html;
    1422       },
    1423  
    1424       /* Pro vide code  to set and  clear the  status pa nel. */
    1425       _addSt atus: func tion(text)  {
    1426           re turn ' onm ouseover=" jQuery(\'# datepicker _status_'  + this._id  + '\').ht ml(\'' + t ext + '\') ;" ' +
    1427                'onmouse out="jQuer y(\'#datep icker_stat us_' + thi s._id + '\ ').html(\' &#xa0;\'); "';
    1428       },
    1429  
    1430       /* Adj ust one of  the date  sub-fields . */
    1431       _adjus tDate: fun ction(offs et, period ) {
    1432           va r year = t his._drawY ear + (per iod == 'Y'  ? offset  : 0);
    1433           va r month =  this._draw Month + (p eriod == ' M' ? offse t : 0);
    1434           va r day = Ma th.min(thi s._selecte dDay, this ._getDaysI nMonth(yea r, month))  +
    1435                (period  == 'D' ? o ffset : 0) ;
    1436           va r date = n ew Date(ye ar, month,  day);
    1437           //  ensure it  is within  the bound s set
    1438           va r minDate  = this._ge tMinMaxDat e('min', t rue);
    1439           va r maxDate  = this._ge tMinMaxDat e('max');
    1440           da te = (minD ate && dat e < minDat e ? minDat e : date);
    1441           da te = (maxD ate && dat e > maxDat e ? maxDat e : date);
    1442           th is._select edDay = da te.getDate ();
    1443           th is._drawMo nth = this ._selected Month = da te.getMont h();
    1444           th is._drawYe ar = this. _selectedY ear = date .getFullYe ar();
    1445       },
    1446       
    1447       /* Det ermine the  number of  months to  show. */
    1448       _getNu mberOfMont hs: functi on() {
    1449           va r numMonth s = this._ get('numbe rOfMonths' );
    1450           re turn (numM onths == n ull ? [1,  1] : (type of numMont hs == 'num ber' ? [1,  numMonths ] : numMon ths));
    1451       },
    1452  
    1453       /* Det ermine the  current m aximum dat e - ensure  no time c omponents  are set -  may be ove rridden fo r a range.  */
    1454       _getMi nMaxDate:  function(m inMax, che ckRange) {
    1455           va r date = t his._deter mineDate(m inMax + 'D ate', null );
    1456           if  (date) {
    1457                date.set Hours(0);
    1458                date.set Minutes(0) ;
    1459                date.set Seconds(0) ;
    1460                date.set Millisecon ds(0);
    1461           }
    1462           re turn date  || (checkR ange ? thi s._rangeSt art : null );
    1463       },
    1464  
    1465       /* Fin d the numb er of days  in a give n month. * /
    1466       _getDa ysInMonth:  function( year, mont h) {
    1467           re turn 32 -  new Date(y ear, month , 32).getD ate();
    1468       },
    1469  
    1470       /* Fin d the day  of the wee k of the f irst of a  month. */
    1471       _getFi rstDayOfMo nth: funct ion(year,  month) {
    1472           re turn new D ate(year,  month, 1). getDay();
    1473       },
    1474  
    1475       /* Det ermines if  we should  allow a " next/prev"  month dis play chang e. */
    1476       _canAd justMonth:  function( offset, cu rYear, cur Month) {
    1477           va r numMonth s = this._ getNumberO fMonths();
    1478           va r date = n ew Date(cu rYear, cur Month + (o ffset < 0  ? offset :  numMonths [1]), 1);
    1479           if  (offset <  0) {
    1480                date.set Date(this. _getDaysIn Month(date .getFullYe ar(), date .getMonth( )));
    1481           }
    1482           re turn this. _isInRange (date);
    1483       },
    1484  
    1485       /* Is  the given  date in th e accepted  range? */
    1486       _isInR ange: func tion(date)  {
    1487           //  during ra nge select ion, use m inimum of  selected d ate and ra nge start
    1488           va r newMinDa te = (!thi s._rangeSt art ? null  :
    1489                new Date (this._sel ectedYear,  this._sel ectedMonth , this._se lectedDay) );
    1490           ne wMinDate =  (newMinDa te && this ._rangeSta rt < newMi nDate ? th is._rangeS tart : new MinDate);
    1491           va r minDate  = newMinDa te || this ._getMinMa xDate('min ');
    1492           va r maxDate  = this._ge tMinMaxDat e('max');
    1493           re turn ((!mi nDate || d ate >= min Date) && ( !maxDate | | date <=  maxDate));
    1494       },
    1495       
    1496       /* Pro vide the c onfigurati on setting s for form atting/par sing. */
    1497       _getFo rmatConfig : function () {
    1498           va r shortYea rCutoff =  this._get( 'shortYear Cutoff');
    1499           sh ortYearCut off = (typ eof shortY earCutoff  != 'string ' ? shortY earCutoff  :
    1500                new Date ().getFull Year() % 1 00 + parse Int(shortY earCutoff,  10));
    1501           re turn {shor tYearCutof f: shortYe arCutoff,
    1502                dayNames Short: thi s._get('da yNamesShor t'), dayNa mes: this. _get('dayN ames'),
    1503                monthNam esShort: t his._get(' monthNames Short'), m onthNames:  this._get ('monthNam es')};
    1504       },
    1505  
    1506       /* For mat the gi ven date f or display . */
    1507       _forma tDate: fun ction(day,  month, ye ar) {
    1508           if  (!day) {
    1509                this._cu rrentDay =  this._sel ectedDay;
    1510                this._cu rrentMonth  = this._s electedMon th;
    1511                this._cu rrentYear  = this._se lectedYear ;
    1512           }
    1513           va r date = ( day ? (typ eof day ==  'object'  ? day : ne w Date(yea r, month,  day)) :
    1514                new Date (this._cur rentYear,  this._curr entMonth,  this._curr entDay));
    1515           re turn $.dat epicker.fo rmatDate(t his._get(' dateFormat '), date,  this._getF ormatConfi g());
    1516       }
    1517   });
    1518  
    1519   /* jQuery  extend now  ignores n ulls! */
    1520   function e xtendRemov e(target,  props) {
    1521       $.exte nd(target,  props);
    1522       for (v ar name in  props) {
    1523           if  (props[na me] == nul l) {
    1524                target[n ame] = nul l;
    1525           }
    1526       }
    1527       return  target;
    1528   };
    1529  
    1530   /* Invoke  the datepi cker funct ionality.
    1531      @param   options   String - a  command,  optionally  followed  by additio nal parame ters or
    1532                         Object - s ettings fo r attachin g new date picker fun ctionality
    1533      @return   jQuery o bject */
    1534   $.fn.datep icker = fu nction(opt ions){
    1535       var ot herArgs =  Array.prot otype.slic e.call(arg uments, 1) ;
    1536       if (ty peof optio ns == 'str ing' && (o ptions ==  'isDisable d' || opti ons == 'ge tDate')) {
    1537           re turn $.dat epicker['_ ' + option s + 'Datep icker'].ap ply($.date picker, [t his[0]].co ncat(other Args));
    1538       }
    1539       return  this.each (function( ) {
    1540           ty peof optio ns == 'str ing' ?
    1541                $.datepi cker['_' +  options +  'Datepick er'].apply ($.datepic ker, [this ].concat(o therArgs))  :
    1542                $.datepi cker._atta chDatepick er(this, o ptions);
    1543       });
    1544   };
    1545       
    1546   /* Initial ise the da te picker.  */
    1547   $(document ).ready(fu nction() {
    1548       $.date picker = n ew Datepic ker(); //  singleton  instance
    1549       $(docu ment.body) .append($. datepicker ._datepick erDiv).
    1550           mo usedown($. datepicker ._checkExt ernalClick );
    1551   });
    1552  
    1553   })(jQuery) ;