
var LastHourForDeliveriesNextDay=14;	// 24 hr clock (only hours 0-23)

// max 28 days pre-order or maxdays needs to be recalculated
var NumPrintedDates=28;		

// put dates that PO cant deleiver in here - Not Sunday - but Bank Hols v2003.1
NoDeliveryDays = new Array(
1,1,2009,
10,4,2009,
13,4,2009,
4,5,2009,
25,5,2009,
31,8,2009,
25,12,2009,
28,12,2009,
3,1,2010,
2,4,2010,
5,4,2010,
3,5,2010,
31,5,2010,
30,8,2010,
25,12,2010,
26,12,2010,
27,12,2010,
28,12,2010,
3,1,2011,
22,4,2011,
25,4,2011,
2,5,2011,
30,5,2011,
29,8,2011,
25,12,2011,
26,12,2011,
27,12,2011
);
var NumberNoDeliveryDays=NoDeliveryDays.length/3;
	// GTS assded +1 for next working day delivery
today = new Date();
thismonth = today.getMonth()+1;
thisyear = today.getFullYear();
thisday = today.getDate();
thisweekday=today.getDay();
thishour = today.getHours();
var thisactualweekday=0;

montharray=new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
Txday = new Array("Sun", "Mon", "Tue", "Wed", "Thurs", "Fri", "Sat");
Txmonth = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul" ,"Aug", "Sep", "Oct", "Nov" ,"Dec");
Txdatexx= new Array("xx","st","nd","rd","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","st","nd","rd","th","th","th","th","th","th","th","st");

maxdays=montharray[thismonth-1];

if (thismonth==2)
{
if ((thisyear/4)!=parseInt(thisyear/4)) maxdays=28;
else maxdays=29;
}

thisactualweekday=thisweekday;

// is it sunday
if (thisweekday==0) 
	{
	thisday++;
	thisweekday++;
	if (thisweekday==7) thisweekday=0;
	
		if (thisday>maxdays)
		{
		thisday=1;
		thismonth++;
		if (thismonth==13)
			{
			thismonth=1;
			thisyear++;
			}
		}
	}


// add a day to today for next day delivery
	thisday++;
	thisweekday++;
	if (thisweekday==7) thisweekday=0;
	
		if (thisday>maxdays)
		{
		thisday=1;
		thismonth++;
		if (thismonth==13)
			{
			thismonth=1;
			thisyear++;
			}
		}
// is it sunday
if (thisweekday==0) 
	{
	thisday++;
	thisweekday++;
	if (thisweekday==7) thisweekday=0;
	
		if (thisday>maxdays)
		{
		thisday=1;
		thismonth++;
		if (thismonth==13)
			{
			thismonth=1;
			thisyear++;
			}
		}
	}


// check hour for last chance of deliveries next day
// if past this hour then its the day after next for delivery (unless is sunday afternoon now!)
if ((thishour>=LastHourForDeliveriesNextDay)&&(thisactualweekday!=0)) 
{
thisday++;
thisweekday++;
if (thisweekday==7) thisweekday=0;
if (thisday>maxdays)
{
thisday=1;
thismonth++;
if (thismonth==13)
{
thismonth=1;
thisyear++;
}
}
}

if (thisweekday==0) 
{
thisday++;
thisweekday++;
if (thisweekday==7) thisweekday=0;
if (thisday>maxdays)
{
thisday=1;
thismonth++;
if (thismonth==13)
{
thismonth=1;
thisyear++;
}
}
}
var Browser;
Browser=navigator.appName;
document.write("<font class='deld'>Other gifts will be on  ");
var PrintedDate =0;
// GTS assded +1 for next working day delivery - WRONG!
var theday=thisday;
var themonth=thismonth;
var theyear=thisyear;
var theweekday=thisweekday;
while(PrintedDate==0)
{
var miss=0;
for (var c=0;c<NumberNoDeliveryDays;c++)
{
if ((NoDeliveryDays[(c*3)+0]==theday) && (NoDeliveryDays[(c*3)+1]==themonth) && (NoDeliveryDays[(c*3)+2]==theyear))
miss=1;
}

if ((theweekday!=0)&&(miss==0))
{		
document.write(Txday[theweekday] + " " + theday);
document.write(Txdatexx[theday] + " " + Txmonth[themonth-1] + " " + theyear);
PrintedDate=1;
}
theday++;
theweekday++;
if (theweekday==7) theweekday=0;
if (theday>maxdays)
{
theday=1;
themonth++;
if (themonth==13)
{
themonth=1;
theyear++;
}
}
}
document.write("</b></font>");    
       
