/* Copyright 2015 Epic Systems Corporation. */

/*! Copyright � 2004-2011 Epic Systems Corporation	*/
function getMonthName(b){var a=['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];return a[b-1]}function getMonthAbbr(b){var a=['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];return a[b-1]}function getDayName(b){var a=['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];return a[b]}function getDayAbbr(b){var a=['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];return a[b]}function getDayLetter(b){var a=['S', 'M', 'T', 'W', 'T', 'F', 'S'];return a[b]}function getFirstDayOfWeek(){return 0}function getHour12(a){return a%12===0?12:a%12}function getAMPM(b){var a=['AM', 'PM'];return b<12?a[0]:a[1]}function getAMPMAbbr(b){var a=['A','P'];return b<12?a[0]:a[1]}function makeInstant(a,f,c,g,d,e){var b=new Date;if(!a)a=b.getFullYear();else{a=Number(a);if(a<30)a+=2e3}if(!f&&f!==0){f=b.getMonth()+1;if(!c)c=b.getDate()}else if(!c)c=1;if(!g&&g!==0)g=b.getHours();if(!d&&d!==0)d=b.getMinutes();if(!e&&e!==0)e=b.getSeconds();return new Date(a,Number(f)-1,c,g,d,e)}function makeDate(b,a,c){return makeInstant(b,a,c,0,0,0)}function makeTime(c,a,b){return makeInstant(null,null,null,c,a,b)}function buildFormat(d){var c="";d=d.replace(/(\\.|(.)\2*)/g,"$1\n");for(var a=d.split(/\n/),e,b=0;b<a.length;b++)if(a[b].match(/^y+$/))switch(a[b].length){case 2:a[b]=function(a){return(a.getFullYear()%100).toString()};break;case 4:a[b]=function(a){return a.getFullYear().toString()};break;default:a[b]=function(){return c}}else if(a[b].match(/^M+$/))switch(a[b].length){case 1:a[b]=function(a){return(a.getMonth()+1).toString()};break;case 2:a[b]=function(a){return padNumber(a.getMonth()+1,2)};break;case 3:a[b]=function(a){return getMonthAbbr(a.getMonth()+1)};break;case 4:a[b]=function(a){return getMonthName(a.getMonth()+1)};break;default:a[b]=function(){return c}}else if(a[b].match(/^d+$/))switch(a[b].length){case 1:a[b]=function(a){return a.getDate().toString()};break;case 2:a[b]=function(a){return padNumber(a.getDate(),2)};break;case 3:a[b]=function(a){return getDayAbbr(a.getDay())};break;case 4:a[b]=function(a){return getDayName(a.getDay())};break;default:a[b]=function(){return c}}else if(a[b].match(/^h+$/))switch(a[b].length){case 1:a[b]=function(a){return getHour12(a.getHours()).toString()};break;case 2:a[b]=function(a){return padNumber(getHour12(a.getHours()),2)};break;default:a[b]=function(){return c}}else if(a[b].match(/^H+$/))switch(a[b].length){case 1:a[b]=function(a){return a.getHours().toString()};break;case 2:a[b]=function(a){return padNumber2(a.getHours(),2)};break;default:a[b]=function(){return c}}else if(a[b].match(/^m+$/))switch(a[b].length){case 1:a[b]=function(a){return a.getMinutes().toString()};break;case 2:a[b]=function(a){return padNumber2(a.getMinutes(),2)};break;default:a[b]=function(){return c}}else if(a[b].match(/^s+$/))switch(a[b].length){case 1:a[b]=function(a){return a.getSeconds().toString()};break;case 2:a[b]=function(a){return padNumber2(a.getSeconds(),2)};break;default:a[b]=function(){return c}}else if(a[b].match(/^t+$/))switch(a[b].length){case 1:a[b]=function(a){return getAMPMAbbr(a.getHours())};break;case 2:a[b]=function(a){return getAMPM(a.getHours())};break;default:a[b]=function(){return c}}else a[b]=a[b].replace(/(\\)(?!\\)/,c);return function(e){var d=c,b;if(!e)return"\\";else{for(b=0;b<a.length;b++)if(typeof a[b]==="function")d+=a[b](e);else d+=a[b];return d}}}var formatDate=buildFormat("M/d/yyyy"),formatTime=buildFormat("h:mm tt"),parseDate=buildDateParser("M/d/yyyy"),formatHour=buildFormat("h:mm tt".replace(/[^hH]/g,"")),formatMinute=buildFormat("h:mm tt".replace(/[^m]/g,""));function dateInputError(e,d,c,b){var a={};a["@MYCHART@DATEFORMAT@"]="mm/dd/yyyy";a["@MYCHART@ENTEREDDATE@"]=d;if(c)a["@MYCHART@MINDATE@"]=formatDate(c);if(b)a["@MYCHART@MAXDATE@"]=formatDate(b);WP.Validators.DisplayErrors(decodeMnemonics(e,a))}function formatDateField(a,j,i,h){var d=false,g=true;if(!a||!a.value)a=WP.Events.getThis();if(!a||!a.value)return;if(a.holdErrors===g){window.setTimeout(function(){formatDateField(a,j,i,h)},100);return}else if(a.openingCalendar===g){a.openingCalendar=d;return}var f=g;if(a.value.match(/^\s*$/))return g;var c=parseDate(a.value),e,b=new Date;b.setHours(0);b.setMinutes(0);b.setSeconds(0);b.setMilliseconds(0);if(!c)return;else e=formatDate(c);switch(j){case 1:if(c>=b){dateInputError("@MYCHART@ENTEREDDATE@ is not valid.\nThe date must be in the past.",e);f=d}break;case 2:if(c<=b){dateInputError("@MYCHART@ENTEREDDATE@ is not valid.\nThe date must be in the future.",e);f=d}break;case 3:if(c<b){dateInputError("@MYCHART@ENTEREDDATE@ is not valid.\nThe date must be today or in the future.",e);f=d}break;case 4:if(c>b){dateInputError("@MYCHART@ENTEREDDATE@ is not valid.\nThe date must be today or in the past.",e);f=d}break;case 5:if(c<i||c>h){dateInputError("@MYCHART@ENTEREDDATE@ is not valid.\nThe date must be between @MYCHART@MINDATE@ and @MYCHART@MAXDATE@.",e,i,h);f=d}break;default:f=d}if(f===g)a.value=e;return g}function buildDateParser(a){var b;a=a.replace(/[^yMd]*([yMd])+[^yMd]*/g,"$1");switch(a.indexOf("y")){case 0:b=/^\s*(?:(?:((?:\d{2})?\d{2})\D)?(\d{1,2})\D(\d{1,2})|(?:((?:\d{2})?\d{2}))?(\d{2})(\d{2}))\s*$/;break;case 1:b=/^\s*(?:(\d{1,2})\D(?:((?:\d{2})?\d{2})\D)?(\d{1,2})|(\d{2})(?:((?:\d{2})?\d{2}))?(\d{2}))\s*$/;break;case 2:b=/^\s*(?:(\d{1,2})\D(\d{1,2})(?:\D((?:\d{2})?\d{2}))?|(\d{2})(\d{2})(?:((?:\d{2})?\d{2}))?)\s*$/}return function(b,a){return function(g,i){var f="@MYCHART@ENTEREDDATE@ is not valid.\nPlease reenter the date in @MYCHART@DATEFORMAT@ format.",c=true,j,k,e,h;if(g.length<6){i!==c&&dateInputError(f,g);return}var d=g.match(b);if(!d){i!==c&&dateInputError(f,g);return}if(d[1]){k=d[a.indexOf("y")+1];e=d[a.indexOf("M")+1];h=d[a.indexOf("d")+1]}else{k=d[a.indexOf("y")+4];e=d[a.indexOf("M")+4];h=d[a.indexOf("d")+4]}j=makeDate(k,e,h);e=parseInt(e,10);h=parseInt(h,10);if(e<1||e>12)i!==c&&dateInputError("@MYCHART@ENTEREDDATE@ is not valid.\nThe month must be between 1 and 12.",g);else if(j.getDate()!==h)i!==c&&dateInputError("@MYCHART@ENTEREDDATE@ is not valid.\nThe day is not valid for this month.",g);else return j}}(b,a)}