// JavaScript Document
/**
* changing head photo out during different seasons of year
* this javascript checks the date against the below date definitions
* and then puts the correct image in for the head bar based on those definitions
**/

//make a date in human readable format
function makeDate(month,day,year) 
{
	var thisDate = new Date(year, month-1, day);
	return thisDate;
}

var d = new Date();
var fYear = d.getFullYear();

//special dates in MSAgron Program
var testStart = makeDate(12,25,fYear); // testing date
var testEnd = makeDate(12,31,fYear);
var gradSpringStart = makeDate(5,5,fYear); //graduation of year (change this yearly)
var gradSpringEnd = makeDate(5,10,fYear);
var orient08start = makeDate(7,23,fYear); //orientation of year (change this yearly)
var orient08end = makeDate(7,26,fYear);

//normal dates to write seasonal head bars (this should stay the same over years)
var endOfYear = makeDate(12,31,fYear);
var firstOfYear = makeDate(1,1,fYear);
var winter = makeDate(12,22,fYear);
var spring = makeDate(3,20,fYear);
var summer = makeDate(6,21,fYear);
var fall = makeDate(9,23,fYear);

//run write image head area on page load (only on index page)
window.onload = writeHeader; 

//write the head image of the index page based on certain dates
function writeHeader(styleStr)
{
	var headArea = document.getElementById("header"); //find head div element
	//if there is a special date, write that
	/*if((d >= testStart) && (d <= testEnd))
	{  
		headArea.style.backgroundImage="url('images/splash_dirt.jpg')";
		headArea.style.height="226px";
	}
	else*/ if((d >= gradSpringStart) && (d <= gradSpringEnd))
	{ 
		headArea.style.backgroundImage="url('images/splash_graduation.jpg')";
		headArea.style.height="226px";
	}
	else if((d >= orient08start) && (d <= orient08end))
	{ 
		headArea.style.backgroundImage="url('images/splash_orientation.jpg')";
		headArea.style.height="226px";	
	}
	else //or write the normal seasons photos
	{
		if((d >= winter) && (d <= endOfYear) || (d >= firstOfYear) && (d <= spring)) //write winter picture
		{ 
		headArea.style.backgroundImage="url('images/splash_winter.jpg')";
		headArea.style.height="226px";			
		}
		else if((d >= spring) && (d <= summer)) //write spring picture
		{ 
		headArea.style.backgroundImage="url('images/splash_spring.jpg')";
		headArea.style.height="226px";			
		}
		else if((d >= summer) && (d <= fall)) //write summer picture
		{ 
		headArea.style.backgroundImage="url('images/splash_summer.jpg')";
		headArea.style.height="226px";			
		}
		else if((d >= fall) && (d <= winter)) //write fall picture
		{  
		headArea.style.backgroundImage="url('images/splash_fall.jpg')";
		headArea.style.height="226px";			
		}		
		else //write default photo
		{ 
		headArea.style.backgroundImage="url('images/splash_image.jpg')";
		headArea.style.height="226px";			
		}
	}
}

function returnMSDate(dateItem)
{
	var dayOmonth = dateItem.getUTCDate();
	var month = dateItem.getMonth() + 1; //full month number
	var fullyear = dateItem.getUTCFullYear();
	return month + ',' + dayOmonth + ',' + fullyear;
}