function selectedSat(){
d = FORM.elements["AttributeValue[2]"].value;
if (d.substr(0,3)=='Sat') {
	FORM.elements["AttributeValue[3]"].value=d;
	FORM.elements["AttributeValue[4]"].value="";
	}
else {
	FORM.elements["AttributeValue[3]"].value="";
	FORM.elements["AttributeValue[4]"].value=d;
}
}
function isHoliday (testDate){
var dy;
var mo;
dy = testDate.getDate();
mo = testDate.getMonth() + 1;
yr = testDate.getYear();
if (mo==1 && dy==1) {return true;}
if (mo==1 && dy==2) {return true;}
if (mo==1 && dy==3) {return true;}
if (mo==3 && dy==22) {return true;}
if (mo==3 && dy==29) {return true;}
if (mo==4 && dy==5) {return true;}
if (mo==4 && dy==12) {return true;}
if (mo==4 && dy==19) {return true;}
if (mo==4 && dy==26) {return true;}
// vacation
if (mo==6){if (dy > 4 && dy < 26) {return true;}}
// 4th of July
if (mo==7){if (dy > 4 && dy < 13) {return true;}}
if (mo==7 && dy > 28) {return true;}
//Thanksgiving
if (mo==11 && dy > 25) {return true;}
//Christmas
if (mo==12 && dy==1) {return true;}
//Feb 13 2010 is good for delivery
if (mo==2 && dy==13 && yr==2010) {return false;}
// No more Saturdays deliveries after 1/16/2010
if (testDate.getDay() == 6) {return true;}
if (mo==12){if (dy>22 && dy < 29) {return true;}}
//Feb 13 2010 is good for delivery
// Don't worry about Labor Day or Memorial Day - they are on Mondays
// Add any days that they cannot deliver to this list
return false;
}
function filldatelist(){
d_shift = new Array (2,2,2,2,2,3,2);
m_array = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
day_array = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
d=new Date();
d1=new Date();
d3=new Date();
// Add +1 to give us a buffer around Christmas
mo = d.getMonth()+1;
d1.setDate(d.getDate()+d_shift[d.getDay()]);
d3.setDate(d.getDate()+61);
s=-1;
indx=0;
// add each valid delivery date to the options list
while (d1 < d3) {
	if (isHoliday(d1) == false)
	{
		if (d1.getDay() >= 2 && d1.getDay() <= 5) {
			var oOption = document.createElement("OPTION")
			oOption.text = day_array[d1.getDay()]+' '+m_array[d1.getMonth()]+' '+d1.getDate();
			oOption.value = day_array[d1.getDay()]+m_array[d1.getMonth()]+d1.getDate();
			FORM.elements["AttributeValue[2]"].add(oOption);
			// Set the first regular day as the selected delivery day
			if (s==-1){
				s=indx;
				FORM.elements["AttributeValue[2]"].selectedIndex=s;
				FORM.elements["AttributeValue[3]"].value="";
				FORM.elements["AttributeValue[4]"].value=oOption.value;
				}
			indx = indx+1;
		}
		if (d1.getDay() == 6) {
			var oOption = document.createElement("OPTION")
			oOption.text = day_array[d1.getDay()]+' '+m_array[d1.getMonth()]+' '+d1.getDate() + ' ($15 surcharge)';
			oOption.value = day_array[d1.getDay()]+m_array[d1.getMonth()]+d1.getDate();
			FORM.elements["AttributeValue[2]"].add(oOption);
			indx = indx+1;
		}
	}
	d1.setDate(d1.getDate()+1);
}
}

function shipdeliveryday() {
t_name = new Array ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
s_name = new Array ('Monday','Tuesday','Wednesday','Thursday','Monday','Monday','Monday');
d_name = new Array ('Tuesday','Wednesday','Thursday','Friday','Tuesday','Tuesday','Tuesday');
//d_shift = new Array (2,2,2,2,4,3,2);
m_array = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
d = new Date();

document.write('<table border=2><tr><td> ');
document.write('<font color="cc3300"><b>Your cheesecake can be delivered on '+d_name[d.getDay()]+'</b> if you order by midnight ET ');
document.write('tonight ('+t_name[d.getDay()]+'). It will ship on '+s_name[d.getDay()]+' and be delivered on '+d_name[d.getDay()]+'. </font>');
if (d.getDay()==4) {
//document.write('Instead of waiting until '+d_name[d.getDay()]+', you can get your cheesecake shipped on Friday and delivered on Saturday delivery for a $15 surcharge. ');
document.write('To do this, use the "Delivery Date" list and select the appropriate date.');
}
//document.write('<br><br>Or, you can pick your delivery date within the next 60 days from the list in "Delivery Date" (note that there is a $15 surcharge for Saturday delivery).');
document.write('<br><br>Or, you can pick your delivery date within the next 60 days from the list in "Delivery Date".');
document.write('<br><br><font color="cc3300"><b>Cheesecakes can be shipped only within the continental United States and we are unable to ship to PO Boxes, APO boxes or internationally.</b></font>');
//document.write('<br><br><font color="cc3300"><b>Please note that FedEx is not guaranteeing any deliveries between Dec 18th and Dec 23rd, so select an earlier delivery date to ensure timely delivery.</b></font>');
document.write('<br><br><a href="merchant.mv?Screen=CTGY&Category_Code=000742cheesecake">More about our cheesecake</a><br>');
document.write('</font><br>');
document.write('</td></tr></table>');
if (document.FORM != null) {
	FORM.elements["AttributeValue[1]"].rows = '4';
	FORM.elements["AttributeValue[1]"].cols = '30';
	FORM.elements["AttributeValue[3]"].style.visibility="hidden";
	FORM.elements["AttributeValue[4]"].style.visibility="hidden";
	FORM.elements["AttributeValue[2]"].attachEvent('onchange',selectedSat);
	x = document.getElementById("r003");
	x.style.display='none';
	x = document.getElementById("r004");
	x.style.display='none';
	filldatelist();
}
}