function GooCalendar(n,t){var u,r;for(this.$divId=t.divId,this.$div=$("
"),this.$div.addClass("Calendar"),t.fixid&&(this.$fixid=t.fixid),temp="",u="8:009:0010:0011:0012:0013:0014:0015:0016:0017:0018:0019:0020:00任何时间取消
",this.$div.append(temp),r=new Date,this.$daysNum=[31,28,31,30,31,30,31,31,30,31,30,31],this.$date={year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),week:r.getDay(),hour:r.getHours(),minute:r.getMinutes(),second:r.getSeconds()},this.$days=this.$div.children(".day"),this.$selectYear=$("aa年"),this.$selectMonth=$("aa"),this.$div.children(".top").children("b:eq(0)").after(this.$selectMonth).after(this.$selectYear),this.$selectDay=null,this.$selectTime=null,this.$needTime=!1,t.showHour!=null&&(this.$showHour=t.showHour),t.needTime&&(this.$needTime=t.needTime,this.$selectTime={hour:$("23) this.value='0'\"/>"),minute:$("59) this.value='0'\"/>"),second:$("59) this.value='0'\"/>")},this.$div.children(".bottom").children(".time").append(this.$selectTime.hour).append(":").append(this.$selectTime.minute).append(":").append(this.$selectTime.second)),this.$week=t.week?t.week:["Su","Mo","Tu","We","Th","Fr","Sa"],temp="",i=0;i-1?""+this.$week[i]+"
":""+this.$week[i]+"
";for(this.$div.children("div:eq(1)").append(temp),this.$yearRange=t.yearRange?t.yearRange:[1970,2030],temp="",i=this.$yearRange[0];i<=this.$yearRange[1];++i)temp+="";for(this.$selectYear.children("select").html(temp),this.$selectYear.children("select").val(this.$date.year),this.$selectYear.children("span").html(this.$date.year),this.$month=t.month?t.month:["January","February","March","April","May","June","July","August","September","October","November","December"],temp="",i=0;i"+this.$month[i]+"";this.$selectMonth.children("select").html(temp),this.$selectMonth.children("select").val(this.$date.month),this.$selectMonth.children("span").text(this.$month[this.$date.month-1]),this.$format=t.format?t.format:"yyyy-MM-dd hh:mm",this.initDatesByYM=function(n,t){var i,u,f;for(this.$days.empty(),first=new Date(n,t-1,1).getDay(),i=first>0?"":"",r=new Date,nowYear=r.getFullYear(),nowMonth=r.getMonth(),nowDate=r.getDate(),u=1;u<=this.$daysNum[t-1];++u)i+="",i=i.replace("","")):t今天",i=i.replace("","")):n==nowYear&&t==nowMonth+1&&u==nowDate?(i+=" reds' style='color:red'>今天",i=i.replace("","")):i+="'>"+u+"";n%4==0&&t==2&&(i+=""),this.$days.append(i),this.$selectDay=this.$days.children(".select"),this.$days.find("div").each(function(){var r=new Date(n,t-1,$(this).children().text()).getDay();(r=="6"||r=="0")&&$(this).children().css("color","red")})},this.preMonth=function(){year=this.$selectYear.children("span").text(),month=this.$selectMonth.children("select").val(),month>1?month--:(month=12,year--,this.$selectYear.children("span").text(year),this.$selectYear.children("span").attr("value",year)),this.$selectMonth.children("span").text(this.$month[month-1]),this.$selectMonth.children("select").attr("value",month),this.initDatesByYM(year,month)},this.nextMonth=function(){year=this.$selectYear.children("span").text(),month=this.$selectMonth.children("select").val(),month<12?month++:(month=1,year++,this.$selectYear.children("span").text(year),this.$selectYear.children("span").val(year)),this.$selectMonth.children("span").text(this.$month[month-1]),this.$selectMonth.children("select").val(month),this.initDatesByYM(year,month)},this.$days.bind("click",{inthis:this},function(i){var r,f;return inthis=i.data.inthis,r=$(i.target),r.is("a")?(i&&i.preventDefault?i.preventDefault():window.event.returnValue=!1,inthis.$selectDay.removeClass("select"),r.addClass("select"),inthis.$selectDay=r,inthis.$date.year=inthis.$selectYear.children("select").val(),inthis.$date.month=inthis.$selectMonth.children("select").val(),inthis.$date.day=r.text(),inthis.$needTime&&(inthis.$date.hour=inthis.$selectTime.hour.val(),inthis.$date.minute=inthis.$selectTime.minute.val(),inthis.$date.second=inthis.$selectTime.second.val()),f=new Date(inthis.$date.year,inthis.$date.month-1,inthis.$date.day),inthis.$date.week=f.getDay(),inthis.$needTime&&f.setHours(inthis.$date.hour,inthis.$date.minute,inthis.$date.second),t.showHour?($(".day").find("a").each(function(){$(this).next().remove()}),r.parent().append(u),$(".carelative").removeClass("carelative"),r.parent().addClass("carelative"),$.browser.msie?$.browser.version=="6.0"?r.next().css({left:-(6-inthis.$date.week)*16+"px",top:"5px"}):r.next().css({left:32*(inthis.$date.week+1),top:"5px"}):r.next().css({left:32*(inthis.$date.week+1),top:Math.floor((parseInt(new Date(inthis.$date.year,inthis.$date.month-1,1).getDay())+parseInt(inthis.$date.day)-1)/7)*22}),$(".qx").bind("click",function(){$("#"+t.divId).hide()}),$("#daynow").text(new Date($("#"+t.divId+"Year").children("span").text(),inthis.$date.month-1,inthis.$date.day).format("yyyy-MM-dd")),$(".calendartime").find("span").each(function(){$(this).bind("click",function(){$(this).text()!="任何时间"?$("#"+n).val(new Date($("#"+t.divId+"Year").children("span").text(),inthis.$date.month-1,inthis.$date.day).format("yyyy-MM-dd")+" "+$(this).text()):$("#"+n).val(new Date($("#"+t.divId+"Year").children("span").text(),inthis.$date.month-1,inthis.$date.day).format("yyyy-MM-dd")),inthis.$div.hide(),$(".day").find("a").each(function(){$(this).removeClass("select"),$(this).next().remove()})}),$(this).bind("mouseover",function(){$(this).addClass("spanhover"),$(this).css("color","#fff")}),$(this).bind("mouseout",function(){$(this).removeClass("spanhover"),$(this).css("color","#03589B")})})):(inthis.$fixid||inthis.$div.css("display","none"),$("#"+n).val(f.format("yyyy-MM-dd"))),!1):void 0}),this.initDatesByYM(this.$date.year,this.$date.month),this.$div.children(".top").children("b:eq(0)").bind("click",{inthis:this},function(n){inthis=n.data.inthis,inthis.preMonth()}),this.$div.children(".top").children("b:eq(3)").bind("click",{inthis:this},function(n){inthis=n.data.inthis,inthis.nextMonth()}),this.$selectMonth.bind("mousedown",function(){tmpThis=$(this).children("span"),tmpThis.css("display")!="none"&&(tmpThis.hide(),$(this).children("select").show(),$(this).children("select").focus(),$(this).next().children("select").blur())}),this.$selectYear.bind("mousedown",function(){tmpThis=$(this).children("span"),tmpThis.css("display")!="none"&&(tmpThis.hide(),$(this).children("select").show(),$(this).children("select").focus(),$(this).prev().children("select").blur())}),this.$selectMonth.children("select").bind("blur",{span:this.$selectMonth.children("span"),inthis:this},function(n){tmpThis=$(this),inthis=n.data.inthis,n.data.span.text!=inthis.$month[tmpThis.val()-1]&&(n.data.span.text(inthis.$month[tmpThis.val()-1]),inthis.initDatesByYM(inthis.$selectYear.children("select").val(),tmpThis.val())),tmpThis.hide(),n.data.span.show()}),this.$selectMonth.children("select").bind("change",function(){this.blur()}),this.$selectYear.children("select").bind("blur",{span:this.$selectYear.children("span"),inthis:this},function(n){tmpThis=$(this),inthis=n.data.inthis,n.data.span.text!=tmpThis.val()&&(n.data.span.text(tmpThis.val()),inthis.initDatesByYM(tmpThis.val(),inthis.$selectMonth.children("select").val())),tmpThis.hide(),n.data.span.show()}),this.$selectYear.children("select").bind("change",function(){this.blur()}),this.gotoToday=function(){r=new Date,year=r.getFullYear(),month=r.getMonth()+1,this.$selectMonth.children("span").text(this.$month[month-1]),this.$selectMonth.children("select").val(month),this.$selectYear.children("span").text(year),this.$selectYear.children("select").val(year),this.initDatesByYM(year,month),this.$needTime&&(this.$selectTime.hour.val(r.getHours()),this.$selectTime.minute.val(r.getMinutes()),this.$selectTime.second.val(r.getSeconds()))},this.$div.children(".bottom").children("div:eq(0)").bind("click",{inthis:this},function(n){n.data.inthis.gotoToday()}),this.cancel=function(){this.$selectMonth.children("span").text(this.$month[this.$date.month-1]),this.$selectMonth.children("select").val(this.$date.month),this.$selectYear.children("span").text(this.$date.year),this.$selectYear.children("select").val(this.$date.year),this.initDatesByYM(this.$date.year,this.$date.month),this.$needTime&&(this.$selectTime.hour.val(this.$date.hour),this.$selectTime.minute.val(this.$date.minute),this.$selectTime.second.val(this.$date.second)),this.$div.hide()},this.$fixid?$("#"+this.$fixid).append(this.$div.css("display","block")):(this.$div.children(".bottom").children("div:eq(2)").bind("click",{inthis:this},function(n){n.data.inthis.cancel()}),$("body").append(this.$div),$("#img"+n+" ,#"+n).bind("mousedown",{div:this.$div},function(n){var i=getElCoordinate(this);i.top+=$(this).attr("offsetHeight"),n.data.div.css({top:i.top+"px",left:i.left+"px",display:"block"}),$(".qx").bind("click",function(){$("#"+t.divId).hide()})})),document.getElementById(n).value=""}jQuery.extend({createGooCalendar:function(n,t){return new GooCalendar(n,t)}});