
urm.Init=function(b,c,d){Sdule.Mode=1;urm.instanceName=b;urm.separator="-";urm.oBtnTodayTitle="今天";urm.oBtnCancelTitle="关闭";urm.weekDaySting=new Array("S","M","T","W","T","F","S");urm.monthSting=new Array("January","February","March","April","May","June","July","August","September","October","November","December");urm.Width=200;urm.weekDaySting=new Array("日","一","二","三","四","五","六");urm.monthSting=new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");urm.iix=new Date();urm.today=new Date();urm.startYear=1930;urm.endYear=urm.today.getFullYear()+20;urm.buttonClass="ManagerButton";urm.normalfontColor="#666666";urm.selectedfontColor="green";urm.divBorderCss="1px solid #BCD0DE";urm.titleTableBgColor="#98B8CD";urm.tableBorderColor="#CCCCCC";urm.oTaget=null;urm.oPreviousCell=null;urm.sDIVId=b+"_Div";urm.sTABLEId=b+"_Table";urm.sMONTHId=b+"_Month";urm.sYEARId=b+"_Year";urm.sHourId=b+"_Hour";urm.sMinuteId=b+"_Minute";urm.sSecondId=b+"_Second";urm.sTODAYBTNId=b+"_TODAYBTN";var e,sYear;e=urm.iix.getMonth();sYear=urm.iix.getFullYear();var f=new nzy();f.append("<div id=\""+urm.sDIVId+"\" class=\"sd-calendar\">\n");f.append("<table id=\""+urm.sTABLEId+"_Head\"  cellpadding=\"0\" cellspacing=\"0\" class=\"ui-calendar-calendar\">");f.append("<thead>");f.append("<tr class=\"week_title\">");f.append("<th >");f.append("<span title=\"周日\">周日</span></th>");f.append("<th>");f.append("<span title=\"周一\">周一</span></th>");f.append("<th>");f.append("<span title=\"周二\">周二</span></th>");f.append("<th>");f.append("<span title=\"周三\">周三</span></th>");f.append("<th>");f.append("<span title=\"周四\">周四</span></th>");f.append("<th>");f.append("<span title=\"周五\">周五</span></th>");f.append("<th >");f.append("<span title=\"周六\">周六</span></th>");f.append("</tr>");f.append("</thead>");f.append("</table>");f.append("<div class=\"cal_m_content sixweeks\" style=\"height: 515px;\">");f.append("<div class=\"table_content table_border\">");var g=new nzy();for(var i=1;i<=6;i++){g.append("<div class=\"week_line\"  index=\""+i+"\">");g.append("<table isdayList=\"1\"   index=\""+i+"\">");g.append("<tbody>");g.append("<tr index=\""+i+"\">");for(j=0;j<7;j++){g.append("<td class=\" "+(j==0||j==6?"week_1st_td weekend":"")+"\" cellId=\""+j+"\">\n");g.append("&nbsp;</td>")}
g.append("</tr>");g.append("</tbody>");g.append("</table>");g.append("</div>")}
f.append(g.toString());f.append("<div class=\"cal_bottom_line\">");f.append("<div class=\"cal_bottom_in\"></div>");f.append("</div>");f.append("</div>");f.append("</div>\n");urm.wcm=$(f.toString());c.html("");if(!ymr(c)&&c.length>0)c.append(urm.wcm);else $("body",document).html(urm.wcm);urm.$divRows=urm.wcm.children("div.sixweeks").children("div.table_content").children("div.week_line");urm.ggms=urm.$divRows.children("table");urm.wcj=urm.ggms.find("tr[index]");urm.wcj.children().unbind("click").bind("click",function(){urm.$divRows.removeClass("week_selected");$(this).addClass("week_selected")});urm.qkt(urm.iix.getFullYear(),urm.iix.getMonth());Sdule.yzm.show().find(".btn_pre").attr("title","上一月");Sdule.yzm.find(".btn_next").attr("title","下一月");Sdule.yzm.find("[ck='goMonth']").unbind("click").bind("click",function(){var a=$(this).attr("to");urm.cqe(parseInt(a,10))})}
urm.qkt=function(){var f,rowIndex,cellIndex;var g=urm.iix.getMonth();var h=urm.iix.getFullYear();var j=(new Date(h,g,1)).getDay();var k=new Date();var l=k.getDate();var m=1;var n=Sdule.owp(h,g);var o=(new Date(h,g,n)).getDay();if(j!=6)urm.$divRows.filter(":last").hide();else urm.$divRows.filter(":last").show();var p=h;var q=g-1;if(q<1){q=11;p--}
var r=Sdule.owp(p,q);var s=h;var t=g+1;if(t>=12){t=0;s++}
var u=new Date();if(j==0)u=new Date(h,g,1);else u=new Date(p,q,r-j+1);var w=new Date();if(o==6)w=new Date(h,g,n,23,59,59);else w=new Date(s,t,7-o,23,59,59);urm.CurDataKey="M"+u.getFullYear()+"_"+u.getMonth()+"_"+u.getDate()+"_"+w.getFullYear()+"_"+w.getMonth()+"_"+w.getDate();urm.CurIsOk=false;Sdule.wcx(1,u,w);var x=h+"-"+((g+1)<10?"0":"")+(g+1)+"-";for(rowIndex=1;rowIndex<=6;rowIndex++){var y=urm.wcj.filter("[index="+rowIndex+"]");if(y.length<1)continue;if(m>n){y.hide();break}
if(rowIndex==6)y.show();cellIndex=0;if(rowIndex==1)cellIndex=j;var z=false;y.children().each(function(i){var a=$(this);var v=m;var b="";var c=true;if((rowIndex==1&&i<cellIndex)){v=r-j+i+1;b=p+"-"+(q+1)+"-"+v;a.addClass("invalidateday")}else if(m>n){v=m-n;b=s+"-"+(t+1)+"-"+v;a.addClass("invalidateday");m++}else{c=false;b=h+"-"+(g+1)+"-"+v;a.removeClass("invalidateday");m++}
a.attr("date",b);z=true;var d=new nzy();d.append("<div class=\"date_box clearfix\"  title=\"请点击\">\n");d.append("<div class=\"selected_border clearfix\">\n");d.append("<div class=\"month_date "+(c?" other_month ":"")+(v==l?" date_selected today_title ":"")+" clearfix\">\n");d.append("<span class=\"month_date_num right\" >"+v+"</span>\n");d.append("</div>\n");d.append("<ul class=\"month_event\"><li class=\"addevent\" ><a href=\"javascript:void(0);\"  onclick=\"javascript:Sdule.bcp(this,'"+b+"',1);\" >\n");d.append("新建日程…</a><span class=\"event_time\"></span></li></ul>\n");d.append("</div>\n");d.append("<div class=\"month_event_more\">\n");d.append("<span class=\"arrow_b\"></span>\n");d.append("</div>\n");d.append("</div>\n");$(this).html(d.toString())});if(!z){urm.$divRows.filter("[index="+rowIndex+"]").hide()}else urm.$divRows.filter("[index="+rowIndex+"]").show()}
urm.CurIsOk=true;var A=null;urm.ggms.unbind("click").bind("click",function(e){var a=$(e.target);while(!ymr(a)&&a.length>0){if(a.attr("tagName").toLowerCase()=="td")break;else a=a.parent()}
if(a.attr("date")==""){art.VLdialog.tips("此区不是本月。",1);return false}
a.addClass("td_selected");a.children().addClass("date_selected");if(!ymr(A)&&(a.attr("date")==""||a.attr("date")!=A.attr("date"))){A.removeClass("td_selected");A.children().removeClass("date_selected")}
A=a});Sdule.yzm.find("h1").text(urm.iix.getFullYear()+"年"+(urm.iix.getMonth()+1)+"月")}
urm.cqe=function(c){var a=new Date();urm.iix.setMonth(urm.iix.getMonth()+c);urm.qkt()}
urm.hwm=function(){var a,rowIndex,cellIndex;var b=urm.iix.getMonth();var c=urm.iix.getFullYear();var d=(new Date(c,b,1)).getDay();var e=new Date();var f=e.getDate();var g=1;var h=Sdule.owp(c,b);var i=(new Date(c,b,h)).getDay();if(d!=6)urm.$divRows.filter(":last").hide();else urm.$divRows.filter(":last").show();var j=c;var k=b-1;if(k<1){k=11;j--}
var l=Sdule.owp(j,k);var m=c;var n=b+1;if(n>=12){n=0;m++}
var o=new Date();if(d==0)o=new Date(c,b,1);else o=new Date(j,k,l-d+1);var p=new Date();if(i==6)p=new Date(c,b,h,23,59,59);else p=new Date(m,n,7-i,23,59,59);return{"f":o,"l":p}};urm.gwj=function(c){var e,rowIndex,cellIndex;var f=urm.iix.getMonth();var g=urm.iix.getFullYear();var h=(new Date(g,f,1)).getDay();var j=new Date();var k=j.getDate();if(j.getFullYear()!=g||j.getMonth()!=f)k=-1;var l=1;var m=Sdule.owp(g,f);var n=new Date(g,f,m,23,59,59);var o=(new Date(g,f,m)).getDay();var p=g;var q=f-1;if(q<1){q=11;p--}
var r=Sdule.owp(p,q);var s=g;var t=f+1;if(t>=12){t=0;s++}
var u=0;var v=new Date();if(h==0)v=new Date(g,f,1);else{v=new Date(p,q,r-h+1);u=h}
var w=new Date();if(o==6)w=new Date(g,f,m,23,59,59);else w=new Date(s,t,7-o,23,59,59);var x=g+"-"+((f+1)<10?"0":"")+(f+1)+"-";var y=parseInt((m+u)/7,10)+((m+u)%7>0?1:0);var z=Sdule.DataList[c];for(var i=z.length-1;i>=0;i--){var A=z[i];A.StartTime=Dcx.Date.lvk(A.StartTime);A.EndTime=Dcx.Date.lvk(A.EndTime);var d=A.StartTime;d=new Date(d.getFullYear(),d.getMonth(),d.getDate());var B=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();var C=1;if(d.getMonth()==f&&d.getFullYear()==g)C=parseInt((d.getDate()+u)/7,10)+((d.getDate()+u)%7>0?1:0);else if(d>n)C=y;var D="<li new=\"0\" sid=\""+A.SId+"\" folder=\"0\" onclick=\"javascript:Sdule.fln("+A.SId+",null,1);\"><i class=\"ico_square\"></i><p class=\"event_msg\" style=\"color:"+Sdule.yyx(A.TypeId)+";\">"+A.Title+"</p></li>\n";var E=0;var F=d.getDay();if(d>=v){if(d.getMonth()<f){E=d.getDate()-v.getDate()}else{E=(d.getDate()+u)%7-1;if(E<0)E=6}}
if(A.RepeatType==0){var G=urm.wcj.filter("[index="+C+"]");if(G.length<1)continue;var H=G.children("[date='"+B+"']");if(H.length>0){var I=H.find("ul.month_event");if(I.length>0)I.append(D)}}else if(A.RepeatType==1){for(rowIndex=C;rowIndex<=y;rowIndex++){var G=urm.wcj.filter("[index="+rowIndex+"]");if(G.length<1)continue;cellIndex=0;if(rowIndex==C)cellIndex=E;var J=false;G.children().each(function(i){var a=$(this);if(rowIndex==C&&i<cellIndex){return true}
var b=a.find("ul.month_event");b.append(D)})}}else if(A.RepeatType==2){for(rowIndex=C;rowIndex<=y;rowIndex++){var G=urm.wcj.filter("[index="+rowIndex+"]");if(G.length<1)continue;cellIndex=0;if(rowIndex==C)cellIndex=E;var J=false;G.children().each(function(i){var a=$(this);if((rowIndex==C&&i<cellIndex)||a.attr("cellId")=="0"||a.attr("cellId")=="6"){return true}
var b=a.find("ul.month_event");b.append(D)})}}else if(A.RepeatType==4){for(rowIndex=C;rowIndex<=y;rowIndex++){var G=urm.wcj.filter("[index="+rowIndex+"]");if(G.length<1)continue;G.children("[cellId="+F+"]").each(function(i){var a=$(this);var b=a.find("ul.month_event");b.append(D)})}}else if(A.RepeatType==5){if(v.getMonth()!=f&&d.getDate()>=v.getDate()&&d.getMonth()==v.getMonth()){var H=urm.wcj.filter("[index=1]").children("[date='"+v.getFullYear()+"-"+(v.getMonth()+1)+"-"+d.getDate()+"']");if(H.length>0){var I=H.find("ul.month_event");I.append(D)}}
if(w.getMonth()!=f&&d.getDate()<=w.getDate()){var H=urm.wcj.filter("[index="+y+"]").children("[date='"+w.getFullYear()+"-"+(w.getMonth()+1)+"-"+d.getDate()+"']");var I=H.find("ul.month_event");if(H.length>0){var I=H.find("ul.month_event");I.append(D)}}
if(d.getMonth()<=f){var H=urm.wcj.filter("[index="+C+"]").children("[date='"+g+"-"+(f+1)+"-"+d.getDate()+"']");if(H.length>0){var I=H.find("ul.month_event");I.append(D)}}}else if(A.RepeatType==6){if(v.getMonth()==d.getMonth()&&d.getDate()>=v.getDate()){var H=urm.wcj.filter("[index=1]").children("[date='"+v.getFullYear()+"-"+(v.getMonth()+1)+"-"+d.getDate()+"']");if(H.length>0){var I=H.find("ul.month_event");I.append(D)}}else if(w.getMonth()==d.getMonth()&&d.getDate()<=w.getDate()){var H=urm.wcj.filter("[index="+y+"]").children("[date='"+w.getFullYear()+"-"+(w.getMonth()+1)+"-"+d.getDate()+"']");var I=H.find("ul.month_event");if(H.length>0){var I=H.find("ul.month_event");I.append(D)}}else if(d.getMonth()==f){var H=urm.wcj.filter("[index="+C+"]").children("[date='"+g+"-"+(f+1)+"-"+d.getDate()+"']");if(H.length>0){var I=H.find("ul.month_event");I.append(D)}}}}}
urm.cqe=function(c){var a=new Date();urm.iix.setMonth(urm.iix.getMonth()+c);urm.qkt()}