// BEGIN JAVASCRIPT FOR WEEKEND/WEEKLY SHOPPING EVENTS
// SETS WHETHER THE EVENT WILL BE WEEKEND: THURSDAY-SUNDAY OR WEEKLY: 7 DAY OUTLOOK FROM CURRENT DAY
// USE THIS WAY: <a href="javascript:dateRange('weekend');"> OR <a href="javascript:dateRange('week');">

function dateRange(range) {
	
	var today = new Date();
	var curDay = today.getDay();
	var curMonth = today.getMonth() + 1;
	var curDate = today.getDate();
	var curYear = today.getFullYear();
	
	var nextDate = curDate + 6;
	var nextYear = curYear;
	
	var wkndStart = curDate + (4 - curDay);
	var wkndFinish = wkndStart + 3;
	
	var nextMonth = curMonth;
	
	if (curMonth==1 || curMonth==3 || curMonth==5 || curMonth==7 || curMonth==8 || curMonth==10 || curMonth==12){
		if (curDate > 31){
			curDate = curDate - 31;
			curMonth++;
		}
		
		if (range == 'weekend' && wkndStart > 31){
			wkndStart = wkndStart - 31;
			curMonth++;
		}
		
		if (nextDate > 31){
			nextDate = nextDate - 31;
			nextMonth++;
		}
		
		if (range == 'weekend' && wkndFinish > 31){
			wkndFinish = wkndFinish - 31;
			nextMonth++;
		}
	}	else if (curMonth==4 || curMonth==6 || curMonth==9 || curMonth==11){
			if (curDate > 30){
				curDate = curDate - 30;
				curMonth++;
			}
			
			if (range == 'weekend' && wkndStart > 30){
				wkndStart = wkndStart - 30;
				curMonth++;
			}
			
			if (nextDate > 30){
				nextDate = nextDate - 30;
				nextMonth++;
			}
			
			if (range == 'weekend' && wkndFinish > 30){
				wkndFinish = wkndFinish - 30;
				nextMonth++;
			}
			
		}	else {
			var isleap = (curYear % 4 == 0 && (curYear % 100 != 0 || curYear % 400 == 0));
				if (isleap == true) {
					if (curDate > 29){
						curDate = curDate - 29;
						curMonth++;
					}
					if (range == 'weekend' && wkndStart > 29){
						wkndStart = wkndStart - 29;
						curMonth++;
					}
					if (nextDate > 29 || wkndFinish > 29){
						nextDate = nextDate - 29;
						wkndFinish = wkndFinish - 29;
						nextMonth++;
					}
				}	else {
						if (curDate > 28){
							curDate = curDate - 28;
							curMonth++;
						}
						if (range == 'weekend' && wkndStart > 28){
							wkndStart = wkndStart - 28;
							curMonth++;
						}
						if (range != 'weekend' && nextDate > 28){
							nextDate = nextDate - 28;
							nextMonth++;
						}
						if (range == 'weekend' && wkndFinish > 28){
							wkndFinish = wkndFinish - 28;
							nextMonth++;
						}
					}
				}
	
		if (nextMonth > 12){
			nextMonth = nextMonth - 12;
			nextYear = nextYear + 1;
		}
		
		if (curMonth < 10){
			curMonth = '0' + curMonth;
		}
		
		if (nextMonth < 10){
			nextMonth = '0' + nextMonth;
		}
		
		if (curDate < 10){
			curDate = '0' + curDate;
		}
		
		if (nextDate < 10){
			nextDate = '0' + nextDate;
		}
		
		if (wkndStart < 10){
			wkndStart = '0' + wkndStart;
		}
		
		if (wkndFinish < 10){
			wkndFinish = '0' + wkndFinish;
		}
		
		if (range == 'week'){
			window.location.href = "/ae/scr/nws_oth_sr.cfm?c=&p=re&e=11&ec=0&dr=1&sd=" + curMonth + "%2F" + curDate +"%2F" + curYear + "&ed=" + nextMonth + "%2F" + nextDate + "%2F" + nextYear + "&a=0&ah=0&s=&Go.x=27&Go.y=13";
		}
		else if (range == 'weekend'){
			window.location.href = "/ae/scr/nws_oth_sr.cfm?c=&p=re&e=11&ec=0&dr=1&sd=" + curMonth + "%2F" + wkndStart + "%2F" + curYear + "&ed=" + nextMonth + "%2F" + wkndFinish + "%2F" + nextYear +"&a=0&ah=0&s=&Go.x=27&Go.y=13";
		}
			
	}
// END JAVASCRIPT FOR WEEKEND/WEEKLY SHOPPING EVENTS
