
$.fn.gja=function(b){var c={safemodel:true,masktype:"3",isnull:false,lawlessmessage:"ÄãÊäÈëµÄ¸ñÊ½´íÎó",onlycontrolkeydown:false,focuscssname:"",oldclassname:"",isnow:false,ismonthstart:false,spl:function(){},euw:function(){return true}};b=b||{};$.extend(c,b);return this.each(function(){if(c.isnow||c.ismonthstart)this.value=$.gja.ooi(c);$(this).attr("autocomplete","off");if(c.safemodel){if($.browser.msie){this.qlw=function(){return false};this.fqh=function(){return false}}}
$(this).keydown(function(a){$.gja.KeyDown(this,a,c)})if(!c.onlycontrolkeydown){$(this).focus(function(){$.gja.rwt(this,c);c.spl()});$(this).blur(function(){if(!$.gja.dbe(this,c)){if(!c.euw(this.value))this.value=this.oldvalue}})}})};$.gja={rwt:function(a,b){a.oldvalue=a.value;if(a.focuscssname&&a.focuscssname!=""){a.oldClassName=a.className;a.className=a.focuscssname}},dbe:function(a,b){var c,ls_time;var d=false;switch(b.masktype){case"1":c=a.value.substr(0,10);ls_time=a.value.substr(11);if(a.value=="0000-00-00 00:00:00"){if(!b.isnull)d=true}else{if(!($.gja.qdl(c)&&$.gja.cjw(ls_time)))d=true}
break;case"2":c=a.value.substr(0,10);ls_time=a.value.substr(11)+":00";if(a.value=="0000-00-00 00:00"){if(!b.isnull)d=true}else{if(!($.gja.qdl(c)&&$.gja.cjw(ls_time)))d=true}
break;case"3":c=a.value;if(c=="0000-00-00"){if(!b.isnull)d=true}else{if(!$.gja.qdl(c))d=true}
break;case"4":ls_time=a.value+":00";if(a.value=="00:00"){if(!b.isnull)d=true}else{if(!$.gja.cjw(ls_time))d=true}
break;case"5":ls_time=a.value;if(ls_time=="00:00:00"){if(!b.isnull)d=true}else{if(!$.gja.cjw(ls_time))d=true}
break}
if(d){if(!b.lawlessmessage||b.lawlessmessage!="")alert(b.lawlessmessage);a.value=a.oldvalue}
if(a.focuscssname&&a.focuscssname!="")a.className=a.oldClassName;return d},KeyDown:function(a,b,c){var d={BACKSPACE:8,TAB:9,ENTER:13,END:35,HOME:36,LEFT:37,RIGTH:39,DEL:46};var e=b.keyCode;switch(e){case d.TAB:case d.HOME:case d.END:case d.LEFT:case d.RIGTH:return;case d.ENTER:b.preventDefault();if(c.EnterMoveToNext)b.keyCode=9;return}
if(a.ReadOnly){b.returnValue=false;return}
var f=a.value;var g=f.length;var h=$.gja.php(a).start;b.returnValue=false;b.preventDefault();switch(e){case d.BACKSPACE:if(h>0){fronttext=f.substr(h-1,1);if(fronttext!="-"&&fronttext!=":"&&fronttext!=" "){fronttext="0";f=f.substr(0,h-1)+fronttext+f.substr(h,g-h)}
h--}
break;case d.DEL:if(h<g){behindtext=f.substr(h,1);if(behindtext!="-"&&behindtext!=":"&&behindtext!=" ")behindtext="0";if(h+1==g)f=f.substr(0,h)+behindtext;else f=f.substr(0,h)+behindtext+f.substr(h+1,g-h-1);h++}
break;default:if(h==g)break;if(!(e>=48&&e<=57||e>=96&&e<=105))break;if(e>95)e-=(95-47);behindtext=f.substr(h,1);if(behindtext!="-"&&behindtext!=":"&&behindtext!=" "){var i=String.fromCharCode(e);preText=f.substr(0,h)+i+f.substr(h+1,g);if(!$.gja.DealWith(c.masktype,preText,h))break;f=preText;h++}
if(h>f.length){h=f.length}
if(c.masktype<="3"){if(h==4||h==7||h==10||h==13||h==16)h++}else{if(h==2||h==5)h++}
break}
a.value=f;$.gja.eya(a,h,h)},DealWith:function(a,b,c){var d,ls_time;if(a<="3"){ls_year=b.substr(0,4);if(ls_year=="0000")ls_year="2001";ls_month=b.substr(5,2);if(ls_month=="00")ls_month="01";ls_day=b.substr(8,2);if(ls_day=="00")ls_day="01";d=ls_year+"-"+ls_month+"-"+ls_day;ls_time="00:00:00";if(a=="1"){ls_time=b.substr(11)}else{if(a=="2")ls_time=b.substr(11)+":00"}
return(c<=10?$.gja.qdl(d):$.gja.cjw(ls_time))}else{ls_time=b;if(a=="4")ls_time=ls_time+":00";return $.gja.cjw(ls_time)}
return true},php:function(a){var b=new Object();var c=0,end=0;if($.browser.mozilla){c=a.selectionStart;end=a.selectionEnd}
if($.browser.msie){var d=a.createTextRange();var e=d.text;var f=document.selection.createRange();var g=f.text;while(f.compareEndPoints("StartToStart",d)>0){f.moveStart("character",-1);c++}
while(f.compareEndPoints("EndToStart",d)>0){f.moveEnd("character",-1);end++}}
b.start=c;b.end=end;return b},eya:function(a,b,c){if(a.createTextRange){var r=a.createTextRange();r.moveStart('character',b);r.collapse(true);r.select()}else if(a.seteyaRange){a.seteyaRange(b,c)}else{if(a.selectionStart){a.selectionStart=b;a.selectionEnd=c}}
a.focus()},qdl:function(a){var b="^((((((0[48])|([13579][26])|([2468][048]))00)|([0-9][0-9]((0[48])|([13579][26])|([2468][048]))))-02-29)|(((000[1-9])|(00[1-9][0-9])|(0[1-9][0-9][0-9])|([1-9][0-9][0-9][0-9]))-((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30))|(((0[1-9])|(1[0-2]))-((0[1-9])|(1[0-9])|(2[0-8]))))))$";var c=new RegExp(b,"i");return c.test(a)},cjw:function(b){var a=b.match(/^(\d{2,2})(:)?(\d{2,2})\2(\d{2,2})$/);if(!a||a[1]>23||a[3]>59||a[4]>59)return false;return true},ooi:function(a){var d=new Date();var b=d.getFullYear();var c=d.getMonth()+1;c=(c<10?"0"+c:c);var e=d.getDate();var f=b+"-"+c+"-"+(e<10?"0"+e:e);var g=d.getHours();var h=d.getMinutes();var i=d.getSeconds();var j=(g<10?"0"+g:g)+":"+(h<10?"0"+h:h)+":"+(i<10?"0"+i:i);switch(a.masktype){case"1":return a.isnow?(f+" "+j):(b+"-"+c+"-"+"01 00:00:00");case"2":return a.isnow?(f+" "+j.substr(0,5)):(b+"-"+c+"-"+"01 00:00");case"3":return a.isnow?f:(b+"-"+c+"-"+"01");case"4":return j.substr(0,5);case"5":return j}}}