/*!
Epoch DHTML JavaScript Calendar - Version 2.0.2
English Edition
Primary JavaScript File
(c) 2006-2007 MeanFreePath
Free for NON-COMMERCIAL use - see website for details and updates
http://www.meanfreepath.com/javascript_calendar/index.html
!!*/
function Epoch(T,J,Q,I){var L=this;function H(){L.versionNumber="2.0.2";L.displayYearInitial=L.curDate.getFullYear();L.displayMonthInitial=L.curDate.getMonth();L.displayYear=L.displayYearInitial;L.displayMonth=L.displayMonthInitial;L.minDate=new Date(2006,0,1);L.maxDate=new Date(2012,11,31);L.startDay=0;L.showWeeks=true;L.selCurMonthOnly=true}function C(){L.daylist=new Array("S","M","T","W","T","F","S","S","M","T","W","T","F","S");L.months_sh=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");L.monthup_title="Go to the next month";L.monthdn_title="Go to the previous month";L.clearbtn_caption="Clear";L.clearbtn_title="Clears any dates selected on the calendar";L.maxrange_caption="This is the maximum range";L.closebtn_caption="Close";L.closebtn_title="Close the calendar"}function K(){L.daynames=new Array();var U=0;for(var V=L.startDay;V<L.startDay+7;V++){L.daynames[U++]=L.daylist[V]}L.monthDayCount=new Array(31,((L.curDate.getFullYear()-2000)%4?28:29),31,30,31,30,31,31,30,31,30,31)}function M(){var U,V,W;L.calendar=document.createElement("table");L.calendar.setAttribute("id",L.name+"_calendar");S(L.calendar,"calendar");L.calendar.style.display="none";addEventHandler(L.calendar,"selectstart",function(){return false});addEventHandler(L.calendar,"drag",function(){return false});U=document.createElement("tbody");V=document.createElement("tr");W=document.createElement("td");W.appendChild(F());V.appendChild(W);U.appendChild(V);V=document.createElement("tr");W=document.createElement("td");L.calendar.celltable=document.createElement("table");S(L.calendar.celltable,"cells");L.calendar.celltable.appendChild(D());L.calendar.celltable.appendChild(G());W.appendChild(L.calendar.celltable);V.appendChild(W);U.appendChild(V);V=document.createElement("tr");W=document.createElement("td");W.appendChild(E());V.appendChild(W);U.appendChild(V);L.calendar.appendChild(U);addEventHandler(L.calendar,"mouseover",P);addEventHandler(L.calendar,"mouseout",A)}function F(){var U=document.createElement("div");S(U,"mainheading");L.monthSelect=document.createElement("select");L.yearSelect=document.createElement("select");var b=document.createElement("input"),Z=document.createElement("input");var X,W;for(W=0;W<12;W++){X=document.createElement("option");X.setAttribute("value",W);if(L.displayMonth==W){X.setAttribute("selected","selected")}X.appendChild(document.createTextNode(L.months_sh[W]));L.monthSelect.appendChild(X)}var Y=L.maxDate.getFullYear(),a=L.minDate.getFullYear();for(W=a;W<=Y;W++){X=document.createElement("option");X.setAttribute("value",W);if(L.displayYear==W){X.setAttribute("selected","selected")}X.appendChild(document.createTextNode(W));L.yearSelect.appendChild(X)}Z.setAttribute("type","button");Z.setAttribute("value",">");Z.setAttribute("title",L.monthup_title);b.setAttribute("type","button");b.setAttribute("value","<");b.setAttribute("title",L.monthdn_title);L.monthSelect.owner=L.yearSelect.owner=Z.owner=b.owner=L;function V(){if(L.goToMonth(L.yearSelect.value,L.monthSelect.value)){L.displayMonth=L.monthSelect.value;L.displayYear=L.yearSelect.value}else{L.monthSelect.value=L.displayMonth;L.yearSelect.value=L.displayYear}}addEventHandler(Z,"click",function(){L.nextMonth()});addEventHandler(b,"click",function(){L.prevMonth()});addEventHandler(L.monthSelect,"change",V);addEventHandler(L.yearSelect,"change",V);U.appendChild(b);U.appendChild(L.monthSelect);U.appendChild(L.yearSelect);U.appendChild(Z);return U}function E(){var U=document.createElement("div");var V=document.createElement("input");V.setAttribute("type","button");V.setAttribute("value",L.clearbtn_caption);V.setAttribute("title",L.clearbtn_title);V.owner=L;addEventHandler(V,"click",function(){L.resetSelections(false)});U.appendChild(V);if(L.mode=="popup"){var W=document.createElement("input");W.setAttribute("type","button");W.setAttribute("value",L.closebtn_caption);W.setAttribute("title",L.closebtn_title);addEventHandler(W,"click",function(){L.hide()});S(W,"closeBtn");U.appendChild(W)}return U}function D(){L.calHeading=document.createElement("thead");S(L.calHeading,"caldayheading");var V=document.createElement("tr"),U;L.cols=new Array(false,false,false,false,false,false,false);if(L.showWeeks){U=document.createElement("th");S(U,"wkhead");V.appendChild(U)}for(var W=0;W<7;W++){U=document.createElement("th");U.appendChild(document.createTextNode(L.daynames[W]));if(L.selectMultiple){U.headObj=new CalHeading(L,U,(W+L.startDay<7?W+L.startDay:W+L.startDay-7))}V.appendChild(U)}L.calHeading.appendChild(V);return L.calHeading}function G(){L.rows=new Array(false,false,false,false,false,false);L.cells=new Array();var f=-1,Y=(L.showWeeks?48:42);var Z=new Date(L.displayYear,L.displayMonth,1);var b=new Date(L.displayYear,L.displayMonth,L.monthDayCount[L.displayMonth]);var W=new Date(Z);W.setDate(W.getDate()+(L.startDay-Z.getDay())-(L.startDay-Z.getDay()>0?7:0));L.calCells=document.createElement("tbody");var c,X;var U=0,d,V,e;for(var a=0;a<Y;a++){if(L.showWeeks){if(a%8==0){f++;V=W.getWeek(L.startDay);c=document.createElement("tr");X=document.createElement("td");if(L.selectMultiple){X.weekObj=new WeekHeading(L,X,V,f)}else{S(X,"wkhead")}X.appendChild(document.createTextNode(V));c.appendChild(X);a++}}else{if(a%7==0){f++;V=W.getWeek(L.startDay);c=document.createElement("tr")}}e=W.getDate();X=document.createElement("td");X.appendChild(document.createTextNode(e));d=new CalCell(L,X,W,f,V);L.cells[U]=d;X.cellObj=d;c.appendChild(X);L.calCells.appendChild(c);L.reDraw(U++);W.setDate(e+1)}return L.calCells}function O(U){if(L.mode=="popup"){L.calendar.style.position="absolute"}if(U){switch(L.mode){case"flat":L.tgt=U;L.tgt.appendChild(L.calendar);L.visible=true;break;case"popup":L.calendar.style.position="absolute";document.body.appendChild(L.calendar);L.setTarget(U,false);break}}else{document.body.appendChild(L.calendar);L.visible=false}}function N(){L.calendar.celltable.removeChild(L.calendar.celltable.childNodes[1])}function S(U,V){U.setAttribute("class",V);U.setAttribute("className",V)}function B(W){var U=L.cells[W];var V;idx=L.dateInArray(L.dates,U.date);if(idx>-1){V=L.dates[idx];U.date.selected=V.selected||false;U.date.type=V.type;U.date.canSelect=V.canSelect;U.setTitle(V.title);U.setURL(V.href);U.setHTML(V.cellHTML)}else{U.date.selected=false}if(U.date.getTime()<L.minDate.getTime()||U.date.getTime()>L.maxDate.getTime()){U.date.canSelect=false}U.setClass()}function P(){L.mousein=true}function A(){L.mousein=false}function R(){var U=0;L.selectedDates=new Array();for(i=0;i<L.dates.length;i++){if(L.dates[i].selected){L.selectedDates[U++]=L.dates[i]}}}L.dateInArray=function(U,V,X){X=(X!=null?X:0);for(var W=X;W<U.length;W++){if(V.getUeDay()==U[W].getUeDay()){return W}}return -1};L.setTarget=function(X,U){if(L.mode=="popup"){function W(){L.show()}function V(){if(!L.mousein){L.hide()}}function a(){L.hide()}if(L.tgt){removeEventHandler(L.tgt,"focus",W);removeEventHandler(L.tgt,"blur",V);removeEventHandler(L.tgt,"keydown",a)}L.tgt=X;var Z=L.tgt.dateObj,Y=new Array;if(Z){if(L.tgt.value.length){Y[0]=Z}L.goToMonth(Z.getFullYear(),Z.getMonth())}L.selectDates(Y,true,true,true);L.topOffset=L.tgt.offsetHeight;L.leftOffset=0;L.updatePos(L.tgt);addEventHandler(L.tgt,"focus",W);addEventHandler(L.tgt,"blur",V);addEventHandler(L.tgt,"keydown",a);if(U!==false){W()}}else{if(L.tgt){L.tgt.removeChild(L.calendar)}L.tgt=X;L.tgt.appendChild(L.calendar);L.show()}};L.nextMonth=function(){var V=L.displayMonth;var U=L.displayYear;if(L.displayMonth<11){V++}else{if(L.yearSelect.value<L.maxDate.getFullYear()){V=0;U++}}return L.goToMonth(U,V)};L.prevMonth=function(){var V=L.displayMonth;var U=L.displayYear;if(L.displayMonth>0){V--}else{V=11;U--}return L.goToMonth(U,V)};L.goToMonth=function(V,X){var W=new Date(V,X,31);var U=new Date(V,X,1);if(W>=L.minDate&&U<=L.maxDate){L.monthSelect.value=L.displayMonth=X;L.yearSelect.value=L.displayYear=V;G();N();L.calendar.celltable.appendChild(L.calCells);return true}else{alert(L.maxrange_caption);return false}};L.updatePos=function(U){if(L.mode=="popup"){L.calendar.style.top=getTop(U)+L.topOffset+"px";L.calendar.style.left=getLeft(U)+L.leftOffset+"px"}};L.show=function(){L.updatePos(L.tgt);L.calendar.style.display="block";L.visible=true};L.hide=function(){L.calendar.style.display="none";L.visible=false};L.toggle=function(){L.visible?L.hide():L.show()};L.addDates=function(V,W){var U;for(U=0;U<V.length;U++){if(L.dateInArray(L.dates,V[U])==-1){L.dates[L.dates.length]=V[U]}}R();if(W!=false){L.reDraw()}};L.removeDates=function(W,X){var U;for(var V=0;V<W.length;V++){U=L.dateInArray(L.dates,W[V]);if(U!=-1){L.dates.splice(U,1)}}R();if(X!=false){L.reDraw()}};L.selectDates=function(X,V,Z,Y){var W,U;if(Y==true){for(W=0;W<L.dates.length;W++){L.dates[W].selected=false}}for(W=0;W<X.length;W++){U=L.dateInArray(L.dates,X[W]);if(V==true){X[W].selected=true;if(U==-1){L.dates[L.dates.length]=X[W]}else{L.dates[U].selected=true}}else{if(U>-1){L.dates[U].selected=X[W].selected=false;if(L.dates[U].type=="normal"){L.dates.splice(U,1)}}}}R();if(Z!=false){L.reDraw()}};L.sendForm=function(Y,X){var V=X||"epochdates",Z,W;Z=(typeof(Y)=="string"?document.getElementById(Y):Y);if(!Z){alert("ERROR: Invalid form input");return false}for(var U=0;U<L.dates.length;U++){W=document.createElement("input");W.setAttribute("type","hidden");W.setAttribute("name",V+"["+U+"]");W.setAttribute("value",encodeURIComponent(L.dates[U].dateFormat("Y-m-d")));Z.appendChild(W)}return true};L.resetSelections=function(X){var W=new Array();var V=L.dates;for(var U=0;U<V.length;U++){if(V[U].selected){W[W.length]=V[U]}}L.selectDates(W,false,false);L.rows=new Array(false,false,false,false,false,false,false);L.cols=new Array(false,false,false,false,false,false,false);if(L.mode=="popup"){L.tgt.value="";L.hide()}X==true?L.goToMonth(L.displayYearInitial,L.displayMonthInitial):L.reDraw()};L.reDraw=function(V){L.state=1;var U=V?V+1:L.cells.length;for(var W=V||0;W<U;W++){B(W)}L.state=2};L.getCellIndex=function(U){for(var V=0;V<L.cells.length;V++){if(L.cells[V].date.getUeDay()==U.getUeDay()){return V}}return -1};L.state=0;L.name=T;L.curDate=new Date();L.mode=J;L.selectMultiple=(I==true);L.dates=new Array();L.selectedDates=new Array();L.calendar;L.calHeading;L.calCells;L.rows;L.cols;L.cells=new Array();L.monthSelect;L.yearSelect;L.mousein=false;H();C();K();M();Q=typeof(Q)=="string"?document.getElementById(Q):Q;O(Q);L.state=2;L.visible?L.show():L.hide()}function CalHeading(A,E,C){function D(){var H=A.dates;var F=A.cells;var I=new Array();A.cols[C]=!A.cols[C];for(var G=0;G<F.length;G++){if(F[G].dayOfWeek==C&&F[G].date.canSelect&&(!A.selCurMonthOnly||F[G].date.getMonth()==A.displayMonth&&F[G].date.getFullYear()==A.displayYear)){I[I.length]=F[G].date}}A.selectDates(I,A.cols[C],true)}var B=this;B.dayOfWeek=C;addEventHandler(E,"mouseup",D)}function WeekHeading(C,F,E,B){function A(){var G=C.cells;var I=C.dates;var J=new Array();C.rows[B]=!C.rows[B];for(var H=0;H<G.length;H++){if(G[H].tableRow==B&&G[H].date.canSelect&&(!C.selCurMonthOnly||G[H].date.getMonth()==C.displayMonth&&G[H].date.getFullYear()==C.displayYear)){J[J.length]=G[H].date}}C.selectDates(J,C.rows[B],true)}var D=this;D.week=E;F.setAttribute("class","wkhead");F.setAttribute("className","wkhead");addEventHandler(F,"mouseup",A)}function CalCell(C,F,I,H,B){var G=this;function A(){if(G.date.canSelect){if(C.selectMultiple==true){C.selectDates(new Array(G.date),!G.date.selected,false);G.setClass()}else{C.selectDates(new Array(G.date),true,false,true);if(C.mode=="popup"){C.tgt.value=G.date.dateFormat();C.tgt.dateObj=new Date(G.date);C.hide()}C.reDraw()}}}function E(){if(G.date.canSelect){F.setAttribute("class",G.cellClass+" hover");F.setAttribute("className",G.cellClass+" hover")}}function D(){G.setClass()}G.setClass=function(){if(G.date.canSelect!==false){if(G.date.selected){G.cellClass="cell_selected"}else{if(C.displayMonth!=G.date.getMonth()){G.cellClass="notmnth"}else{if(G.date.type=="holiday"){G.cellClass="hlday"}else{if(G.dayOfWeek>0&&G.dayOfWeek<6){G.cellClass="wkday"}else{G.cellClass="wkend"}}}}}else{G.cellClass="noselect"}if(G.date.getUeDay()==C.curDate.getUeDay()){G.cellClass=G.cellClass+" curdate"}F.setAttribute("class",G.cellClass);F.setAttribute("className",G.cellClass)};G.setURL=function(J,L){if(J){if(L=="js"){addEventHandler(G.tableCell,"mousedown",function(){window.location.href=J})}else{var K=document.createElement("a");K.setAttribute("href",J);K.appendChild(document.createTextNode(G.date.getDate()));G.tableCell.replaceChild(K,G.tableCell.firstChild)}}};G.setTitle=function(J){if(J&&J.length>0){G.title=J;G.tableCell.setAttribute("title",J)}};G.setHTML=function(K){if(K&&K.length>0){if(G.tableCell.childNodes[1]){G.tableCell.childNodes[1].innerHTML=K}else{var J=document.createElement("div");J.innerHTML=K;G.tableCell.appendChild(J)}}};G.cellClass;G.tableRow=H;G.tableCell=F;G.date=new Date(I);G.date.canSelect=true;G.date.type="normal";G.date.selected=false;G.date.cellHTML="";G.dayOfWeek=G.date.getDay();G.week=B;addEventHandler(F,"click",A);addEventHandler(F,"mouseover",E);addEventHandler(F,"mouseout",D);G.setClass()}Date.prototype.getDayOfYear=function(){return parseInt((this.getTime()-new Date(this.getFullYear(),0,1).getTime())/86400000+1)};Date.prototype.getWeek=function(D){D=typeof(D)=="int"?D:0;var C=new Date(this.getFullYear(),0,1);var A=C.getDay()-D;A=(A>=0?A:A+7);var E,B=Math.floor((this.getTime()-C.getTime()-(this.getTimezoneOffset()-C.getTimezoneOffset())*60000)/86400000)+1;if(A<4){E=Math.floor((B+A-1)/7)+1;if(E>52){nYear=new Date(this.getFullYear()+1,0,1);nday=nYear.getDay()-D;nday=nday>=0?nday:nday+7;E=nday<4?1:53}}else{E=Math.floor((B+A-1)/7)}return E};Date.prototype.getUeDay=function(){return parseInt(Math.floor((this.getTime()-this.getTimezoneOffset()*60000)/86400000))};Date.prototype.dateFormat=function(L){if(!L){L="m/d/Y"}LZ=function(E){return(E<0||E>9?"":"0")+E};var D=new Array("January","February","March","April","May","June","July","August","September","October","November","December","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");var F=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sun","Mon","Tue","Wed","Thu","Fri","Sat");var Q="";var C=0;var J="";var B="";var K=this.getFullYear().toString();var I=this.getMonth()+1;var G=this.getDate();var P=this.getDay();var N=this.getHours();var A=this.getMinutes();var O=this.getSeconds();value={Y:K.toString(),y:K.substring(2),n:I,m:LZ(I),F:D[I-1],M:D[I+11],j:G,d:LZ(G),D:F[P+7],l:F[P],G:N,H:LZ(N)};if(N==0){value.g=12}else{if(N>12){value.g=N-12}else{value.g=N}}value.h=LZ(value.g);if(N>11){value.a="pm";value.A="PM"}else{value.a="am";value.A="AM"}value.i=LZ(A);value.s=LZ(O);while(C<L.length){J=L.charAt(C);B="";while((L.charAt(C)==J)&&(C<L.length)){B+=L.charAt(C++)}if(value[B]!=null){Q=Q+value[B]}else{Q=Q+B}}return Q};function addEventHandler(A,B,C){if(A.addEventListener){A.addEventListener(B,C,false)}else{if(A.attachEvent){A.attachEvent("on"+B,C)}}}function removeEventHandler(A,B,C){if(A.removeEventListener){A.removeEventListener(B,C,false)}else{if(A.attachEvent){A.detachEvent("on"+B,C)}}}function getTop(A){var C=A;var B=0;while(C.tagName!="HTML"){B+=C.offsetTop||0;if(C.offsetParent){C=C.offsetParent}else{break}}return B}function getLeft(A){var C=A;var B=0;while(C.tagName!="HTML"){B+=C.offsetLeft||0;if(C.offsetParent){C=C.offsetParent}else{break}}return B};
