function GetParams() {
    var sLocation = new String(window.location);     //property contains domain, directory, 
                                                     //filename of the document plus the params (and the "?" before the params).
    var sParamsList = new String(sLocation.substr(sLocation.lastIndexOf("?")+1));
    return sParamsList.split('&');
}
function verifyCheckBoxes() {
	var formObj = document.UserForm;
	//var Geo =      formObj.StateBox.value;
	var list = formObj.StateBox
	var index = list.selectedIndex;
	var Geo = list.options[index].value;
	
	//var County =     formObj.CountyBox.value;	
    var list = formObj.CountyBox
	var index = list.selectedIndex;
	var County = list.options[index].value;
	
	//var Variable =      formObj.VariableBox.value;
    var list = formObj.VariableBox
	var index = list.selectedIndex;
	var Variable = list.options[index].value;
	
//	var Compare = formObj.CompareBox.value;
    var list = formObj.CompareBox
	var index = list.selectedIndex;
	var Compare = list.options[index].value;
	
//	var Compare = formObj.CompareBox.value;
    var list = formObj.NumberBox
	var index = list.selectedIndex;
	var NumberBox = list.options[index].value;
	
	var okToSubmit = 0;
	var listForError = "";
	
	if (Geo == "**") {
		listForError = listForError + "State\n";
	}
	if (County == "***") {
		listForError = listForError + "County\n";
	}
	if (Variable == "**") {
		listForError = listForError+ "Peer Basis\n";
	}
	if (Compare == "**") {
		listForError = listForError + "Comparison\n";
	}
	if (NumberBox == "**") {
		listForError = listForError + "Number of Peers\n";
	}
	
	//return okToSubmit;
	return listForError;
}


function submitPeer() {
	   var formObj = document.UserForm;
	//var Geo =      formObj.StateBox.value;
	var list = formObj.StateBox
	var index = list.selectedIndex;
	var Geo = list.options[index].value;
	
	//var County =     formObj.CountyBox.value;	
    var list = formObj.CountyBox
	var index = list.selectedIndex;
	var County = list.options[index].value;
	
	//var Variable =      formObj.VariableBox.value;
    var list = formObj.VariableBox
	var index = list.selectedIndex;
	var Variable = list.options[index].value;
	
//	var Compare = formObj.CompareBox.value;
    var list = formObj.CompareBox
	var index = list.selectedIndex;
	var Compare = list.options[index].value;
	
//	var Compare = formObj.CompareBox.value;
    var list = formObj.NumberBox
	var index = list.selectedIndex;
	var NumberBox = list.options[index].value;
	
	var listForError = verifyCheckBoxes() ;
		
	if (listForError != "") {
		alert("Please make a selection for each category before continuing.");
		//alert("All variables must have a selection to create this graph.\n\nPlease make a selection for the following variable(s): \n"+listForError);
	}
	else {
	
	var queryString = Geo+"&"+County+"&"+Variable+"&"+Compare+"&"+NumberBox+"&"+1; //1 is for regular report
	
	formObj.target='_self';
   formObj.action = "/cgi-bin/peer/peerPostgres.pl?"+queryString;
   //alert (formObj.target);
  // alert (formObj.action);
   formObj.submit();
}//else
}

function UpdateSelected() {
		//alert ("in CancerReportUpdateSelected()");
	var VisibleForm = document.UserForm;
	paramArray = GetParams();
	
	var CurrentStateVisible = VisibleForm.StateBox;
	var CurrentCountyVisible = VisibleForm.CountyBox;
	var CurrentVariableVisible = VisibleForm.VariableBox;
	var CurrentCompareVisible = VisibleForm.CompareBox;
	var CurrentNumberVisible = VisibleForm.NumberBox;
	
	var CurrentStateHidden = paramArray[0];
	var CurrentCountyHidden = paramArray[1];
	var CurrentVariableHidden = paramArray[2];
	var CurrentCompareHidden = paramArray[3];
	var lastparam = paramArray[4];
	var lastparamarray = lastparam.split('#');
	var CurrentNumberHidden = lastparamarray[0];
	
	//var CurrentCancerHidden = CurrentCancerHiddenNumber + "";
	//alert ("current cancer hidden = "+CurrentCancerHidden);
	for (var i=0; i<CurrentStateVisible.length; i++) {
			//alert ("i = "+i+", CurrentCancerVisible.options[i] = "+CurrentCancerVisible.options[i].value);
		if (CurrentStateHidden == CurrentStateVisible.options[i].value) {
			CurrentStateVisible.selectedIndex = i;
			break;
		}
	}
	
	WriteCountySelectBox();
	for (var i=0; i<CurrentCountyVisible.length; i++) {
			//alert ("i = "+i+", CurrentCancerVisible.options[i] = "+CurrentCancerVisible.options[i].value);
		if (CurrentCountyHidden == CurrentCountyVisible.options[i].value) {
			CurrentCountyVisible.selectedIndex = i;
			break;
		}
	}
	
	for (var i=0; i<CurrentVariableVisible.length; i++) {
			//alert ("i = "+i+", CurrentCancerVisible.options[i] = "+CurrentCancerVisible.options[i].value);
		if (CurrentVariableHidden == CurrentVariableVisible.options[i].value) {
			CurrentVariableVisible.selectedIndex = i;
			break;
		}
	}
	ChangeCompareBox();
	
	if (CurrentCompareHidden == "00") {
		CurrentCompareVisible.selectedIndex = 1;
	}
	else if (CurrentCompareHidden == "**") {
		CurrentCompareVisible.selectedIndex = 0;
	}
	else  {
		CurrentCompareVisible.selectedIndex = 2;
	}
	
	ChangeNumberBox();
	
	for (var i=0; i<CurrentNumberVisible.length; i++) {
			//alert ("i = "+i+", CurrentCancerVisible.options[i] = "+CurrentCancerVisible.options[i].value);
		if (CurrentNumberHidden == CurrentNumberVisible.options[i].value) {
			CurrentNumberVisible.selectedIndex = i;
			break;
		}
	}
	
}
/*
function ChangeCompareBox() {
	var State = document.UserForm.StateBox;
	var StateName = State.options[State.selectedIndex];
	
	var Compare = document.UserForm.CompareBox;
	Compare.length = 0;
	
	Compare.options[0] = new Option("All US Counties");
	Compare.options[0].value = "00";
	
	Compare.options[1] = new Option(StateName + " Counties");
	Compare.options[1].value = "01";
}*/

function ChangeNumberBox() { // based upon what's chosen in the compare box
	var formObj = document.UserForm;
	var Compare = document.UserForm.CompareBox;
	var Numbers = document.UserForm.NumberBox;
	var CurrentNumber = Numbers.selectedIndex;
	var CurrentComparison = Compare.selectedIndex;
	
	
	Numbers.length = 0; // start from scratch
	
	
	Numbers.options[0] = new Option(CHOOSE_BEGINNING + "choose number" + CHOOSE_END);
	Numbers.options[0].value = "**";
	Numbers.options[1] = new Option("10");
	Numbers.options[1].value = "10";
	Numbers.options[2] = new Option("20");
	Numbers.options[2].value = "20";
	Numbers.options[3] = new Option("30");
	Numbers.options[3].value = "30";
	Numbers.options[4] = new Option("50");
	Numbers.options[4].value = "50";
	
	if (CurrentComparison == 1) { // index of Total US
		// don't give them the option to return all counties, because we're looking at Total US
		if (CurrentNumber > 4 ) {
			Numbers.selectedIndex = 0; // set it back to choose number if they'd wanted all before
		}
	}
	else {
		Numbers.options[5] = new Option("All");
		Numbers.options[5].value = "99";
		Numbers.selectedIndex = CurrentNumber;
	}
	
} // function
		
	
		
	
	

function ChangeCompareBox() {
	//var County = document.UserForm.CountyBox;
	var formObj = document.UserForm;
	var Compare = document.UserForm.CompareBox;
	var State = document.UserForm.StateBox;
	var index = State.selectedIndex;
	var StateFIPS_Alpha = State.options[index].value;
	var StateFIPS = StateFIPS_Alpha * 1;
	//alert (StateFIPS);
	var CurrentCompare = Compare.selectedIndex;
	//alert ("state fips = "+StateFIPS);
//	alert ("SNAF[01] = "+StateNameAndFIPS[01]);
//	alert ("SNAF['01'] = "+StateNameAndFIPS['01']);
//	alert ("SNAF[1] = "+StateNameAndFIPS[1]);

	var forLoopStart = StateFIPS;
	var forLoopEnd = StateFIPS;
	
	
		for (var i=forLoopStart; i<=forLoopEnd; i++) {
			var StateFIPSNum = i;
		}
	
		Compare.length = 0;
		
		Compare.options[0] = new Option(CHOOSE_BEGINNING + "choose comparison" + CHOOSE_END);
		Compare.options[0].value = "**";
		
		Compare.options[1] = new Option("All US Counties");
		Compare.options[1].value = "00";
	
		if (StateFIPSNum == "11") { 
			// don't do this next step
		}
		else {
			Compare.options[2] = new Option(StateNameAndFIPS[StateFIPSNum] + " Counties");
			Compare.options[2].value = "01";
		}
		
	//alert (CurrentCompare); // this was 2
	//alert (Compare.length);  // this was 2
	if (CurrentCompare >= Compare.length)  {
		Compare.selectedIndex = 1; // total US;
	}
	else {
		Compare.selectedIndex = CurrentCompare;
	}

	//Compare.selectedIndex = 1;
	
	//alert (Compare.selectedIndex);
}

/*
* new way
* John Stephens re-wrote it to make it work in Netscape
*/
function WriteCountySelectBox(){
	//alert("write county select box");
//Function : 	WriteCountySelectBox
//Purpose :	To assign the available options in the CountySelectBox based upon the Selected  State in the State List Box
	
   var formObj = document.UserForm;
	//Assign State List Box Object
	var stateForm = formObj.StateBox;
	//Assign County List Box Object
	var countyForm = formObj.CountyBox;
	//Obtain the value of the Selected Index in the State List Box 
	var stateSelectedIndex = stateForm.selectedIndex;
	var selectedStateFips  = stateForm.options[stateSelectedIndex].value;
	//var selectedStateFips = selectedStateFips_alpha * 1;
	//alert (selectedStateFips);
	//var selectedStateFips = stateForm.options[stateForm.selectedIndex].value;
	
	//Assign the Starting Index for the for loop that will be used to access the variables in the CountyName array
	//The County Name Array contains All of the US Counties indexed by their State/County Fips
	var forLoopStart = selectedStateFips + "000";
	//Assign the Ending Index for the for loop that will be used to access the variables in the CountyName array
	var forLoopEnd = selectedStateFips + "999";
	//alert("entering if loops");
	
	var countyNames = new Array();
	var counties = new Array();
	var CcountyNames = new Array();
	countyForm.disabled = false;
	
	//Read counties in and sort them BEFORE adding to options
	var j=0; //[1] is already used for Entire State	
	for (var i=forLoopStart; i<=forLoopEnd; i++) {
		//If the Array spot has an entry
		if (CountyNameArray[i]) {
			//countyNames.push(seerStatCountyName[i]+"###"+i);
			countyNames[j] = (CountyNameArray[i]+"###"+i);
			j++;
		}
	}
	
	countyNames.sort();
	var newSelectedIndex = 0;
	var disabled = false;
	
	//Checks specific cases and inserts appropriate selections at beginning of countyNames array
	if (selectedStateFips == "**") {
		var selections = new Array(CHOOSE_BEGINNING + "choose county"  + CHOOSE_END + "###***");//, "Entire State###000");
		var CcountyNames = selections.concat(countyNames);
		disabled = true;
		
	}
	else if (selectedStateFips == "00") { // Entire US
		var selections = new Array(CHOOSE_BEGINNING + "choose county"  + CHOOSE_END + "###***", "U.S. (Total)###000");
		var CcountyNames = selections.concat(countyNames);
		newSelectedIndex = 1;
		disabled = true;
		
	}			
	else if (selectedStateFips == "11") { // DC - don't add entire state
		var selections = new Array(CHOOSE_BEGINNING + "choose county"  + CHOOSE_END + "###***");
		var CcountyNames = selections.concat(countyNames);
		//countyNames.unshift(stateForm.options[stateForm.selectedIndex].text+"###"+stateForm.options[stateForm.selectedIndex].value); 
		// this is really awesome.  It takes what's in the box and uses that to fill in this next box - so if we change District of Columbia then it automatically changes here!
		newSelectedIndex = 1;
		disabled = true;
	}		
//	else if (selectedStateFips == "02") { // Alaska
//		var selections = new Array("Alaska###900");
//		var CcountyNames = selections.concat(countyNames);
//		//countyNames.unshift(stateForm.options[stateForm.selectedIndex].text+"###"+stateForm.options[stateForm.selectedIndex].value); 
//		// this is really awesome.  It takes what's in the box and uses that to fill in this next box - so if we change District of Columbia then it automatically changes here!
//		newSelectedIndex = 0;
//		disabled = true;
//	}

// REMOVED HAWAII from here since we now have counties.

//	else if (selectedStateFips == "15") { // Hawaii
//		var selections = new Array("Hawaii###000");
//		var CcountyNames = selections.concat(countyNames);
//		//countyNames.unshift(stateForm.options[stateForm.selectedIndex].text+"###"+stateForm.options[stateForm.selectedIndex].value); 
//		// this is really awesome.  It takes what's in the box and uses that to fill in this next box - so if we change District of Columbia then it automatically changes here!
//		newSelectedIndex = 0;
//		disabled = true;
//	}
	else { 
		var selections = new Array(CHOOSE_BEGINNING + "choose county"  + CHOOSE_END + "###***");//, "Entire State###000");
		var CcountyNames = selections.concat(countyNames);
		
	}
 	
	countyForm.options.length = CcountyNames.length; 
	
	for (var i=0; i<CcountyNames.length; i++){
	     //name and fips finder	
		var name = CcountyNames[i].substring(0, CcountyNames[i].indexOf('#'));	
		var longFips = CcountyNames[i].substring(CcountyNames[i].lastIndexOf('#')+1, CcountyNames[i].length);
		var longFipsLength = longFips.length;
		var fips = longFips.substring(longFipsLength-3, longFipsLength);
		
				
	     //new county constructor call -- seems to reduce "flashing" in Netscape
		counties[i] = new county(name, fips);
		
		//alert (counties[i].value);		
	}
		
	for (var j=0; j<counties.length; j++){
	     //Populates countyForm with appropriate counties		
		countyForm.options[j].text = counties[j].name;
		countyForm.options[j].value = counties[j].value;	
	}
		countyForm.selectedIndex = newSelectedIndex;
		countyForm.disabled = disabled;
	
	//alert (" first option: " + countyForm.options[0].text + ", value: " + countyForm.options[0].value);
//	alert ("end of write county select box");
}

function county(name, fips){
   //county constructor -- two dimensional array	
	this.name = name;
	this.value = fips	
}

/// nothing is used from here on (I don't think - there are two functions that are there without being commented out



// SAVED VERSION OF NEW WAY, NOT IE 5.0 COMPATIBLE
///function WriteCountySelectBox(){
///	//alert("write county select box");
/////Function : 	WriteCountySelectBox
/////Purpose :	To assign the available options in the CountySelectBox based upon the Selected  State in the State List Box
///	
///   var formObj = document.UserForm;
///	//Assign State List Box Object
///	var stateForm = formObj.StateBox;
///	//Assign County List Box Object
///	var countyForm = formObj.CountyBox;
///	//Obtain the value of the Selected Index in the State List Box 
///	var stateSelectedIndex = stateForm.selectedIndex;
///	var selectedStateFips  = stateForm.options[stateSelectedIndex].value;
///	//var selectedStateFips = selectedStateFips_alpha * 1;
///	//alert (selectedStateFips);
///	//var selectedStateFips = stateForm.options[stateForm.selectedIndex].value;
///	
///	//Assign the Starting Index for the for loop that will be used to access the variables in the CountyName array
///	//The County Name Array contains All of the US Counties indexed by their State/County Fips
///	var forLoopStart = selectedStateFips + "000";
///	//Assign the Ending Index for the for loop that will be used to access the variables in the CountyName array
///	var forLoopEnd = selectedStateFips + "999";
///	//alert("entering if loops");
///	
///	var selections = new Array("choose county******", "U.S. (Total)***000", "Entire State***000")
///	var countyNames = new Array();
///	var counties = new Array();
///	
///	//Read counties in and sort them BEFORE adding to options	
///	for (var i=forLoopStart; i<=forLoopEnd; i++) {
///		//If the Array spot has an entry
///		if (seerStatCountyName[i]) {
///			countyNames.push(seerStatCountyName[i]+"***"+i);
///		}
///	}
///	
///	countyNames.sort();
///	
///	//Checks specific cases and inserts appropriate selections at beginning of countyNames array
///	if (selectedStateFips == "**") {
///		//countyNames.unshift(selections[2]);
///		countyNames.unshift(selections[0]);
///		countyForm.selectedIndex = 0;	
///		countyForm.disabled = true;
///	}
///	else if (selectedStateFips == "00") { // Entire US
///		countyNames.unshift(selections[1]);
///		countyNames.unshift(selections[0]);
///		countyForm.selectedIndex = 1;
///		countyForm.disabled = true;
///	}			
///	else if (selectedStateFips == "11") { // DC - don't add entire state
///		countyNames.unshift(selections[0]); 
///		countyForm.selectedIndex = 1;
///		countyForm.disabled = true;
///	}
///	else { 
///	   //     countyNames.unshift(selections[2]);
///		countyNames.unshift(selections[0]);
///		countyForm.selectedIndex = 0;
///		countyForm.disabled = false;
///	}
///	
///	if (selectedStateFips == "02")  { // Alaska
///		countyNames.push("Aleutians East Borough***013","Aleutians West Census Area***016", "Anchorage Borough***020",  "Bethel Census Area***050");
///		countyNames.push("Bristol Bay Borough***060", "Dillingham Census Area***070", "Fairbanks North Star***090", "Haines Borough***100");
///		countyNames.push("Juneau Borough***110", "Kenai Peninsula Borough***122", "Ketchikan Gateway Borough***130", "Kodiak Island Borough***150");
///		countyNames.push("Lake and Peninsula Borough***164", "Matanuska-Susitna Borough***170","Nome Census Area***180","North Slope Borough***185");
///		countyNames.push("Northwest Arctic Borough***188", "Prince of Wales-Outer Ketchikan***201","Sitka Borough***220","Skagway-Yakutat-Angoon***231");
///		countyNames.push("Southeast Fairbanks Census Area***240", "Valdez-Cordova Census Area***261", "Wade Hampton Census Area***270");
///		countyNames.push("Wrangell-Petersburg Census Area***280", "Yukon-Koyukuk Census Area***290");
///
///	}
///	else if (selectedStateFips == "15")  { // Hawaii
///		//alert ("we are in Hawaii");
///		countyNames.push("Hawaii County***001", "Honolulu County***003", "Kalawao County***005", "Kauai County***007","Maui County***009");
///	}
///	
///	
///	countyForm.options.length = countyNames.length; 
///	
///	for (var i=0; i<countyNames.length; i++){
///	     //name and fips finder	
///		var name = countyNames[i].substring(0, countyNames[i].indexOf('*'));
///		var longFips = countyNames[i].substring(countyNames[i].lastIndexOf('*')+1, countyNames[i].length);
///		var longFipsLength = longFips.length;
///		var fips = longFips.substring(longFipsLength-3, longFipsLength);
///		
///	     //new county constructor call -- seems to reduce "flashing" in Netscape
///		counties[i] = new county(name, fips);		
///	}
///		
///	for (var j=0; j<counties.length; j++){
///	     //Populates countyForm with appropriate counties		
///		countyForm.options[j].text = counties[j].name;
///		countyForm.options[j].value = counties[j].value;	
///	}
///}
///
///function county(name, fips){
///   //county constructor -- two dimensional array	
///	this.name = name;
///	this.value = fips	
///}


///////////
///////////function WriteCountySelectBox(){
///////////	//alert("write county select box");
/////////////Function : 	WriteCountySelectBox
/////////////Purpose :	To assign the available options in the CountySelectBox based upon the Selected  State in the State List Box
///////////	
///////////   var formObj = document.UserForm;
///////////	//Assign State List Box Object
///////////	var stateForm = formObj.StateBox;
///////////	//Assign County List Box Object
///////////	var countyForm = formObj.CountyBox;
///////////	//Obtain the value of the Selected Index in the State List Box 
///////////	var selectedStateFips = stateForm.options[stateForm.selectedIndex].value;
///////////	//Assign the Starting Index for the for loop that will be used to access the variables in the CountyName array
///////////	//The County Name Array contains All of the US Counties indexed by their State/County Fips
///////////	var forLoopStart = selectedStateFips + "000";
///////////	//Assign the Ending Index for the for loop that will be used to access the variables in the CountyName array
///////////	var forLoopEnd = selectedStateFips + "999";
///////////	//alert("entering if loops");
///////////	
///////////		//alert("else");
///////////		//Erase all Current options from the County List Box
///////////		countyForm.length=0;
///////////		countyForm.options[0] = new Option("choose county");
///////////		countyForm.options[0].value = "***";
///////////		
///////////		if (selectedStateFips == "02")  { // Alaska
///////////   		countyForm.options[1] = new Option("Aleutians East Borough");           
///////////   		countyForm.options[1].value="013"; 
///////////   		countyForm.options[2] = new Option("Aleutians West Census Area");     
///////////   		countyForm.options[2].value="016"; 
///////////   		countyForm.options[3] = new Option("Anchorage Borough");               
///////////   		countyForm.options[3].value="020"; 
///////////   		countyForm.options[4] = new Option("Bethel Census Area");             
///////////   		countyForm.options[4].value="050"; 
///////////   		countyForm.options[5] = new Option("Bristol Bay Borough");            
///////////   		countyForm.options[5].value="060"; 
///////////   		countyForm.options[6] = new Option("Dillingham Census Area");      
///////////   		countyForm.options[6].value="070"; 
///////////   		countyForm.options[7] = new Option("Fairbanks North Star");              
///////////   		countyForm.options[7].value="090"; 
///////////   		countyForm.options[8] = new Option("Haines Borough");                   
///////////   		countyForm.options[8].value="100"; 
///////////   		countyForm.options[9] = new Option("Juneau Borough");                    
///////////   		countyForm.options[9].value="110"; 
///////////   		countyForm.options[10] = new Option("Kenai Peninsula Borough");           
///////////   		countyForm.options[10].value="122"; 
///////////   		countyForm.options[11] = new Option("Ketchikan Gateway Borough");         
///////////   		countyForm.options[11].value="130"; 
///////////   		countyForm.options[12] = new Option("Kodiak Island Borough");             
///////////   		countyForm.options[12].value="150"; 
///////////   		countyForm.options[13] = new Option("Lake and Peninsula Borough");        
///////////   		countyForm.options[13].value="164"; 
///////////   		countyForm.options[14] = new Option("Matanuska-Susitna Borough");         
///////////   		countyForm.options[14].value="170"; 
///////////   		countyForm.options[15] = new Option("Nome Census Area");                  
///////////   		countyForm.options[15].value="180"; 
///////////   		countyForm.options[16] = new Option("North Slope Borough");               
///////////   		countyForm.options[16].value="185"; 
///////////   		countyForm.options[17] = new Option("Northwest Arctic Borough");          
///////////   		countyForm.options[17].value="188"; 
///////////   		countyForm.options[18] = new Option("Prince of Wales-Outer Ketchikan");   
///////////   		countyForm.options[18].value="201"; 
///////////   		countyForm.options[19] = new Option("Sitka Borough");                     
///////////   		countyForm.options[19].value="220"; 
///////////   		countyForm.options[20] = new Option("Skagway-Yakutat-Angoon");            
///////////   		countyForm.options[20].value="231"; 
///////////   		countyForm.options[21] = new Option("Southeast Fairbanks Census Area");   
///////////   		countyForm.options[21].value="240"; 
///////////   		countyForm.options[22] = new Option("Valdez-Cordova Census Area");        
///////////   		countyForm.options[22].value="261"; 
///////////   		countyForm.options[23] = new Option("Wade Hampton Census Area");          
///////////   		countyForm.options[23].value="270"; 
///////////   		countyForm.options[24] = new Option("Wrangell-Petersburg Census Area");   
///////////   		countyForm.options[24].value="280"; 
///////////   		countyForm.options[25] = new Option("Yukon-Koyukuk Census Area");         
///////////   		countyForm.options[25].value="290";       
///////////
///////////		}
///////////		else if (selectedStateFips == "15")  { // Hawaii
///////////			countyForm.options[1] = new Option("Hawaii County");
///////////			countyForm.options[1].value = "001";
///////////			countyForm.options[2] = new Option("Honolulu County");
///////////			countyForm.options[2].value = "003";
///////////			countyForm.options[3] = new Option("Kalawao County");
///////////			countyForm.options[3].value = "005";
///////////			countyForm.options[4] = new Option("Kauai County");
///////////			countyForm.options[4].value = "007";
///////////			countyForm.options[5] = new Option("Maui County");
///////////			countyForm.options[5].value = "009";
///////////		}
///////////		
///////////		//Read counties in and sort them BEFORE adding to options
///////////		var countyNames = new Array();
///////////		var arrayLength = 0;
///////////		var j = 0; 
///////////		for (var i=forLoopStart; i<=forLoopEnd; i++) {
///////////			//If the Array spot has an entry
///////////			if (seerStatCountyName[i]) {
///////////				//countyNames.push(seerStatCountyName[i]+"***"+i);
///////////				countyNames[j] = (seerStatCountyName[i]+"***"+i);
///////////				j++;
///////////			}
///////////		}//for
///////////		
///////////		//alert("about to sort");
///////////		//for (var i=0; i<countyNames.length; i++) {
///////////			//alert(i+" "+countyNames[i]);
///////////		//}
///////////		
///////////		countyNames.sort();
///////////		//alert(countyNames.length);
///////////		
///////////		var j = 1; //1 because [0] is -- choose --
///////////		//var j = 0; //Separate Counter for assigning the members of the list box
///////////		//alert("Entering loop");
///////////		//alert(countyNames[0]);
///////////		for (var i=0; i<countyNames.length; i++){
///////////			//alert("countyNames[i] = "+countyNames[i]);
///////////			var name = countyNames[i].substring(0, countyNames[i].indexOf('*'));
///////////			//alert("name = "+name);
///////////			var longFips = countyNames[i].substring(countyNames[i].lastIndexOf('*')+1, countyNames[i].length);
///////////			var longFipsLength = longFips.length;
///////////			var fips = longFips.substring(longFipsLength-3, longFipsLength);
///////////			//alert(fips);
///////////			//if (seerStatCountyName[i]){
///////////				//alert(seerStatCountyName[i]);
///////////				//Create a new option for the county
///////////			countyForm.options[j] = new Option(name);
///////////				//Value of the option equals the state/county Fips
///////////			countyForm.options[j].value = fips;//+"&"+name;
///////////			j++;
///////////			//}
///////////			}//for
///////////
///////////
///////////	//Assign the selectedIndex for the County List Box to the first entry.
///////////	countyForm.selectedIndex = 0;	//Select First Record in List Box
///////////	//alert("leaving WriteCountySelectBox");
///////////}
///////////
///////////function WriteCountySelectBoxOLD(){
/////////////Function : 	WriteCountySelectBox
/////////////Purpose :	To assign the available options in the CountySelectBox based upon the Selected  State in the State List Box
///////////
///////////	//Assign State List Box Object
///////////	var stateForm = document.UserForm.StateBox;
///////////	//Assign County List Box Object
///////////	var countyForm = document.UserForm.CountyBox;
///////////	
///////////	//Obtain the value of the Selected Index in the State List Box 
///////////	var selectedStateFips = stateForm.options[stateForm.selectedIndex].value;
///////////	//Assign the Starting Index for the for loop that will be used to access the variables in the CountyName array
///////////	//The County Name Array contains All of the US Counties indexed by their State/County Fips
///////////	var forLoopStart = selectedStateFips + "000";
///////////	//Assign the Ending Index for the for loop that will be used to access the variables in the CountyName array
///////////	var forLoopEnd = selectedStateFips + "999";
///////////
///////////	//Erase all Current options from the COunty List Box
///////////	countyForm.length=0;
///////////	var j = 0; //Separate Counter for assigning the members of the list box
///////////	for (var i=forLoopStart; i<=forLoopEnd; i++){
///////////		//If the Array spot has an entry
///////////		if (CountyName[i]){
///////////			//Create a new option for the county
///////////			countyForm.options[j] = new Option(CountyName[i]);
///////////			//Value of the option equals the state/county Fips
///////////			countyForm.options[j].value = i;
///////////			j++;
///////////		}
///////////	}
///////////	//Assign the selectedIndex for the County List Box to the first entry.
///////////	countyForm.selectedIndex = 0;	//Select First Record in List Box
///////////}

/*
function RetainSelectedState(){
//Function : 	RetainSelectedState()
//Purpose : 	This Function is used to set the Selected Index of the State List Box equal to the state that was submitted by the 
//		user when the form was submitted. This function is called by the RetainListBoxes() function as part of 
//		the onLoad Script for the <BODY> tag.
//		This function makes use of the Javascript variable searchCounty that is defined in the <HEAD> section of the HTML page.
//   		The value for the searchCounty flag is obtained by the Perl script that writes the HTML page. The Perl script inserts
//		the value for the state/county Fips from the environment variables into the page as the value for the searchCounty.

	//If the Search County is Defined
	if (searchCounty!=0){
		//Assign the State List Box to a variable
		var stateForm = document.UserForm.StateBox;
		
		var lastSelectedState = "";
		//Convert searchCounty into a string
		var countyString = "" + searchCounty;
		//If the state fips is less than 10, the state portion of the Fips code is only passed as a single digit, without the leading zero
		//The string conversion and length check are used here to avoid any possibble confusion that this could lead to.
		if (countyString.length == 4){ //State with Fips Code less than 10
			lastSelectedState = countyString.substring(0,1);
			//Add on the leading zero
			lastSelectedState = "0" + lastSelectedState;
		}
		else if (countyString.length == 5)
			lastSelectedState = countyString.substring(0,2);
		//Search the state selection Box for the state fips that matches the one extracted from countyString
		for (var i =0; i < stateForm.length; i++){
			if (stateForm.options[i].value == lastSelectedState){
				//Change the selected index to the matching state.
				stateForm.selectedIndex = i;
				break;
			}
		}
	}
}
function RetainSelectedCounty(){
//Function : 	RetainSelectedCounty()
//Purpose : 	This Function is used to set the Selected Index of the County List Box equal to the county that was submitted by the 
//		user when the form was submitted. This function also performs the same task for the Ecological Variable.
//	  	This function is called by the RetainListBoxes() function as part of the onLoad Script for the <BODY> tag.
//		This function makes use of the Javascript variable searchCounty that is defined in the <HEAD> section of the HTML page.
//   		The value for the searchCounty flag is obtained by the Perl script that writes the HTML page. The Perl script inserts
//		the value for the state/county Fips from the environment variables into the page as the value for the searchCounty.
	//If the Search County is Defined
	if (searchCounty!=0){
		//Assign the County List Box to a variable
		var countyForm = document.UserForm.CountyBox;
		
		for (var i =0; i < countyForm.length; i++){
			if (countyForm.options[i].value == searchCounty)
				countyForm.selectedIndex = i;
		}
		//Assign the Ecological Variable list box to a variable
		var ecoVarForm = document.UserForm.variable;
		
		for (var j =0; j < ecoVarForm.length; j++){
			if (ecoVarForm.options[j].value == searchVariable)
				ecoVarForm.selectedIndex = j;
		}
			
	}
}
*/

function AssignHiddenVariables(){
	//Function : 	AssignHiddenVariables()
	//Purpose :  	This function is used to assign the text associated with the users selected list box options
	//		 to a hidden variable. These values are passed to the as part of the POST to allow the new page to write
	//		 out a description of the data that is displayed.
	//		 This function is called only when the User submits the Form.
	
	//Assign the UserForm to a variable
	var UserForm = document.UserForm;
	//State Name
	UserForm.StateDisplayName.value = UserForm.StateBox.options[UserForm.StateBox.selectedIndex].text;
	//County Name
	UserForm.CountyDisplayName.value = UserForm.CountyBox.options[UserForm.CountyBox.selectedIndex].text;
	//Ecological Variable Name
	UserForm.EcoDisplayName.value = UserForm.VariableBox.options[UserForm.VariableBox.selectedIndex].text;
	//Submit the Form
	UserForm.submit();
}

function AssignHiddenVariables2(){
	//Function : 	AssignHiddenVariables()
	//Purpose :  	This function is used to assign the text associated with the users selected list box options
	//		 to a hidden variable. These values are passed to the as part of the POST to allow the new page to write
	//		 out a description of the data that is displayed.
	//		 This function is called only when the User submits the Form.
	
	//Assign the UserForm to a variable
	var UserForm = document.UserForm;
	//State Name
	//UserForm.StateDisplayName.value = UserForm.State.options[UserForm.State.selectedIndex].text;
	//County Name
	//UserForm.CountyDisplayName.value = UserForm.County.options[UserForm.County.selectedIndex].text;
	//Ecological Variable Name
	//UserForm.EcoDisplayName.value = UserForm.variable.options[UserForm.variable.selectedIndex].text;
	//Submit the Form
	UserForm.submit();
}
/*
function RetainListBoxes(){
	//Determine which state was passed in to the page and make it the initial selected state
	RetainSelectedState();
	//Assign the appropriate county names to the county list box based on the initial selected state index
	WriteCountySelectBox();
	//Determine which state and ecological variable were passed into the page and make them the initial selections
	RetainSelectedCounty();
}*/
