/* * Date picker plugin for jQuery * http://binarypusher.com * * Copyright (c) 2006 Steve Bramley (binarypusher.com) * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php * * $LastChangedDate: 2006-08-23 12:39:59 +0800 (Wed, 23 Aug 2006) $ * $Rev: 0 $ */ var cal = new function() { $.fn.calendar = function(o, d, m, y){ if(typeof(o._day == "undefined")){ init(o); } $(o).hover(function(){},function(){}).css({cursor:"pointer"}); $(o).click(function(){popCal(this, this._today)}); }; function init(o) { o._days = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30,31, 30, 31); o._day_names = new Array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); o._month_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September","October", "November", "December"); o._raw_date_string = o.value; o._day = Number(o._raw_date_string.split("/")[0]); o._month = Number(o._raw_date_string.split("/")[1]); o._year = Number(o._raw_date_string.split("/")[2]); o._today = null; o.target_elem = o; if (o._year == null || o._month == null || isNaN(o._year) || isNaN(o._month)){ o._today = new Date(); o._year = o._today.getYear(); o._month = o._today.getMonth(); } else { o._today = new Date() o._today.setFullYear(o._year, Number(o._month-1),o._day); } if ((o._year % 4 == 0) && (o._year % 100 != 0)){ o._days[1] = 29; } } function shutCal(o) { $('#' + o.id).parent().find(".picker").remove(); $(o).validate.init(o); } function popCal(o,d) { shutCal(o); var current_date = d; var year = null; current_date.setDate(1); if ((Number(d.getYear())+1900) > 3000){ year = d.getYear(); } else { year = (Number(d.getYear())+1900); } var first_of_month = current_date.getDay(); var _minus_month = new Date(Number(year),Number(d.getMonth()-1),1); var _plus_month = new Date(Number(year),Number(d.getMonth()+1),1);//((current_date.getMonth()+1) == 13) ? 1 : (current_date.getMonth()+1); var _minus_year = new Date(Number(year-1),d.getMonth(),1,0,0,0,0);//(Number(current_date.getYear())+1899); var _plus_year = new Date(Number(year+1),d.getMonth(),1,0,0,0,0);//(Number(current_date.getYear())+1901); var target = $('#' + o.id).parent().append(''); teststring = '