var BWDP_ClickDisableDates = "02-14-2019 07-04-2018 11-22-2018 12-25-2018 01-01-2019"; var BWDP_CalDivID = "calendar-presentation-div"; var BWDP_DateContainerID = "calendar-date-value"; var BWDP_DateFormatTemplate = "~WS~, ~MS~ ~D~, ~Y~"; var BWDP_PreviousMonthSymbol = "<"; var BWDP_PreviousYearSymbol = ""; var BWDP_NextMonthSymbol = ">"; var BWDP_NextYearSymbol = ""; var BWDP_MonthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December"); var BWDP_WeekdayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); var BWDP_Holidays = BWDP_ClickDisableDates.split(" "); var BWDP_DisableToday = 1; if( 0 ) { BWDP_DisableToday = 1; } var BWDP_DisableTomorrow = 0; var BWDP_NowDay = 25; var BWDP_NowMonth = 1; var BWDP_NowYear = 2018; var BWDP_TomDay = 26; var BWDP_TomMonth = 1; var BWDP_TomYear = 2018; var BWDP_MaximumMonth = 99; var BWDP_MaximumYear = 99999; var BWDP_SelectedMonth = 0; var BWDP_SelectedDay = 0; var BWDP_SelectedYear = 0; var BWDP_WeekdaySuppression = new Array(String("0")); var BWDP_WeekdayDateEnable = new Array(String("0-0-2000")); var BWDP_SelectedDateHolder = "bwdp-calendar-date-is-for-time-list"; var BWDP_CalDivID_InitialContent = document.getElementById(BWDP_CalDivID).innerHTML; // An empty div to hold selected date for transfer to time pick list generator. document.write(''); function BWDP_NumDaysInMonth(month,year) { if( month == 1 ) { return (new Date("Feb 29, "+year).getMonth()===1) ? 29 : 28; } if( month == 3 || month == 5 || month == 8 || month == 10 ) { return 30; } return 31; } // function BWDP_NumDaysInMonth() function BWDP_MakeMonthCalendar(thismonth,thisyear) { var start = new Date(BWDP_MonthNames[thismonth]+" 1, "+thisyear); var maxrownum = 6; var calarray = new Array(); for( var i=0; i<=maxrownum; i++ ) { calarray[i] = new Array(); } calarray[0][0] = "Sun"; calarray[0][1] = "Mon"; calarray[0][2] = "Tue"; calarray[0][3] = "Wed"; calarray[0][4] = "Thu"; calarray[0][5] = "Fri"; calarray[0][6] = "Sat"; var limit = start.getDay(); for( var i=0; i<=limit; i++ ) { calarray[1][i] = ' '; } var lastday = BWDP_NumDaysInMonth(start.getMonth(),start.getFullYear()); var nowrownum = 1; var indice = limit; for( var i=1; i<=lastday; i++ ) { calarray[nowrownum][indice] = i; indice++; if( indice > 6 && i < lastday ) { indice = 0; nowrownum++; } } for( var i=indice; i<=6; i++) { calarray[nowrownum][i] = ''; } var cal = new String; var monthnumber = start.getMonth(); var yearnumber = start.getFullYear(); cal += ""; cal += ''; var i = 0; cal += ''; for( var ii=0; ii<=6; ii++ ) { cal += ''; } cal += ''; for( var i=1; i<=nowrownum; i++ ) { cal += ''; for( var ii=0; ii<=6; ii++ ) { cal += ''; } cal += ''; } cal += '
'; cal += ''; cal += ''; cal += ''; if( yearnumber >= BWDP_MaximumYear && monthnumber >= BWDP_MaximumMonth ) { cal += ''; } else { cal += ''; } cal += '
'+BWDP_PreviousYearSymbol+' '+BWDP_PreviousMonthSymbol+''+BWDP_MonthNames[monthnumber]+' '+yearnumber+'
'+BWDP_NextMonthSymbol+' '+BWDP_NextYearSymbol+'
'; cal += '
'+calarray[i][ii]+'
'; if(parseInt(calarray[i][ii])>0) { if( BWDP_IsTodayPreviousDayOrHoliday(yearnumber,monthnumber,calarray[i][ii],ii) ) { cal += ''+calarray[i][ii]+''; } else { cal += ''+calarray[i][ii]+''; } } else { cal += ' '; } cal += '
'; return cal; } // function BWDP_MakeMonthCalendar() function BWDP_IsTodayPreviousDayOrHoliday(y,m,d,w) { if(y 2 ) { if(y==chunk[2] && m==chunk[0] && d==chunk[1]) { return true; } } else { if(m==chunk[0] && d==chunk[1]) { return true; } } } return false; } // function BWDP_IsTodayPreviousDayOrHoliday function BWDP_PublishCalendar(id,month,year) { document.getElementById(id).innerHTML = BWDP_MakeMonthCalendar(month,year) + BWDP_CalDivID_InitialContent; } function BWDP_getPrevMonth(month,year) { month--; if( month < 0 ) { month = 11; year--; } BWDP_PublishCalendar(BWDP_CalDivID,month,year); } // function BWDP_getPrevMonth() function BWDP_getPrevYear(month,year) { year--; BWDP_PublishCalendar(BWDP_CalDivID,month,year); } // function BWDP_getPrevYear() function BWDP_getNextMonth(month,year) { if( year >= BWDP_MaximumYear && month >= BWDP_MaximumMonth ) { return; } month++; if( month > 11 ) { month = 0; year++; } BWDP_PublishCalendar(BWDP_CalDivID,month,year); } // function BWDP_getNextMonth() function BWDP_getNextYear(month,year) { if( year >= BWDP_MaximumYear && month >= BWDP_MaximumMonth ) { return; } year++; BWDP_PublishCalendar(BWDP_CalDivID,month,year); } // function BWDP_getNextYear() function CloseCalendar() { document.getElementById(BWDP_CalDivID).style.display = "none"; } function BWDP_DateSelected(day,month,year) { BWDP_SelectedMonth = month; BWDP_SelectedYear = year; BWDP_SelectedDay = day; BWDP_SelectedMonth++; BWDP_SelectedMonth = String(BWDP_SelectedMonth); BWDP_SelectedYear = String(BWDP_SelectedYear); BWDP_SelectedDay = String(BWDP_SelectedDay); if( BWDP_SelectedDay.length < 2 ) { BWDP_SelectedDay = String(String("0")+String(BWDP_SelectedDay)); } if( BWDP_SelectedMonth.length < 2 ) { BWDP_SelectedMonth = String(String("0")+String(BWDP_SelectedMonth)); } while( BWDP_SelectedYear.length < 4 ) { BWDP_SelectedYear = String(String("0")+String(BWDP_SelectedYear)); } var fieldval = BWDP_DateFormatTemplate.replace("~Y~",year); fieldval = fieldval.replace("~M~",(month+1)); fieldval = fieldval.replace("~MS~",BWDP_MonthNames[month]); fieldval = fieldval.replace("~D~",day); fieldval = fieldval.replace("~WS~",BWDP_WeekdayNames[(new Date(BWDP_MonthNames[month]+" "+day+", "+year).getDay())]); document.getElementById(BWDP_DateContainerID).value = fieldval; CloseCalendar(); //document.getElementById(BWDP_CalDivID).style.display = "none"; var dateholder = String(BWDP_SelectedYear + "-" + BWDP_SelectedMonth + "-" + BWDP_SelectedDay); document.getElementById(BWDP_SelectedDateHolder).innerHTML = dateholder; dateholder += "," + fieldval; if( dateholder.length ) { BWDP_RememberDateSelection("date:" + dateholder); } if( typeof(BWTP_MakeDeliveryTimeList) == 'function' ) { BWTP_MakeDeliveryTimeList(); } } // function BWDP_DateSelected() function BWDP_RememberDateSelection(datecookie) { var cookiecontent = new String(); if(document.cookie.length > 0) { var cookiebegin = document.cookie.indexOf("DateTimePicked="); var cookieend = 0; if(cookiebegin > -1) { cookiebegin += "DateTimePicked=".length; cookieend = document.cookie.indexOf(";",cookiebegin); if(cookieend < cookiebegin) { cookieend = document.cookie.length; } cookiecontent = document.cookie.substring(cookiebegin,cookieend); } } var deliverytimecookie = new String("deltime:"); var servingtimecookie = new String("sertime:"); if(cookiecontent) { cookiecontent = cookiecontent.replace(/_/g,"\t"); var ta = cookiecontent.split(/\t/,3); if( ta[0].indexOf('deltime:') == 0 ) { deliverytimecookie = ta[0]; } else if( ta[0].indexOf('sertime:') == 0 ) { servingtimecookie = ta[0]; } if( ta.length > 1 ) { if( ta[1].indexOf('deltime:') == 0 ) { deliverytimecookie = ta[1]; } else if( ta[1].indexOf('sertime:') == 0 ) { servingtimecookie = ta[1]; } } if( ta.length > 2 ) { if( ta[2].indexOf('deltime:') == 0 ) { deliverytimecookie = ta[2]; } else if( ta[2].indexOf('sertime:') == 0 ) { servingtimecookie = ta[2]; } } } var cookieval = datecookie + "\t" + deliverytimecookie + "\t" + servingtimecookie; document.cookie = "DateTimePicked=" + cookieval + '; path=/'; } // function BWDP_RememberDateSelection() function BWDP_PublishCurrentCalendar() { today = new Date(); start = new Date(BWDP_MonthNames[today.getMonth()]+', 1 '+today.getFullYear()); BWDP_PublishCalendar(BWDP_CalDivID,start.getMonth(),start.getFullYear()); document.getElementById(BWDP_CalDivID).style.display = "table"; if( typeof(BWTP_MakeDeliveryTimeList) == 'function' ) { BWTP_MakeDeliveryTimeList(); } } // function BWDP_PublishCurrentCalendar() function BWDP_PreFillDates() { var innerdate = new String(); var viewdate = new String(); var cookiecontent = new String(); if(document.cookie.length > 0) { var cookiebegin = document.cookie.indexOf("DateTimePicked="); var cookieend = 0; if(cookiebegin > -1) { cookiebegin += "DateTimePicked=".length; cookieend = document.cookie.indexOf(";",cookiebegin); if(cookieend < cookiebegin) { cookieend = document.cookie.length; } cookiecontent = document.cookie.substring(cookiebegin,cookieend); } } var date = new String(); if(cookiecontent) { cookiecontent = cookiecontent.replace(/_/g,"\t"); var ta = cookiecontent.split(/\t/,3); if( ta[0].indexOf('date:') == 0 ) { date = ta[0]; } else if( ta.length > 1 && ta[1].indexOf('date:') == 0) { date = ta[1]; } else if( ta.length > 1 && ta[2].indexOf('date:') == 0) { date = ta[2]; } } if( date.length ) { date = date.substr(5); var ta = date.split(/,/); innerdate = ta.shift(); viewdate = ta.join(","); } document.getElementById(BWDP_DateContainerID).value = viewdate; document.getElementById(BWDP_SelectedDateHolder).innerHTML = innerdate; } // function BWDP_PreFillDates() function BWDP_AppendOnloadEvent(f) { var cache = window.onload; if(typeof window.onload != 'function') { window.onload = f; } else { window.onload = function() { if (cache) { cache(); } f(); }; } } // function BWDP_AppendOnloadEvent() BWDP_PreFillDates(); //BWDP_AppendOnloadEvent(BWDP_PreFillDates);