// Created by Holly Kenyon																			    																		
// 																										
// The user enters in their birthday and the calcAgeGroup() function checks to see what age bracket they  
// should be in.													    									
// The age group is then highlighted in red. Before the new age group is presented, the old age group text
// is changed to black and the new one is changed to red.	
												
function calcAgeGroup() 
{
/* Determine Age Group from Date of Birth */
 
/* Grab values from inputs */
	var year = document.ageGroups.year.value;
	var month = document.ageGroups.month.value;
	var day = document.ageGroups.day.value;
		
/* Comparison date for this season */
	var compareMonth = 8;
	var compareDay = 31;
	var compareYear = 2012; 
	
	var	years = compareYear - year;
	
	
	if (compareMonth <= month)
	{
		if (month == compareMonth)
		{
			if (day > compareDay)
				years--;
		}
		else
			years--;
	}
		
	var ageGroup = years;

/* There is no club team for 13 yr olds. They can play in the 14U */	
	if (ageGroup == 13)
		ageGroup = 14;
		
/* Set <= 12 to 12's Age Group */
	if (ageGroup <= 12) 
		ageGroup = 12;

document.getElementById('ageHere').innerHTML = "Age Group: " + ageGroup;		
document.getElementById('ageHere').style.visibility="visible";

changeBackTextColor();

changeTextColor(ageGroup);
}

// the comment line is changed to red depending upon their age
function changeTextColor(num)
{
	if ( num == "18" )
		document.getElementById('num18').style.color = 'red';
	else if ( num == "17" )
		document.getElementById('num17').style.color = 'red';
	else if ( num == "16" )
		document.getElementById('num16').style.color = 'red';
	else if ( num == "15" )
		document.getElementById('num15').style.color = 'red';	
	else if ( num == "14" )
		document.getElementById('num14').style.color = 'red';
	else if ( num == "12" )
		document.getElementById('num12').style.color = 'red';	
}

// all 5 comment lines are changed to black
function changeBackTextColor()
{
	document.getElementById('num18').style.color = 'black';
	document.getElementById('num17').style.color = 'black';
	document.getElementById('num16').style.color = 'black';
	document.getElementById('num15').style.color = 'black';
	document.getElementById('num14').style.color = 'black';
	document.getElementById('num12').style.color = 'black';
}
