/* * my97 datepicker 4.2 * site: http://dp.my97.net * blog: http://my97.cnblogs.com * mail: smallcarrot@163.com */ var $dp,wdatepicker;(function(){var $={ $wdate:true, $crossframe:false, $dppath:"", position:{}, lang:"auto", skin:"default", datefmt:"yyyy-mm-dd", realdatefmt:"yyyy-mm-dd", realtimefmt:"hh:mm:ss", realfullfmt:"%date %time", mindate:"1900-01-01 00:00:00", maxdate:"2099-12-31 23:59:59", startdate:"", alwaysusestartdate:false, yearoffset:1911, isshowweek:false, highlineweekday:true, isshowclear:true, isshowtoday:true, isshowothers:true, readonly:false, errdealmode:0, autopickdate:null, qsenabled:true, disableddates:null,disableddays:null,opposite:false,onpicking:null,onpicked:null,onclearing:null,oncleared:null,econt:null,vel:null,errmsg:"",quicksel:[],has:{}};wdatepicker=s;var v=window,n="document",h="documentelement",a="getelementsbytagname",t,_,r,g,z;switch(navigator.appname){case"microsoft internet explorer":r=true;break;case"opera":z=true;break;default:g=true;break}t=v;if($.$crossframe){try{while(t.parent[n]!=t[n]&&t.parent[n][a]("frameset").length==0)t=t.parent}catch(p){}}_=j();if($.$wdate)k(_+"skin/wdatepicker.css");var l;if(t.$dp){try{l=(t.$dp.$("my")=="likemy97")}catch(p){l=p.number==-2146823277?true:false}}if(!t.$dp||l){$dp=q({ff:g,ie:r,opera:z,el:null,win:v,status:l?2:0,defmindate:$.mindate,defmaxdate:$.maxdate,$:function(_){try{this.win[n]}catch($){return"likemy97"}return(typeof _=="string")?this.win[n].getelementbyid(_):_},$d:function($,_){return this.$dv(this.$($).value,_)},$dv:function(_,$){if(_!=""){this.dt=$dp.cal.splitdate(_,$dp.cal.datefmt);if($)for(var a in $){if(this.dt[a]===undefined)this.errmsg="invalid property:"+a;this.dt[a]+=$[a]}if(this.dt.refresh())return this.dt}return""},show:function(){if(this.dd)this.dd.style.display="block"},hide:function(){if(this.dd)this.dd.style.display="none"},attachevent:c});if(!l)x(t,function(){s(null,true)})}else $dp=t.$dp;if(!v[n].docmd){c(v[n],"onmousedown",b);v[n].docmd=true}if(!t[n].docmd){c(t[n],"onmousedown",b);t[n].docmd=true}c(v,"onunload",function(){$dp.hide()});function q(_){t.$dp=t.$dp||{};for(var $ in _)t.$dp[$]=_[$];return t.$dp}function c(a,$,_){if(r)a.attachevent($,_);else{var b=$.replace(/on/,"");_._ieemueventhandler=function($){return _($)};a.addeventlistener(b,_._ieemueventhandler,false)}}function j(){var _,a,$=document.getelementsbytagname("script");for(var b=0;b<$.length;b++){_=$[b].src.substring(0,$[b].src.tolowercase().indexof("wdatepicker.js"));a=_.lastindexof("/");if(a>0)_=_.substring(0,a+1);if(_)break}return _}function d(f){var e,c;if(f.substring(0,1)!="/"&&f.indexof("://")==-1){e=t.location.href;c=location.href;if(e.indexof("?")>-1)e=e.substring(0,e.indexof("?"));if(c.indexof("?")>-1)c=c.substring(0,c.indexof("?"));var _="",d="",a="",h,g,b="";for(h=0;h_.scrollleft||a.scrollleft>_.scrollleft))?a:_;return{"top":b.scrolltop,"left":b.scrollleft}}function b(_){src=_?(_.srcelement||_.target):null;if($dp&&$dp.dd&&$dp.dd.style.display=="block"&&src!=$dp.el){var a=$dp.el,b=$dp.cal,$=$dp.el[$dp.elprop];if($!=null){$dp.$w.hidesel();if($!=""&&!$dp.readonly)b.date.loadfromdate(b.splitdate($,b.datefmt));if($==""||(b.isdate(b.date)&&b.istime(b.date)&&b.checkvalid(b.date))){b.mark(true);if($!="")b.update();else b.setrealvalue("");$dp.hide()}else b.mark(false)}else $dp.hide()}}var o=[];function w(){$dp.status=2;f()}function f(){if(o.length>0){var $=o.shift();$.el={innerhtml:""};$.econt=$dp.$($.econt);$.autopickdate=true;$.qsenabled=false;i($)}}function s(c,$){$dp.win=v;c=c||{};if($){$dp.status=1;i({el:{innerhtml:""}},true)}else if(c.econt){o.push(c);if($dp.status==2)f()}else{if($dp.status==0)$dp.status=1;if($dp.status!=2)return;var b,a=_();if(a){b=a.srcelement||a.target;a.cancelbubble=true}c.el=$dp.$(c.el||b);if(!c.el||c.el&&c.el.disabled||(c.el==$dp.el&&$dp.dd.style.display!="none"&&$dp.dd.style.left!="-1970px"))return;i(c)}function _(){if(g){func=_.caller;while(func!=null){var $=func.arguments[0];if($&&($+"").indexof("event")>=0)return $;func=func.caller}return null}return event}}function i(g,a){for(var f in $)if(f.substring(0,1)!="$")$dp[f]=$[f];for(f in g)if($dp[f]===undefined)$dp.errmsg="invalid property:"+f;else $dp[f]=g[f];$dp.elprop=$dp.el&&$dp.el.nodename=="input"?"value":"innerhtml";if($dp.el[$dp.elprop]==null)return;if($dp.lang=="auto")$dp.lang=r?navigator.browserlanguage.tolowercase():navigator.language.tolowercase();if(!$dp.dd||$dp.econt||($dp.lang&&$dp.reallang&&$dp.reallang.name!=$dp.lang)){if($dp.dd&&!$dp.econt)t[n].body.removechild($dp.dd);if($.$dppath=="")d(_);var b="";if($dp.econt){$dp.econt.innerhtml=b;x($dp.econt.childnodes[0],w)}else{$dp.dd=t[n].createelement("div");$dp.dd.style.csstext="position:absolute;z-index:19700";$dp.dd.innerhtml=b;t[n].body.appendchild($dp.dd);x($dp.dd.childnodes[0],w);if(a)$dp.dd.style.left=$dp.dd.style.top="-1970px";else{$dp.show();c()}}}else if($dp.cal){$dp.show();$dp.cal.init();c()}function c(){var f=$dp.position.left,b=$dp.position.top,g=u($dp.el),$=e(v),c=m(t),a=y(t),d=$dp.dd.offsetheight,_=$dp.dd.offsetwidth;if(isnan(b)){if(b=="above"||(b!="under"&&(($.topm+g.bottom+d>c.height)&&($.topm+g.top-d>0))))b=a.top+$.topm+g.top-d-3;else b=a.top+$.topm+g.bottom;b+=r?-1:1}else b+=a.top+$.topm;if(isnan(f))f=a.left+math.min($.leftm+g.left,c.width-_-5)-(r?2:0);else f+=a.left+$.leftm;$dp.dd.style.top=b+"px";$dp.dd.style.left=f+"px"}}})()