var PsCalendar={Name:"PsCalendar",Author:"Pierre Wu",Version:"1.3.12,"};function showPsCalendar(options){this.name="calendarDiv";var oThis=this;this.eventObj=null;this.isReady=false;this.closingCn="\u5173\u95ed";this.closingEn="Close";this.monthNameCn=new Array("01","02","03","04","05","06","07","08","09","10","11","12");this.monthNameEn=new Array("01","02","03","04","05","06","07","08","09","10","11","12");this.weekNameCn=new Array("\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d");this.weekNameEn=new Array("S","M","T","W","T","F","S");this.monthNumS=new Array("31","28","31","30","31","30","31","31","30","31","30","31");this.monthNumL=new Array("31","29","31","30","31","30","31","31","30","31","30","31");this.now=new Date();this.curY=this.minY=this.maxY=this.nowY=this.now.getFullYear();this.curM=this.minM=this.maxM=this.nowM=this.now.getMonth();this.curD=this.minD=this.maxD=this.nowD=this.now.getDate();this.setOptions(options?options:new Object());this.initialize()}showPsCalendar.prototype={setOptions:function(options){this.options=options;if(!this.options.language){this.options.language="cn"}if(!this.options.minDate){this.options.minDate=new Date(this.curY,this.curM,this.curD-(-1))}if(!this.options.maxDate){this.options.maxDate=new Date(this.curY-(-1),11,31)}},appendZero:function(n){return(("00"+n).substr(("00"+n).length-2))},switchLan:function(cn,en){return(this.options.language=="en"?en:cn)},setDom:function(cn,en){if(!this.isReady){var strFontFamily=this.switchLan("font-family: \"\u5b8b\u4f53\" !important;","");var minusYSpan=document.createElement("span");minusYSpan.setAttribute("id",this.name+"_MinusY");minusYSpan.appendChild(document.createTextNode("  << "));minusYSpan.oThis=this;var yearSpan=document.createElement("span");yearSpan.setAttribute("id",this.name+"_Year");yearSpan.appendChild(document.createTextNode(this.curY));yearSpan.oThis=this;var plusYSpan=document.createElement("span");plusYSpan.setAttribute("id",this.name+"_PlusY");plusYSpan.appendChild(document.createTextNode(" >>"));plusYSpan.oThis=this;var YearDivSpan=document.createElement("span");YearDivSpan.className="calfl";YearDivSpan.appendChild(minusYSpan);YearDivSpan.appendChild(yearSpan);YearDivSpan.appendChild(plusYSpan);var minusMSpan=document.createElement("span");minusMSpan.setAttribute("id",this.name+"_MinusM");minusMSpan.appendChild(document.createTextNode("< "));minusMSpan.oThis=this;var monthName=this.switchLan(this.monthNameCn,this.monthNameEn)[this.curM];var monthSpan=document.createElement("span");monthSpan.setAttribute("id",this.name+"_Month");monthSpan.appendChild(document.createTextNode(monthName));monthSpan.oThis=this;var plusMSpan=document.createElement("span");plusMSpan.setAttribute("id",this.name+"_PlusM");plusMSpan.appendChild(document.createTextNode(" >  "));plusMSpan.oThis=this;var MonthDivSpan=document.createElement("span");MonthDivSpan.className="calfr";MonthDivSpan.appendChild(plusMSpan);MonthDivSpan.appendChild(monthSpan);MonthDivSpan.appendChild(minusMSpan);var YMDiv=document.createElement("div");YMDiv.setAttribute("style","height: 22px; font: bold 12px Arial; text-align: center; padding: 4px 4px 0px 4px;");YMDiv.style.cssText="height: 22px; font: bold 12px Arial; text-align: center; padding: 4px 4px 0px 4px;";YMDiv.appendChild(YearDivSpan);YMDiv.appendChild(MonthDivSpan);var row=document.createElement("tr");for(var iWeek=0;iWeek<7;iWeek++){var weekName=(this.switchLan(this.weekNameCn,this.weekNameEn))[iWeek];var cell=document.createElement("th");cell.setAttribute("style","background: #F9C605; font: 12px Arial; text-align: center; border: 1px solid #FFCC82; color:#FFFFFF;");cell.style.cssText="background: #176ec4; font: 12px Arial; text-align: center; border: 1px solid #666666; color:#FFFFFF;";cell.appendChild(document.createTextNode(weekName));row.appendChild(cell)}var calBody=document.createElement("tbody");calBody.appendChild(row);for(var iRow=1;iRow<=6;iRow++){var rowN=document.createElement("tr");for(var iCol=1;iCol<=7;iCol++){var cellN=document.createElement("td");cellN.setAttribute("id",this.name+"_"+(7*(iRow-1)-(-iCol)));cellN.setAttribute("style","padding: 4px; width: 18px; height: 18px;");cellN.style.cssText="padding: 4px; width: 18px; height: 18px;";cellN.appendChild(document.createTextNode("&nbsp;"));rowN.appendChild(cellN)}calBody.appendChild(rowN)}var calTable=document.createElement("table");calTable.setAttribute("style","clear: both; width: 160px; margin: 0 auto; border-collapse: collapse; border: 1px solid #FFCC82;");calTable.style.cssText="clear: both; width: 160px; margin: 0 auto; border-collapse: collapse; border: 1px solid #666666;";calTable.appendChild(calBody);var ClosingDiv=document.createElement("div");ClosingDiv.setAttribute("style","margin: 0 auto; width: 50px; cursor: pointer; font: 13px Arial; text-align: center;"+strFontFamily);ClosingDiv.style.cssText="margin: 0 auto; width: 50px; cursor: pointer; font: 13px Arial; text-align: center;"+strFontFamily;var closing=this.switchLan(this.closingCn,this.closingEn);ClosingDiv.appendChild(document.createTextNode(closing));ClosingDiv.oThis=this;ClosingDiv.onmouseover=this._over;ClosingDiv.onmouseout=this._out;ClosingDiv.onclick=this._close;var calDiv00=document.createElement("div");calDiv00.innerHTML="<iframe id=\"zIndexIframe\" frameborder=\"0\"></iframe>";var calDiv=document.createElement("div");calDiv.setAttribute("id",this.name);calDiv.setAttribute("style","text-align: center; width: 180px; position: absolute; left: -300px; top: -300px; background: #000000; border: 1px solid #CACACA; display: none;");calDiv.style.cssText="text-align: center; width: 180px; position: absolute; left: -300px; top: -300px; background: #E9E9E9; border: 1px solid #CACACA; display: none;";calDiv.appendChild(YMDiv);calDiv.appendChild(calTable);calDiv.appendChild(ClosingDiv);calDiv00.appendChild(calDiv);document.body.appendChild(calDiv00);this.isReady=true}$(this.name+"_MinusY").onmouseover=this._over;$(this.name+"_MinusY").onmouseout=this._out;$(this.name+"_MinusY").onclick=this._minusYear;$(this.name+"_Year").onmouseover=this._over;$(this.name+"_Year").onmouseout=this._out;$(this.name+"_Year").onclick=this._selectYear;$(this.name+"_PlusY").onmouseover=this._over;$(this.name+"_PlusY").onmouseout=this._out;$(this.name+"_PlusY").onclick=this._plusYear;$(this.name+"_MinusM").onmouseover=this._over;$(this.name+"_MinusM").onmouseout=this._out;$(this.name+"_MinusM").onclick=this._minusMonth;$(this.name+"_Month").onmouseover=this._over;$(this.name+"_Month").onmouseout=this._out;$(this.name+"_Month").onclick=this._selectMonth;$(this.name+"_PlusM").onmouseover=this._over;$(this.name+"_PlusM").onmouseout=this._out;$(this.name+"_PlusM").onclick=this._plusMonth},initialize:function(){this.minY=this.options.minDate.getFullYear();this.minM=this.options.minDate.getMonth();this.minD=this.options.minDate.getDate();this.maxY=this.options.maxDate.getFullYear();this.maxM=this.options.maxDate.getMonth();this.maxD=this.options.maxDate.getDate()},getDateValue:function(dateNum){this.now.setFullYear(this.curY);this.now.setMonth(this.curM);this.now.setDate(1);var weekday=this.now.getDay();return""+this.curY+"-"+this.appendZero(this.curM-(-1))+"-"+this.appendZero(dateNum-weekday)},start:function(e){this.eventObj=e;var curDateArr=this.eventObj.value.split("-");var isDate=true;for(var i=0;i<curDateArr.length;i++){if(isNaN(curDateArr[i])){isDate=false;break}}if(isDate&&(curDateArr.length==3)){this.curY=this.nowY=parseInt(curDateArr[0],10);this.curM=this.nowM=parseInt(curDateArr[1],10)-1;this.curD=this.nowD=parseInt(curDateArr[2],10)}this.setDom();this.create();var pos=Position.cumulativeOffset(this.eventObj);$(this.name).style.left=pos[0]+"px";$(this.name).style.top=(pos[1]+this.eventObj.offsetHeight)+"px";this._showAll(this.name)},create:function(){$(this.name+"_Year").innerHTML=this.curY;if(this.curY<=this.minY){Element.hide($(this.name+"_MinusY"))}else{Element.show($(this.name+"_MinusY"))}if(this.curY>=this.maxY){Element.hide($(this.name+"_PlusY"))}else{Element.show($(this.name+"_PlusY"))}$(this.name+"_Year").onclick=this._selectYear;$(this.name+"_Year").className="";var monthName=this.switchLan(this.monthNameCn,this.monthNameEn)[this.curM];$(this.name+"_Month").innerHTML=monthName;if(this.curY<this.minY||(this.curY==this.minY&&this.curM<=this.minM)){Element.hide($(this.name+"_MinusM"))}else{Element.show($(this.name+"_MinusM"))}if(this.curY>this.maxY||(this.curY==this.maxY&&this.curM>=this.maxM)){Element.hide($(this.name+"_PlusM"))}else{Element.show($(this.name+"_PlusM"))}$(this.name+"_Month").onclick=this._selectMonth;$(this.name+"_Month").className="";var MonthArray=(0==this.curY%4&&(this.curY%100!=0||this.curY%400==0))?this.monthNumL:this.monthNumS;this.now.setFullYear(this.curY);this.now.setMonth(this.curM);this.now.setDate(1);var weekday=this.now.getDay();for(var iDate=1;iDate<=42;iDate++){var handleObj=$(this.name+"_"+iDate);if((iDate>=(weekday-(-1)))&&(iDate<=weekday-(-MonthArray[this.curM]))){var isIllegal=(iDate-weekday<this.minD&&this.curM==this.minM&&this.curY==this.minY)||(iDate-weekday>this.maxD&&this.curM==this.maxM&&this.curY==this.maxY)||(this.curM<this.minM&&this.curY==this.minY)||(this.curM>this.maxM&&this.curY==this.maxY)||this.curY<this.minY||this.curY>this.maxY;var isCurrent=(iDate-weekday==this.nowD)&&(this.curM==this.nowM)&&(this.curY==this.nowY);if(isIllegal){this._illegal(handleObj)}else{if(isCurrent){handleObj.style.backgroundColor="#F37021";this._current(handleObj)}else{this._normal(handleObj)}}handleObj.innerHTML=iDate-weekday;handleObj.onmouseover=isIllegal?null:this._over;handleObj.onmouseout=isIllegal?null:this._out;handleObj.onclick=isIllegal?null:this._click}else{this._illegal(handleObj);handleObj.innerHTML="&nbsp;";handleObj.onmouseover=null;handleObj.onmouseout=null;handleObj.onclick=null}handleObj.oThis=this}for(var iDate=1;iDate<=42;iDate+=7){var tRow=$(this.name+"_"+iDate).parentNode;if($(this.name+"_"+iDate).innerHTML=="&nbsp;"&&$(this.name+"_"+(iDate+6)).innerHTML=="&nbsp;"){Element.hide(tRow)}else{Element.show(tRow)}}},_normal:function(obj){obj.setAttribute("style","background: #FFF9F3; font: 12px Arial; color: #333333; text-align: center; text-decoration: none; border: 1px solid #FFCC82; cursor: pointer;");obj.style.cssText="background: #FFFFFF; font: 12px Arial; color: #000000; text-align: center; text-decoration: none; border: 1px solid #666666; cursor: pointer;"},_illegal:function(obj){obj.setAttribute("style","background: #FFF9F3; font: 12px Arial; color: #ABABAB; text-align: center; text-decoration: none; border: 1px solid #666666; cursor: default;");obj.style.cssText="background: #FFFFFF; font: 12px Arial; color: #A2A1A1; text-align: center; text-decoration: none; border: 1px solid #666666; cursor: default;"},_current:function(obj){obj.setAttribute("style","background: #F37021; font:bold 12px Arial; color: #333333; text-align: center; text-decoration: none; border: 1px solid #FFCC82; cursor: pointer;");obj.style.cssText="background: #686868; font:bold 12px Arial; color: #ffffff; text-align: center; text-decoration: none; border: 1px solid #FFCC82; cursor: pointer;"},_over:function(e){this.className="hover"},_out:function(e){this.className=""},_minusYear:function(){var oThis=this.oThis;if(!oThis){return}if(oThis.curY>oThis.minY){oThis.curY--}oThis.create()},_selectYear:function(){var oThis=this.oThis;if(!oThis){return}if($(oThis.name+"_Month").firstChild.value){oThis.create()}while(this.childNodes.length>0){this.removeChild(this.childNodes[0])}var selectYear=document.createElement("select");selectYear.oThis=oThis;selectYear.onblur=oThis._doSelectYear;selectYear.onchange=oThis._doSelectYear;for(var kYear=oThis.minY;kYear<=oThis.maxY;kYear++){option=document.createElement("option");option.appendChild(document.createTextNode(kYear));option.value=kYear;if(kYear==oThis.curY){option.selected=true}selectYear.appendChild(option)}this.appendChild(selectYear);this.onclick=null},_doSelectYear:function(){var oThis=this.oThis;if(!oThis){return}oThis.curY=this.value;oThis.create()},_plusYear:function(){var oThis=this.oThis;if(!oThis){return}if(oThis.curY<oThis.maxY){oThis.curY++}oThis.create()},_minusMonth:function(){var oThis=this.oThis;if(!oThis){return}if(oThis.curY>oThis.minY||(oThis.curY==oThis.minY&&oThis.curM>oThis.minM)){oThis.curM--;if(oThis.curM<0){oThis.curM+=12;oThis.curY--}}oThis.create()},_selectMonth:function(){var oThis=this.oThis;if(!oThis){return}if($(oThis.name+"_Year").childNodes[0].value){oThis.create()}while(this.childNodes.length>0){this.removeChild(this.childNodes[0])}var selectMonth=document.createElement("select");selectMonth.oThis=oThis;selectMonth.onblur=oThis._doSelectMonth;selectMonth.onchange=oThis._doSelectMonth;var minM=oThis.curY==oThis.minY?oThis.minM:0;var maxM=oThis.curY==oThis.maxY?oThis.maxM:11;for(var kMonth=minM;kMonth<=maxM;kMonth++){var monthName=oThis.switchLan(oThis.monthNameCn,oThis.monthNameEn)[kMonth];option=document.createElement("option");option.appendChild(document.createTextNode(monthName));option.value=kMonth;if(kMonth==oThis.curM){option.selected=true}selectMonth.appendChild(option)}this.appendChild(selectMonth);this.onclick=null},_doSelectMonth:function(){var oThis=this.oThis;if(!oThis){return}oThis.curM=this.value;oThis.create()},_plusMonth:function(){var oThis=this.oThis;if(!oThis){return}if(oThis.curY<oThis.maxY||(oThis.curY==oThis.maxY&&oThis.curM<oThis.maxM)){oThis.curM++;if(oThis.curM>11){oThis.curM-=12;oThis.curY++}}oThis.create()},_click:function(e){var oThis=this.oThis;if(!oThis){return}if(oThis.eventObj){oThis.eventObj.value=oThis.getDateValue(this.id.split("_")[1])}oThis._hideAll(oThis.name);$(oThis.name+"_Year").onclick=oThis._selectYear;$(oThis.name+"_Month").onclick=oThis._selectMonth},_close:function(){var oThis=this.oThis;if(!oThis){return}oThis._hideAll(oThis.name)},_showAll:function(id){Element.show($(id));if(window.addEventListener){document.addEventListener("click",checkForClose,true)}else{if(window.attachEvent){setTimeout(function(){document.attachEvent("onclick",checkForClose)},50);window.event.cancelBubble=true;window.event.returnValue=false}}},_hideAll:function(id){Element.hide($(id));if(window.removeEventListener){document.removeEventListener("click",checkForClose,true)}else{if(window.detachEvent){setTimeout(function(){document.detachEvent("onclick",checkForClose)},50)}}}};function checkForClose(e){var evt=e||window.event;var eThis=evt.target||evt.srcElement;while(eThis&&eThis.id!="calendarDiv"&&eThis.nodeName.toLowerCase()!="body"){eThis=eThis.parentNode}if(eThis&&eThis.id!="calendarDiv"){Element.hide($("calendarDiv"));if(window.removeEventListener){document.removeEventListener("click",checkForClose,true)}else{if(window.detachEvent){document.detachEvent("onclick",checkForClose)}}}}
