//* This function looks for a space in the genus form.
function validate() {
  	if (document.searchForm.Genus.value == '') {
		window.alert('You must enter a search term.');
		document.searchForm.Genus.focus();
		return false;
		}
		var myTerm = document.searchForm.Genus.value;
		var marker = myTerm.indexOf(' ');
	if (marker >= 0) {
		window.alert('You must not include a space in the generic name.');
		document.searchForm.Genus.focus();
		return false;
		}
	}


var theURL = window.location.search;
var thePosition = theURL.indexOf("=") + 1;
// var theCat = theURL.substring(thePosition, theURL.length); //
function hide_all() {
	var myDiv = document.getElementById('contactDiv');
    myDiv.style.display = "none";
	
    var myDiv = document.getElementById('introductionDiv');
    myDiv.style.display = "none";
    
	var myDiv = document.getElementById('collectionsDiv');
    myDiv.style.display = "none";

    var myDiv = document.getElementById('partnersDiv');
    myDiv.style.display = "none";
    
	var myDiv = document.getElementById('researchDiv');
    myDiv.style.display = "none";

    var myDiv = document.getElementById('imagesDiv');
    myDiv.style.display = "none";

    var myDiv = document.getElementById('pubsDiv');
    myDiv.style.display = "none";

    var myDiv = document.getElementById('eventsDiv');
    myDiv.style.display = "none";

    var myDiv = document.getElementById('referencesDiv');
    myDiv.style.display = "none";
	
    var myDiv = document.getElementById('returnLinkDiv');
    myDiv.style.display = "none";
}

function show_hide(theDiv){
	 hide_all();
     var myDiv = document.getElementById(theDiv);
	 myDiv.style.display = "block";
     var myReturn = document.getElementById('returnLinkDiv');
	 if (theDiv != "introductionDiv") {
	 	myReturn.style.display = "block";
	 }

}

//* This function shows the div for the term passed on the URL. 
//* It checks for collections, research, publications, images, references, partners, contacts and events.
//* The terms are case sensitive--use all lowercase letters.
//* Other sections open in windows or show directly on the page.
//* The syntax is 'http://www.nmnh.si.edu/botany/index.html?research'
 
function checkURL() {
var whichSection = "";
if (location.search) {
var whichSection = location.search.substring(1);
}	
	
switch (whichSection)
{
case "collections":
show_hide('collectionsDiv');
break;

case "research":
show_hide('researchDiv');
break;

case "publications":
show_hide('pubsDiv');
break;

case "images":
show_hide('imagesDiv');
break;

case "references":
show_hide('referencesDiv');
break;

case "events":
show_hide('eventsDiv');
break;

case "contacts":
show_hide('contactDiv');
break;

case "partners":
show_hide('partnersDiv');
break;

}
}

