// Set the title with datecode
window.onload = function() {
	document.title = "BEN-HUR 50th ANNIVERSARY ULTIMATE COLLECTOR'S EDITION AVAILABLE "  + getDateCode();
}

/*
(1)   ON DVD & BLU-RAY 9/27/11

(2)   ON DVD & BLU-RAY TUESDAY

(3)   ON DVD & BLU-RAY TOMORROW

(4)   NOW ON DVD & BLU-RAY
BEN-HUR 50th ANNIVERSARY ULTIMATE COLLECTOR'S EDITION AVAILABLE ON DVD & BLU-RAY 9/27/11
*/

// Get date code string
function getDateCode() {
	var str = "ON BLU-RAY(tm) and DVD SEPT 27";   // Default title
	
	// Get dates and parse them into milliseconds difference from january 01, 1970 
	var currentDate = new Date();
	var currentDate_month = currentDate.getMonth();
	var currentDate_date = currentDate.getDate();
	var currentDate_year = currentDate.getFullYear();
	currentDate = Date.parse(currentDate);
	

	var targetDayAfter  = Date.parse("Sep 28, 2011");
	var targetDate 	    = Date.parse("Sep 27, 2011");
	var targetDayBefore = Date.parse("Sep 26, 2011");
	var targetWeek      = Date.parse("Sep 21, 2011");
	
	// Set title to appropriate value based on date
	if (currentDate >= targetDayAfter)
		str = "NOW ON BLU-RAY(tm) & DVD";
	else if (currentDate >= targetDate && currentDate <= targetDayAfter)
		str = "NOW ON BLU-RAY(tm) & DVD";
	else if (currentDate >= targetDayBefore)
		str = "ON BLU-RAY(tm) & DVD TOMORROW";
	else if (currentDate >= targetWeek)
		str = "ON BLU-RAY(tm) & DVD TUESDAY";
	
	return str;
}


