function showstates() {
	document.getElementById('hideMeStates').style.visibility='visible';
	if (document.choice.category.selectedIndex==0) {
		allCategories();
	}
	return true;
}

function hidestates() {
	document.getElementById('hideMeStates').style.visibility='hidden';
	if (document.choice.category.selectedIndex==0) {
		allCategories();
	}
	return true;
}

function showsub() {
	document.getElementById('hideMeSub').style.visibility='visible';
	return true;
}

function hidesub() {
	document.getElementById('hideMeSub').style.visibility='hidden';
	return true;
}

function getStartYear(){	
	var year;
	
	if (document.choice.subcategory.selectedIndex==0&&document.choice.category.selectedIndex==7){
		year=1982;
	}
	else if (document.choice.subcategory.selectedIndex==1&&document.choice.category.selectedIndex==7){
		year=1991;
	}
	else if (document.choice.subcategory.selectedIndex==2&&document.choice.category.selectedIndex==7){
		year=2002;
	}
	else if (document.choice.subcategory.selectedIndex==3&&document.choice.category.selectedIndex==7){
		year=2008;
	}
	else{
		year=1938;
	}
	return year;
}
function getEndYear() {
	var year;
	var d = new Date();
	if (document.choice.subcategory.selectedIndex==0&&document.choice.category.selectedIndex==7){
		year=1985;
	}
	else if (document.choice.subcategory.selectedIndex==1&&document.choice.category.selectedIndex==7){
		year=1994;
	}
	else if (document.choice.subcategory.selectedIndex==2&&document.choice.category.selectedIndex==7){
		year=2004;
	}
	else if (document.choice.subcategory.selectedIndex==2&&document.choice.category.selectedIndex==7){
		year=2008;
	}
	else{
		year=d.getFullYear()-1;
	}
	return year;
}
					  
function change() {
	var startYear;
	var endYear;
	var i;
	var index;
	var myEle;
	
	startYear=getStartYear();
	endYear=getEndYear();

	for (var q=document.choice.strtyear.options.length;q>=0;q--){
		document.choice.strtyear.options[q]=null;
	}
	for (var q=document.choice.endyear.options.length;q>=0;q--){
		document.choice.endyear.options[q]=null;
	}
	
	for (i=endYear; i>=startYear; i--){
		myEle=document.createElement("option");
		myEle.value=i;
		myEle.text=i;
		document.choice.strtyear.add(myEle);
	}	

	for (i=endYear; i>=startYear; i--){
		myEle=document.createElement("option");
		myEle.value=i;
		myEle.text=i;
		document.choice.endyear.add(myEle);
	}

	
	return true;
}

function allCategories(){

	document.getElementById('hideMeStates').style.visibility='hidden';
	if (document.choice.order[0].checked){
		var startYear;
		var endYear;
		var i;
		var index;
		var myEle;
	
		startYear=getStartYear();
		endYear=getEndYear();

		for (var q=document.choice.strtyear.options.length;q>=0;q--){
			document.choice.year.options[q]=null;
		}
		
		for (i=endYear; i>=startYear; i--){
			myEle=document.createElement("option");
			myEle.value=i;
			myEle.text=i;
			document.choice.year.add(myEle);
		}	

		document.getElementById('allCatByYearShowMe').style.visibility='visible';	
		document.getElementById('allCatByYearHideMe').style.visibility='hidden';
		document.getElementById('allCatByStateShowMe').style.visibility='hidden';
	}
	else{
		change();
		document.getElementById('allCatByStateShowMe').style.visibility='visible';
		document.getElementById('allCatByYearShowMe').style.visibility='hidden';
		document.getElementById('allCatByYearHideMe').style.visibility='visible';

	}
	return true;
}

function notAllCategories(){
	document.getElementById('allCatByYearShowMe').style.visibility='hidden';	
	document.getElementById('allCatByYearHideMe').style.visibility='visible';
	document.getElementById('allCatByStateShowMe').style.visibility='hidden';
	if (document.choice.order[0].checked){
		document.getElementById('HideMeStates').style.visibility='hidden';
	}
	else{
		document.getElementById('HideMeStates').style.visibility='visible';
	}
	return true;
}