function changeFormSummaries(doChain) {
	var time = document.options.time.value;
	var year = document.options.year.value;
	var season = document.options.season.value;
	var month = document.options.month.value;
	if(time!='Monthly' && time!='Seasonal' && time!='Annual'){
		var y = getURLVar('y')
		var m = getURLVar('m')
		if(y!='' && (m=='Winter' || m=='Spring' || m=='Summer' || m=='Autumn')){
			//seasonal
			time = 'Seasonal'
			year = y
			season = m
		}
		else if(y!='' && m!='' && m!='Annual'){
			//monthly
			time = 'Monthly'
			year = y
			month = m
		}
		else if(y!='' && (m=='' || m=='Annual')){
			//annual
			time = 'Annual'
			year = y
		}
		document.options.time.value = time
		document.options.year.value = year
		document.options.season.value = season
		document.options.month.value = month
/*		if(time!=''){
			changeTextSummaries();
		}*/
	}
	if(doChain=='y' && year=='2009'){
		$('#form_month')
			.item([
				{month_selector:'<br/>Month<br/><select name="month" onchange = "changeFormSummaries(\'n\');"><option value="" selected="selected">&nbsp;</option><option value="01">January</option><option value="02">February</option><option value="03">March</option><option value="04">April</option><option value="05">May</option><option value="06">June</option><option value="07">July</option><option value="08">August</option><option value="09">September</option><option value="10">October</option></select>'}
				])
			.chain();
	}
	else if(doChain=='y') {
		$('#form_month')
			.item([
				{month_selector:'<br/>Month<br/><select name="month" onchange = "changeFormSummaries(\'n\');"><option value="" selected="selected">&nbsp;</option><option value="01">January</option><option value="02">February</option><option value="03">March</option><option value="04">April</option><option value="05">May</option><option value="06">June</option><option value="07">July</option><option value="08">August</option><option value="09">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option></select>'}
				])
			.chain();	
	}

	var form_time = document.getElementById('form_time')
	var form_year = document.getElementById('form_year')
	var form_season = document.getElementById('form_season')
	var form_month = document.getElementById('form_month')
	var go = document.getElementById('go')
	if (time=='Monthly'){
		//turn on year and month only
		form_time.style.display = 'block';
		form_year.style.display = 'block';
		form_season.style.display = 'none';
		if (time && year){
			form_month.style.display = 'block';
			if (time && year && month) {
				go.style.display = 'block';
			}
			else{
				go.style.display = 'none';
			}
		}
		else{
			form_month.style.display = 'none';
			go.style.display = 'none';
		}
	}
	else if(time=='Seasonal'){
		//turn on year and season only
		form_time.style.display = 'block';
		form_year.style.display = 'block';
		form_month.style.display = 'none';
		if (time && year){
			form_season.style.display = 'block';
			if (time && year && season){
				go.style.display = 'block';
			}
			else {
				go.style.display = 'none';
			}
		}
		else {
			form_season.style.display = 'none';
			go.style.display = 'none';
		}
	}
	else if(time=='Annual'){
		//turn on year only
		form_time.style.display = 'block';
		form_year.style.display = 'block';
		form_season.style.display = 'none';
		form_month.style.display = 'none';
		if (time && year){
			go.style.display = 'block';
		}
		else {
			go.style.display = 'none';
		}
	}
	else{
		//turn off year, season, month
		form_time.style.display = 'block';
		form_year.style.display = 'none';
		form_season.style.display = 'none';
		form_month.style.display = 'none';
		go.style.display = 'none';
	}
}

function changeTextSummaries() {
	changeFormSummaries('n');
	var time = document.options.time.value;
	var year = document.options.year.value;
	var season = document.options.season.value;
	var month = document.options.month.value;
	var src = ""
	if (time=='Monthly' && year && month) {
		src = "summaries/Summary_"+year+"-"+month+".html"
	}
	if (time=='Seasonal' && year && season) {
		src = "summaries/Summary_"+year+"-"+season+".html"
	}
	if (time=='Annual' && year){
		src = "summaries/Summary_"+year+"-Annual.html"
	}
	$('.featured_data')
		.item([
			{data_graphic:'<iframe aligh="left" src="'+src+'" width="100%" height="1230" scrolling="no" frameborder="0"></iframe>'}
			])
		.chain();
}
