var form = document.cart_quantity;
varDelTime = new Array("Anytime of the day","Morning (10:00 AM - 1:00 PM)","Afternoon (2:00 PM - 5:30 PM)","Evening (5:00 PM - 10:00 PM)");
//okstmtcc 20160125 valentines day
//okstmtcc 20140110 valentines day
//okstmtcc 20190213 disable valentines
//okstmtcc 20210211 enable valentines to 1 slot only
//varValTime = new Array("Morning (9:00 AM - 5:30 PM)");
varValTime = new Array("Anytime of the day","Morning (10:00 AM - 1:00 PM)","Afternoon (2:00 PM - 5:30 PM)","Evening (5:00 PM - 10:00 PM)");
if (form.recipient) {
for (var i=0;i
0){
document.getElementById('btnAddToMyCart').style.pointerEvents = 'auto';
}
if(form.is_sunday_and_holiday) chkOption(form.is_sunday_and_holiday,num).value = "No";
// if(form.surcharge) chkOption(form.surcharge,num).value = "5";
if (chkOption(form.dtime,num)!=null && form.dtime){
if (chkOption(form.dtime,num).type=="select-one"){
/*
var earliest_delivery_date = new Date(2025,0,31);
var curdate = new Date(2025,0,30);
*/
var deldate = new Date(chkOption(form.year1,num).options[chkOption(form.year1,num).selectedIndex].value, chkOption(form.month1,num).options[chkOption(form.month1,num).selectedIndex].value-1, chkOption(form.day1,num).options[chkOption(form.day1,num).selectedIndex].value);
chkOption(form.dtime,num).length = 0;
//validate deldate
dayfield = chkOption(form.day1,num).options[chkOption(form.day1,num).selectedIndex].value;
monthfield = chkOption(form.month1,num).options[chkOption(form.month1,num).selectedIndex].value;
yearfield = chkOption(form.year1,num).options[chkOption(form.year1,num).selectedIndex].value;
if ((deldate.getMonth()+1!=monthfield)||(deldate.getDate()!=dayfield)||(deldate.getFullYear()!=yearfield)){
alert('Invalid Delivery Date!');
if(jQuery('#btnAddToMyCart').length>0){
document.getElementById('btnAddToMyCart').style.pointerEvents = 'none';
}
return;
}
if (earliest_delivery_date.getTime() > deldate.getTime() || dateDiff(curdate,deldate) > 30){ // small than earliest delivery date
chkOption(form.is_sunday_and_holiday,num).value = "N/A"
chkOption(form.dtime,num).options[0] = new Option("No available delivery time","");
console.log('small than earliest delivery date');
//Only check for today whether is Sun or PH
if(dateDiff(curdate,deldate)==0){
if (isHoliday(form,num,deldate)){
}
// check if sunday
else if (chkSunday(form,num)){
chkOption(form.is_sunday_and_holiday,num).value = "Yes";
}
}
smaller_than_earliest = true;
}else {
//Order time just to determine earliest deliver date & session
//Chosen delivery date will determine which session is available
//if delivery date choosen is 1 day after earliest day, all session should be available;
daydiff = Cov2Day(deldate - earliest_delivery_date);
if(daydiff > 0){
for (var i=0;i 0){
chkOption(form.dtime,num).length = 2;
chkOption(form.dtime,num).options[0] = new Option(varDelTime[1],1);
chkOption(form.dtime,num).options[1] = new Option(varDelTime[2],2);
}else{
//If is today, mean have only 1 session Afternoon
// same day with earliest delivery date; get the earliest session;
switch ('Afternoon'){
case 'Morning':
chkOption(form.dtime,num).length = 2;
chkOption(form.dtime,num).options[0] = new Option(varDelTime[1],1);
chkOption(form.dtime,num).options[1] = new Option(varDelTime[2],2);
break;
case 'Afternoon':
chkOption(form.dtime,num).length = 1;
chkOption(form.dtime,num).options[0] = new Option(varDelTime[2],2);
break;
}
}
}
//Check if is sunday or PH
if ( (isHoliday(form,num,deldate) || chkSunday(form,num)) && daydiff > 0 && !smaller_than_earliest){
chkOption(form.is_sunday_and_holiday,num).value = "Yes";
chkOption(form.dtime,num).length = 1;
chkOption(form.dtime,num).options[0] = new Option(varDelTime[1],1);
}
//okstmtcc 20160125 valentines day
//okstmtcc 20140110 valentines day
//okstmtcc 20210211 enable valentines to 1 slot only
if(chkValentinesDay(form,num) && !smaller_than_earliest){
//If bigger than today, mean have 2 sessions Morning & Afternoon
if(daydiff > 0){
chkOption(form.dtime,num).length = 1;
chkOption(form.dtime,num).options[0] = new Option(varValTime[0],0);
// chkOption(form.dtime,num).options[1] = new Option(varValTime[1],5);
}else{
//If is today, mean have only 1 session Afternoon
// same day with earliest delivery date; get the earliest session;
// alert('Afternoon');
//okstmtcc 20190213 disable valentines
//okstmtcc 20210211 enable valentines to 1 slot only
switch ('Afternoon'){
case 'Morning':case 'Afternoon':
chkOption(form.dtime,num).length = 1;
chkOption(form.dtime,num).options[0] = new Option(varValTime[0],0);
// chkOption(form.dtime,num).options[1] = new Option(varValTime[1],5);
break;
case 'Evening':
chkOption(form.dtime,num).length = 1;
chkOption(form.dtime,num).options[0] = new Option(varValTime[1],5);
break;
}
}
}
//okstmtcc 20140103 redemption (23)
var curCategory = form.categories_id.value;
var daydiff_r = 0;
var smaller_than_redemption_earliest = false;
if(curCategory=='23'){
if(redemption_earliest_delivery_date.getTime() > deldate.getTime()){
smaller_than_redemption_earliest = true;
}
daydiff_r = daydiff+1;//add 1 more day for the existing
//If bigger or equal to 2 days difference
if(daydiff_r >= 2 || daydiff_r==1){
chkOption(form.dtime,num).length = 1;
chkOption(form.dtime,num).options[0] = new Option(varValTime[0],4);
}
//Check if is sunday or PH or less than 2 days from order date
if ( (isHoliday(form,num,deldate) || chkWeekend(form,num)) || (daydiff_r < 2 && daydiff_r!=1) || smaller_than_redemption_earliest){
if(chkSunday(form,num)){ chkOption(form.is_sunday_and_holiday,num).value = "Yes"; }
chkOption(form.dtime,num).length = 1;
chkOption(form.dtime,num).options[0] = new Option("No available delivery time","");
}
}
//okstmtcc 20140407 International Order (29)
if(curCategory=='29'){
if(redemption_earliest_delivery_date.getTime() > deldate.getTime()){
smaller_than_redemption_earliest = true;
}
daydiff_r = daydiff+1;//add 1 more day for the existing
//If bigger or equal to 2 days difference
if(daydiff_r >= 2 || daydiff_r==1){
chkOption(form.dtime,num).length = 1;
chkOption(form.dtime,num).options[0] = new Option(varDelTime[0],0);
}
//Check if is sunday or PH or less than 2 days from order date
if ( (isHoliday(form,num,deldate) || chkWeekend(form,num)) || (daydiff_r < 2 && daydiff_r!=1) || smaller_than_redemption_earliest){
if(chkSunday(form,num)){ chkOption(form.is_sunday_and_holiday,num).value = "Yes"; }
chkOption(form.dtime,num).length = 1;
chkOption(form.dtime,num).options[0] = new Option("No available delivery time","");
}
}
/** Previous old code here **/
/** Previous old code here **/
}
/*
var varTime = new Array("");
chkOption(form.dtime,num).selectedIndex = 0;
if (first_time){
for (var i=0;i= begin_date && deldate <= end_date){
bln = true;
var spe_notes = arrSpecialPriceDelivery[pid][i].notes;
}
}
}
}
if (bln){
$('tr.special_attributes_row').show();
$('tr.default_attributes_row').hide();
$('.details-del-spec-notes-box').show();
$('span.inner-notes').html(spe_notes);
$('input[name="is_special_delivery"]').val('1');
}else{
$('input[name="is_special_delivery"]').val('0');
}
return bln;
}
function nl2br (str, is_xhtml) {
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '
' : '
';
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}
function gup( name ){
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null ) return "";
else return results[1];
}