/*
Copyright 2010, KISSY UI Library v1.1.5
MIT Licensed
build time: Sep 19 17:41
*/
KISSY.add("date",function(e){var j=function(){var i=/w{1}|d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,a=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,b=/[^-+\dA-Z]/g,c=function(f,g){f=String(f);for(g=g||2;f.length<g;)f="0"+f;return f},d={"default":"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",longTime:"h:MM:ss TT Z",
isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUTCDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",localShortDate:"yy\u5e74mm\u6708dd\u65e5",localShortDateTime:"yy\u5e74mm\u6708dd\u65e5 hh:MM:ss TT",localLongDate:"yyyy\u5e74mm\u6708dd\u65e5",localLongDateTime:"yyyy\u5e74mm\u6708dd\u65e5 hh:MM:ss TT",localFullDate:"yyyy\u5e74mm\u6708dd\u65e5 w",localFullDateTime:"yyyy\u5e74mm\u6708dd\u65e5 w hh:MM:ss TT"},h={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","\u661f\u671f\u65e5","\u661f\u671f\u4e00","\u661f\u671f\u4e8c","\u661f\u671f\u4e09","\u661f\u671f\u56db","\u661f\u671f\u4e94",
"\u661f\u671f\u516d"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]};return function(f,g,l){if(arguments.length==1&&Object.prototype.toString.call(f)=="[object String]"&&!/\d/.test(f)){g=f;f=undefined}f=f?new Date(f):new Date;if(isNaN(f))throw SyntaxError("invalid date");g=String(d[g]||g||d["default"]);if(g.slice(0,4)=="UTC:"){g=g.slice(4);l=true}var k=l?"getUTC":"get",
n=f[k+"Date"](),q=f[k+"Day"](),o=f[k+"Month"](),s=f[k+"FullYear"](),m=f[k+"Hours"](),t=f[k+"Minutes"](),u=f[k+"Seconds"]();k=f[k+"Milliseconds"]();var r=l?0:f.getTimezoneOffset(),v={d:n,dd:c(n),ddd:h.dayNames[q],dddd:h.dayNames[q+7],w:h.dayNames[q+14],m:o+1,mm:c(o+1),mmm:h.monthNames[o],mmmm:h.monthNames[o+12],yy:String(s).slice(2),yyyy:s,h:m%12||12,hh:c(m%12||12),H:m,HH:c(m),M:t,MM:c(t),s:u,ss:c(u),l:c(k,3),L:c(k>99?Math.round(k/10):k),t:m<12?"a":"p",tt:m<12?"am":"pm",T:m<12?"A":"P",TT:m<12?"AM":
"PM",Z:l?"UTC":(String(f).match(a)||[""]).pop().replace(b,""),o:(r>0?"-":"+")+c(Math.floor(Math.abs(r)/60)*100+Math.abs(r)%60,4),S:["th","st","nd","rd"][n%10>3?0:(n%100-n%10!=10)*n%10]};return g.replace(i,function(p){return p in v?v[p]:p.slice(1,p.length-1)})}}();e.Date={format:function(i,a,b){return j(i,a,b)},parse:function(i){var a=null;if(a instanceof Date)i=a;else{a=new Date(i);i=a instanceof Date&&a!="Invalid Date"&&!isNaN(a)?a:null}return i}}});
KISSY.add("calendar",function(e,j){function i(a,b){this._init(a,b)}e.augment(i,{_init:function(a,b){var c=e.one(a);this.id=this.C_Id=this._stamp(c);this._buildParam(b);if(this.popup){this.trigger=c;this.con=e.Node("<div></div>");e.one("body").append(this.con);this.C_Id=this._stamp(this.con);this.con.css({top:"0px",position:"absolute",background:"white",visibility:"hidden"})}else this.con=c;c=new Function;e.augment(c,e.EventTarget);c=new c;e.mix(this,c);this.render();this._buildEvent();return this},
render:function(a){var b=0,c,d;a=a||{};this._parseParam(a);this.ca=[];this.con.addClass("ks-cal-call ks-clearfix multi-"+this.pages);this.con.html("");b=0;for(d=[this.year,this.month];b<this.pages;b++){if(b==0)a=true;else{a=false;d=this._computeNextMonth(d)}c=b==this.pages-1;this.ca.push(new this.Page({year:d[0],month:d[1],prevArrow:a,nextArrow:c,showTime:this.showTime},this));this.ca[b].render()}return this},_stamp:function(a){if(a.attr("id")==j||a.attr("id")=="")a.attr("id","K_"+e.now());return a.attr("id")},
_showdate:function(a,b){var c=new Date(b-0+a*864E5);c=c.getFullYear()+"/"+(c.getMonth()+1)+"/"+c.getDate();return new Date(c)},_buildEvent:function(){var a=this;if(!a.popup)return this;for(var b=0;b<a.EV.length;b++)a.EV[b]!==j&&a.EV[b].detach();a.EV[0]=e.one("body").on("click",function(c){c.target=e.Node(c.target);if(c.target.attr("id")!=a.C_Id)if(!((c.target.hasClass("ks-next")||c.target.hasClass("ks-prev"))&&c.target[0].tagName=="A"))if(c.target.attr("id")!=a.id)e.DOM.contains(e.one("#"+a.C_Id),
c.target)||a.hide()});for(b=0;b<a.triggerType.length;b++)a.EV[1]=e.one("#"+a.id).on(a.triggerType[b],function(c){c.target=e.Node(c.target);c.preventDefault();var d=a.triggerType;if(e.inArray("click",d)&&e.inArray("focus",d))c.type=="focus"&&a.toggle();else if(e.inArray("click",d)&&!e.inArray("focus",d))c.type=="click"&&a.toggle();else!e.inArray("click",d)&&e.inArray("focus",d)?setTimeout(function(){a.toggle()},170):a.toggle()});return this},toggle:function(){this.con.css("visibility")=="hidden"?this.show():
this.hide()},show:function(){this.con.css("visibility","");var a=this.trigger.offset().left,b=this.trigger[0].offsetHeight||this.trigger.height();b=this.trigger.offset().top+b;this.con.css("left",a.toString()+"px");this.con.css("top",b.toString()+"px");return this},hide:function(){this.con.css("visibility","hidden");return this},_buildParam:function(a){function b(f,g){var l=a[g];c[g]=l===j||l==null?f:l}var c=this;if(a===j||a==null)a={};e.each({date:new Date,startDay:0,pages:1,closable:false,rangeSelect:false,
minDate:false,maxDate:false,multiSelect:false,navigator:true,popup:false,showTime:false,triggerType:["click"]},b);if(typeof a.triggerType==="string")a.triggerType=[a.triggerType];b(c.date,"selected");if(a.startDay)c.startDay=(7-a.startDay)%7;if(a.range!==j&&a.range!=null){var d=c._showdate(1,new Date(a.range.start.getFullYear()+"/"+(a.range.start.getMonth()+1)+"/"+a.range.start.getDate())),h=c._showdate(1,new Date(a.range.end.getFullYear()+"/"+(a.range.end.getMonth()+1)+"/"+a.range.end.getDate()));
c.range={start:d,end:h}}else c.range={start:null,end:null};c.EV=[];return this},_parseParam:function(a){var b;if(a===j||a==null)a={};for(b in a)this[b]=a[b];this._handleDate();return this},_templetShow:function(a,b){var c,d,h,f;if(b instanceof Array){c="";for(d=0;d<b.length;d++)c+=arguments.callee(a,b[d]);a=c}else{c=a.match(/{\$(.*?)}/g);if(b!==j&&c!=null){d=0;for(h=c.length;d<h;d++){f=c[d].replace(/({\$)|}/g,"");f=b[f]!==j?b[f]:"";a=a.replace(c[d],f)}}}return a},_handleDate:function(){var a=this.date;
this.weekday=a.getDay()+1;this.day=a.getDate();this.month=a.getMonth();this.year=a.getFullYear();return this},_getHeadStr:function(a,b){return a.toString()+"\u5e74"+(Number(b)+1).toString()+"\u6708"},_monthAdd:function(){if(this.month==11){this.year++;this.month=0}else this.month++;this.date=new Date(this.year.toString()+"/"+(this.month+1).toString()+"/"+this.day.toString());return this},_monthMinus:function(){if(this.month==0){this.year--;this.month=11}else this.month--;this.date=new Date(this.year.toString()+
"/"+(this.month+1).toString()+"/"+this.day.toString());return this},_computeNextMonth:function(a){var b=a[0];a=a[1];if(a==11){b++;a=0}else a++;return[b,a]},_handleOffset:function(){var a=["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"],b=this.startDay,c="";c=[];for(var d=0;d<7;d++)c[d]={day:a[(d-b+7)%7]};c=this._templetShow("<span>{$day}</span>",c);return{day_html:c}},_handleRange:function(a){if(this.range.start==null&&this.range.end==null||this.range.start!=null&&this.range.end!=null){this.range.start=a;this.range.end=
null;this.render()}else if(this.range.start!=null&&this.range.end==null){this.range.end=a;if(this.range.start.getTime()>this.range.end.getTime()){a=this.range.start;this.range.start=this.range.end;this.range.end=a}this.fire("rangeSelect",this.range);this.render()}return this}});e.Calendar=i},{requires:["core"]});
KISSY.add("calendar-page",function(e){e.augment(e.Calendar,{Page:function(j,i){this.father=i;this.month=Number(j.month);this.year=Number(j.year);this.prevArrow=j.prevArrow;this.nextArrow=j.nextArrow;this.timmer=this.node=null;this.id="";this.EV=[];this.html=['<div class="ks-cal-box" id="{$id}"><div class="ks-cal-hd"><a href="javascript:void(0);" class="ks-prev {$prev}"><</a><a href="javascript:void(0);" class="ks-title">{$title}</a><a href="javascript:void(0);" class="ks-next {$next}">></a></div><div class="ks-cal-bd"><div class="ks-whd">',
i._handleOffset().day_html,'</div><div class="ks-dbd ks-clearfix">{$ds}</div></div><div class="ks-setime hidden"></div><div class="ks-cal-ft {$showtime}"><div class="ks-cal-time">\u65f6\u95f4\uff1a00:00 &hearts;</div></div><div class="ks-selectime hidden"></div></div><!--#ks-cal-box--\>'].join("");this.nav_html='<p>\u6708<select value="{$the_month}"><option class="m1" value="1">01</option><option class="m2" value="2">02</option><option class="m3" value="3">03</option><option class="m4" value="4">04</option><option class="m5" value="5">05</option><option class="m6" value="6">06</option><option class="m7" value="7">07</option><option class="m8" value="8">08</option><option class="m9" value="9">09</option><option class="m10" value="10">10</option><option class="m11" value="11">11</option><option class="m12" value="12">12</option></select></p><p>\u5e74<input type="text" value="{$the_year}" onfocus="this.select()"/></p><p><button class="ok">\u786e\u5b9a</button><button class="cancel">\u53d6\u6d88</button></p>';
this.Verify=function(){return{isDay:function(a){if(!/\d+/i.test(a))return false;a=Number(a);return!(a<1||a>31)},isYear:function(a){if(!/\d+/i.test(a))return false;a=Number(a);return!(a<100||a>1E4)},isMonth:function(a){if(!/\d+/i.test(a))return false;a=Number(a);return!(a<1||a>12)}}};this._renderUI=function(){var a={};this.HTML="";a.prev="";a.next="";a.title="";a.ds="";if(!this.prevArrow)a.prev="hidden";if(!this.nextArrow)a.next="hidden";if(!this.father.showtime)a.showtime="hidden";a.id=this.id="ks-cal-"+
Math.random().toString().replace(/.\./i,"");a.title=this.father._getHeadStr(this.year,this.month);this.createDS();a.ds=this.ds;this.father.con.append(this.father._templetShow(this.html,a));this.node=e.one("#"+this.id);if(this.father.showTime){a=this.node.one(".ks-cal-ft");a.removeClass("hidden");this.timmer=new this.father.TimeSelector(a,this.father)}return this};this._buildEvent=function(){var a=this,b,c=e.one("#"+a.id);for(b=0;b<a.EV.length;b++)typeof a.EV[b]!="undefined"&&a.EV[b].detach();a.EV[0]=
c.one("div.ks-dbd").on("click",function(d){d.preventDefault();d.target=e.Node(d.target);if(!d.target.hasClass("null"))if(!d.target.hasClass("disabled")){d=Number(d.target.html());var h=new Date;h.setDate(d);h.setMonth(a.month);h.setYear(a.year);a.father.dt_date=h;a.father.fire("select",{date:h});a.father.popup&&a.father.closable&&a.father.hide();a.father.rangeSelect&&a.father._handleRange(h);a.father.render({selected:h})}});a.EV[1]=c.one("a.ks-prev").on("click",function(d){d.preventDefault();a.father._monthMinus().render();
a.father.fire("monthChange",{date:new Date(a.father.year+"/"+(a.father.month+1)+"/01")})});a.EV[2]=c.one("a.ks-next").on("click",function(d){d.preventDefault();a.father._monthAdd().render();a.father.fire("monthChange",{date:new Date(a.father.year+"/"+(a.father.month+1)+"/01")})});if(a.father.navigator){a.EV[3]=c.one("a.ks-title").on("click",function(d){try{a.timmer.hidePopup();d.preventDefault()}catch(h){}d.target=e.Node(d.target);d=c.one(".ks-setime");d.html("");var f=a.father._templetShow(a.nav_html,
{the_month:a.month+1,the_year:a.year});d.html(f);d.removeClass("hidden");c.one("input").on("keydown",function(g){g.target=e.Node(g.target);if(g.keyCode==38){g.target.val(Number(g.target.val())+1);g.target[0].select()}if(g.keyCode==40){g.target.val(Number(g.target.val())-1);g.target[0].select()}if(g.keyCode==13){g=c.one(".ks-setime").one("select").val();var l=c.one(".ks-setime").one("input").val();c.one(".ks-setime").addClass("hidden");if(a.Verify().isYear(l))if(a.Verify().isMonth(g)){a.father.render({date:new Date(l+
"/"+g+"/01")});a.father.fire("monthChange",{date:new Date(l+"/"+g+"/01")})}}})});a.EV[4]=c.one(".ks-setime").on("click",function(d){d.preventDefault();d.target=e.Node(d.target);if(d.target.hasClass("ok")){d=c.one(".ks-setime").one("select").val();var h=c.one(".ks-setime").one("input").val();c.one(".ks-setime").addClass("hidden");if(a.Verify().isYear(h))if(a.Verify().isMonth(d)){a.father.render({date:new Date(h+"/"+d+"/01")});a.father.fire("monthChange",{date:new Date(h+"/"+d+"/01")})}}else d.target.hasClass("cancel")&&
c.one(".ks-setime").addClass("hidden")})}return this};this._getNode=function(){return this.node};this._getNumOfDays=function(a,b){return 32-(new Date(a,b-1,32)).getDate()};this.createDS=function(){var a="",b=((new Date(this.year+"/"+(this.month+1)+"/01")).getDay()+this.father.startDay+7)%7,c=this._getNumOfDays(this.year,this.month+1)+b,d,h;for(d=0;d<c;d++){h=/532/.test(e.UA.webkit)?new Date(this.year+"/"+Number(this.month+1)+"/"+(d+1-b).toString()):new Date(this.year+"/"+Number(this.month+1)+"/"+
(d+2-b).toString());var f=new Date(this.year+"/"+Number(this.month+1)+"/"+(d+1-b).toString());a+=d<b?'<a href="javascript:void(0);" class="ks-null">0</a>':this.father.minDate instanceof Date&&(new Date(this.year+"/"+(this.month+1)+"/"+(d+2-b))).getTime()<this.father.minDate.getTime()+1?'<a href="javascript:void(0);" class="ks-disabled">'+(d-b+1)+"</a>":this.father.maxDate instanceof Date&&(new Date(this.year+"/"+(this.month+1)+"/"+(d+1-b))).getTime()>this.father.maxDate.getTime()?'<a href="javascript:void(0);" class="ks-disabled">'+
(d-b+1)+"</a>":this.father.range.start!=null&&this.father.range.end!=null&&h.getTime()>=this.father.range.start.getTime()&&f.getTime()<this.father.range.end.getTime()?d==b+(new Date).getDate()-1&&(new Date).getFullYear()==this.year&&(new Date).getMonth()==this.month?'<a href="javascript:void(0);" class="ks-range ks-today">'+(d-b+1)+"</a>":'<a href="javascript:void(0);" class="ks-range">'+(d-b+1)+"</a>":d==b+(new Date).getDate()-1&&(new Date).getFullYear()==this.year&&(new Date).getMonth()==this.month?
'<a href="javascript:void(0);" class="ks-today">'+(d-b+1)+"</a>":d==b+this.father.selected.getDate()-1&&this.month==this.father.selected.getMonth()&&this.year==this.father.selected.getFullYear()?'<a href="javascript:void(0);" class="ks-selected">'+(d-b+1)+"</a>":'<a href="javascript:void(0);">'+(d-b+1)+"</a>"}if(c%7!=0)for(d=0;d<7-c%7;d++)a+='<a href="javascript:void(0);" class="ks-null">0</a>';this.ds=a;return this};this.render=function(){this._renderUI();this._buildEvent();return this}}})},{host:"calendar"});
KISSY.add("calendar-time",function(e){e.augment(e.Calendar,{TimeSelector:function(j,i){this.father=i;this.fcon=j.parent(".ks-cal-box");this.popupannel=this.fcon.one(".ks-selectime");if(typeof i._time=="undefined")i._time=new Date;this.time=i._time;this.status="s";this.ctime=e.Node('<div class="ks-cal-time">\u65f6\u95f4\uff1a<span class="h">h</span>:<span class="m">m</span>:<span class="s">s</span><!--{{arrow--\><div class="cta"><button class="u"></button><button class="d"></button></div><!--arrow}}--\></div>');
this.button=e.Node('<button class="ct-ok">\u786e\u5b9a</button>');this.h_a=["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"];this.m_a=["00","10","20","30","40","50"];this.s_a=["00","10","20","30","40","50"];this.parseSubHtml=function(a){for(var b="",c=0;c<a.length;c++)b+='<a href="javascript:void(0);" class="item">'+a[c]+"</a>";b+='<a href="javascript:void(0);" class="x">x</a>';return b};this.showPopup=function(a){this.popupannel.html(a);
this.popupannel.removeClass("hidden");a=this.status;this.ctime.all("span").removeClass("on");switch(a){case "h":this.ctime.all(".h").addClass("on");break;case "m":this.ctime.all(".m").addClass("on");break;case "s":this.ctime.all(".s").addClass("on")}};this.hidePopup=function(){this.popupannel.addClass("hidden")};this.render=function(){var a=this.get("h"),b=this.get("m"),c=this.get("s");this.father._time=this.time;this.ctime.all(".h").html(a);this.ctime.all(".m").html(b);this.ctime.all(".s").html(c);
return this};this.set=function(a,b){b=Number(b);switch(a){case "h":this.time.setHours(b);break;case "m":this.time.setMinutes(b);break;case "s":this.time.setSeconds(b)}this.render()};this.get=function(a){var b=this.time;switch(a){case "h":return b.getHours();case "m":return b.getMinutes();case "s":return b.getSeconds()}};this.add=function(){var a=this.status,b=this.get(a);b++;this.set(a,b)};this.minus=function(){var a=this.status,b=this.get(a);b--;this.set(a,b)};this._init=function(){var a=this;j.html("").append(a.ctime);
j.append(a.button);a.render();a.popupannel.on("click",function(b){b=e.Node(b.target);if(b.hasClass("x"))a.hidePopup();else if(b.hasClass("item")){b=Number(b.html());a.set(a.status,b);a.hidePopup()}});a.button.on("click",function(){var b=typeof a.father.dt_date=="undefined"?a.father.date:a.father.dt_date;b.setHours(a.get("h"));b.setMinutes(a.get("m"));b.setSeconds(a.get("s"));a.father.fire("timeSelect",{date:b});a.father.popup&&a.father.closable&&a.father.hide()});a.ctime.on("keyup",function(b){if(b.keyCode==
38||b.keyCode==37){b.preventDefault();a.add()}if(b.keyCode==40||b.keyCode==39){b.preventDefault();a.minus()}});a.ctime.one(".u").on("click",function(){a.hidePopup();a.add()});a.ctime.one(".d").on("click",function(){a.hidePopup();a.minus()});a.ctime.one(".h").on("click",function(){var b=a.parseSubHtml(a.h_a);a.status="h";a.showPopup(b)});a.ctime.one(".m").on("click",function(){var b=a.parseSubHtml(a.m_a);a.status="m";a.showPopup(b)});a.ctime.one(".s").on("click",function(){var b=a.parseSubHtml(a.s_a);
a.status="s";a.showPopup(b)})};this._init()}})},{host:"calendar"});
