var bull = 0;
var eco_factor = 0;
var hab_description = "";
var first_round = 0;
function openLocation(myLink) {
	var eagleName = window.document.eagle.src
	if (eagleName.substring(eagleName.length - 15, eagleName.length) !== "transparent.gif") {
		alert("Congratulations! First clue: respect.");
		window.location = myLink;
	}
	else {
		alert("You must create a perfect bull trout habitat before you get a clue.");
	}
}
function buildHabitat() {
	hab_description = "Your Habitat Description: ";
	eco_factor = 0;
	//cobble
	if (document.habitat.cobble.checked == true) {
		hab_description = hab_description + "Many different types of fish will be able to use the cobble and gravel as nests for their eggs. ";
		eco_factor ++;
		document.rock1.src = "../../images/fish/t_hab/rock1.jpg";
		document.rock2.src = "../../images/fish/t_hab/rock2.jpg";
		document.rock3.src = "../../images/fish/t_hab/rock3.jpg";
		//coho
		if (document.habitat.coho.checked == true) document.coho.src = "../../images/fish/t_hab/coho_gravel.jpg";
		else document.coho.src = "../../images/fish/t_hab/coho_empty_cobble.jpg";
		//bull
		if (bull == 1) document.bull.src = "../../images/fish/t_hab/bull_cobble.jpg";
		else document.bull.src = "../../images/fish/t_hab/bull_empty_cobble.jpg";
		//log4
		if (document.habitat.logs.checked == true) document.log4.src = "../../images/fish/t_hab/log_cobble.jpg";
		else document.log4.src = "../../images/fish/t_hab/log_empty_cobble.jpg";
	}
	else {
		hab_description = hab_description + "The sandy creek bottom is not well suited for salmonid nests. ";
		document.rock1.src = "../../images/fish/t_hab/sand1.jpg";
		document.rock2.src = "../../images/fish/t_hab/sand2.jpg";
		document.rock3.src = "../../images/fish/t_hab/sand3.jpg";
		//coho
		if (document.habitat.coho.checked == true) document.coho.src = "../../images/fish/t_hab/coho_sand.jpg";
		else document.coho.src = "../../images/fish/t_hab/coho_empty.jpg";
		//bull
		if (bull == 1) document.bull.src = "../../images/fish/t_hab/bull_sand.jpg";
		else document.bull.src = "../../images/fish/t_hab/bull_empty.jpg";
		//log4
		if (document.habitat.logs.checked == true) document.log4.src = "../../images/fish/t_hab/log_sand.jpg";
		else document.log4.src = "../../images/fish/t_hab/log_empty.jpg";
	}
	//coho add factor
	if (document.habitat.coho.checked == true) {
		eco_factor = eco_factor + 2;
		hab_description = hab_description + "Your juvenile coho are a perfect food source for bull trout. ";
	}
	//brook_trout
	if (document.habitat.brook.checked == true) {
		document.brook.src = "../../images/fish/t_hab/brook.jpg";
		eco_factor = eco_factor - 2;
		hab_description = hab_description + "Brook trout are nonnative fish and will compete for habitat with other native fish, including bull trout. ";
	}
	else document.brook.src = "../../images/fish/t_hab/brook_empty.jpg";	
	//logs 1,2,3
	if (document.habitat.logs.checked == true) {
		eco_factor ++;
		document.log1.src = "../../images/fish/t_hab/log1.jpg";
		document.log2.src = "../../images/fish/t_hab/log2.jpg";
		document.log3.src = "../../images/fish/t_hab/log3.jpg";
		hab_description = hab_description + "The logs in your creek will help to keep the waters cool and provide shelter for salmonids. ";
	}
	else {
		document.log1.src = "../../images/fish/t_hab/log1_empty.jpg";
		document.log2.src = "../../images/fish/t_hab/log2_empty.jpg";
		document.log3.src = "../../images/fish/t_hab/log3_empty.jpg";
		hab_description = hab_description + "There are no logs in your creek. Any fish entering this creek will have difficulty finding shelter from the sun and from predators. ";
	}
	//forests
	var forest_file = "../../images/fish/t_hab/";
	if (document.habitat.forested.checked == true) {
		eco_factor ++;
		forest_file = forest_file + "f1";
		hab_description = hab_description + "The forested mountainsides will guarantee a cool, clean water supply into your creek. ";
	}
	else {
		forest_file = forest_file + "f0";
		hab_description = hab_description + "Water trickling down the mountainside will gather heat from the sun. Most salmonids, especially bull trout, cannot survive in warm water. During rainstorms, runoff will erode the treeless landscape and muddy will enter your creek. Muddy water can suffocate trout and salmon eggs. ";
	}
	if (document.habitat.riparian.checked == true) {
		eco_factor ++;
		forest_file = forest_file + "r1";
		hab_description = hab_description + "Trees in your riparian zone will help to shade and to keep the creek cool. ";
	}
	else forest_file = forest_file + "r0";
	document.forest1.src = forest_file + "_a.jpg";
	document.forest2.src = forest_file + "_b.jpg";
	//bmi
	if (document.habitat.bmi.checked == true) {
		eco_factor ++;
		hab_description = hab_description + "Young salmonids, including juvenile bull trout will feast on the benthic macroinvertebrates. ";
	}
	//temp
	if (document.habitat.temp30.checked == true) {
		document.temp.src = "../../images/fish/t_hab/temp_30.jpg";
		hab_description = hab_description + "And by the way, your creek is frozen. ";
	}
	if (document.habitat.temp45.checked == true) {
		eco_factor = eco_factor + 3;
		document.temp.src = "../../images/fish/t_hab/temp_45.jpg";
		hab_description = hab_description + "Lastly, your creek's temperature is perfect for spawning bull trout. ";
	}
	if (document.habitat.temp72.checked == true) {
		document.temp.src = "../../images/fish/t_hab/temp_72.jpg";
		hab_description = hab_description + "Sadly, your creek's temperature is far too warm. Few native fish will survive in these temperatures. ";
	}
	if (first_round == 0) hab_description = "Each time you redraw your habitat, look for a description of your habitat here.";
	document.habitat.description.value = hab_description;
	first_round = 1
	document.habitat.eco_factor.value = eco_factor;
	if (eco_factor >= 10) {
		document.bull.src = "../../images/fish/t_hab/bull_cobble.jpg";
		window.document.eagle.src = "../../elements/eagle_btn_ani.gif";
	}
}