//Javascript name: My KLMP Rules And Regulations
//Date created: 25-June-2007 23:19
//Scripter: Matthew Williamson
//Website: http://www.murraystate.edu/wsi/
//Copyright (c) 2007 Center for Reservoir Research
//Copyright (c) 2009 Watershed Studies Institute
//FileName: KLMPScripts.js
//Version: 1
//Contact: matthew.williamson@murraystate.edu
// Note: Permission given to use this script in ANY kind of applications if
//       header lines are left unchanged.
function mytoday() {
var currentTime = new Date();
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
//document.write(month + "/" + day + "/" + year)
document.DatReq.EndDate.value = month + "/" + day + "/" + year;
}

function AddGIF(sender) {
document.DatReq.holder.src = "images/" + sender + ".gif"
}

function RemoveGIF() {
document.DatReq.holder.src = "images/blank.gif"
}

function CheckDates(){
var strTempStart = document.DatReq.StartDate.value
var StartMonth = strTempStart.substring(0,strTempStart.indexOf('/'))
strTempStart = strTempStart.substring(strTempStart.indexOf('/')+1)
var StartDay = strTempStart.substring(0,strTempStart.indexOf('/'))
var StartYear = strTempStart.substring(strTempStart.indexOf('/')+1)

var strTempEnd = document.DatReq.EndDate.value
var EndMonth = strTempEnd.substring(0, strTempEnd.indexOf('/'))
strTempEnd = strTempEnd.substring(strTempEnd.indexOf('/')+1)
var EndDay = strTempEnd.substring(0, strTempEnd.indexOf('/'))
var EndYear = strTempEnd.substring(strTempEnd.indexOf('/')+1)

var StartTime = Date.UTC(StartYear, StartMonth, StartDay,0,0,0)
var EndTime = Date.UTC(EndYear, EndMonth, EndDay,0,0,0)
var firstCruise = Date.UTC(1990,3,25,0,0,0)

if (StartTime > EndTime)
	{alert("Your start date must be before your end date");
	document.DatReq.StartDate.value = "7/22/1988";
	document.DatReq.StartDate.focus();}
if (EndTime < Date.UTC(1990,3,25,0,0,0))
	{document.DatReq.chk1L.checked = false;
	document.DatReq.chk1L.disabled = true;
	document.DatReq.chk2L.checked = false;
	document.DatReq.chk2L.disabled = true;
	document.DatReq.chk3L.checked = false;
	document.DatReq.chk3L.disabled = true;
	document.DatReq.chk4L.checked = false;
	document.DatReq.chk4L.disabled = true;
	document.DatReq.chk5L.checked = false;
	document.DatReq.chk5L.disabled = true;}
else
	{document.DatReq.chk1L.disabled = false;
	document.DatReq.chk2L.disabled = false;
	document.DatReq.chk3L.disabled = false;
	document.DatReq.chk4L.disabled = false;
	document.DatReq.chk5L.disabled = false;}


if (EndTime < Date.UTC(1995,12,4,0,0,0))
	{document.DatReq.chk1N.checked = false;
	document.DatReq.chk1N.disabled = true;
	document.DatReq.chk2N.checked = false;
	document.DatReq.chk2N.disabled = true;
	document.DatReq.chk3N.checked = false;
	document.DatReq.chk3N.disabled = true;
	document.DatReq.chk10L.checked = false;
	document.DatReq.chk10L.disabled = true;
	document.DatReq.chk11L.checked = false;
	document.DatReq.chk11L.disabled = true;}
else 
	{document.DatReq.chk1N.disabled = false;
	document.DatReq.chk2N.disabled = false;
	document.DatReq.chk3N.disabled = false;
	document.DatReq.chk10L.disabled = false;
	document.DatReq.chk11L.disabled = false;}

if (EndTime < Date.UTC(1996,27,1,0,0,0))
	{document.DatReq.chk4N.checked = false;
	document.DatReq.chk4N.disabled = true;}
else 
	{document.DatReq.chk4N.disabled = false;}

if (EndTime < Date.UTC(1988,25,7,0,0,0))
	{document.DatReq.chkUB.checked = false;
	document.DatReq.chkUB.disabled = true;}
else 
	{document.DatReq.chkUB.disabled = false;}

if (StartTime > Date.UTC(1993,5,20,0,0,0) || EndTime < Date.UTC(1991,7,2,0,0,0))
	{document.DatReq.chkUA.checked = false;
	document.DatReq.chkUA.disabled = true;
	document.DatReq.chkED.checked = false;
	document.DatReq.chkED.disabled = true;
	document.DatReq.chkUD.checked = false;
	document.DatReq.chkUD.disabled = true;
	document.DatReq.chkUE.checked = false;
	document.DatReq.chkUE.disabled = true;
	document.DatReq.chkUM.checked = false;
	document.DatReq.chkUM.disabled = true;
	document.DatReq.chkUR.checked = false;
	document.DatReq.chkUR.disabled = true;
	document.DatReq.chkWE.checked = false;
	document.DatReq.chkWE.disabled = true;
	document.DatReq.chkWM.checked = false;
	document.DatReq.chkWM.disabled = true;
	document.DatReq.chkWR.checked = false;
	document.DatReq.chkWR.disabled = true;}
else 
	{document.DatReq.chkUA.disabled = false;
	document.DatReq.chkED.disabled = false;
	document.DatReq.chkUD.disabled = false;
	document.DatReq.chkUE.disabled = false;
	document.DatReq.chkUM.disabled = false;
	document.DatReq.chkUR.disabled = false;
	document.DatReq.chkWE.disabled = false;
	document.DatReq.chkWM.disabled = false;
	document.DatReq.chkWR.disabled = false;}
}

function FilterParams(ListType) {
var strTempStart = document.DatReq.StartDate.value
var StartMonth = strTempStart.substring(0,strTempStart.indexOf('/'))
strTempStart = strTempStart.substring(strTempStart.indexOf('/')+1)
var StartDay = strTempStart.substring(0,strTempStart.indexOf('/'))
var StartYear = strTempStart.substring(strTempStart.indexOf('/')+1)

var strTempEnd = document.DatReq.EndDate.value
var EndMonth = strTempEnd.substring(0, strTempEnd.indexOf('/'))
strTempEnd = strTempEnd.substring(strTempEnd.indexOf('/')+1)
var EndDay = strTempEnd.substring(0, strTempEnd.indexOf('/'))
var EndYear = strTempEnd.substring(strTempEnd.indexOf('/')+1)

var StartTime = Date.UTC(StartYear, StartMonth, StartDay,0,0,0)
var EndTime = Date.UTC(EndYear, EndMonth, EndDay,0,0,0)

var ExcludeFields = new Array()

var FieldsArray = new Array(3)
FieldsArray[0] = new Array(20)

FieldsArray[0][0] = "Cruise Beginning Elevation"
FieldsArray[0][1] = "Cruise Ending Elevation"
FieldsArray[0][2] = "Wind Direction"
FieldsArray[0][3] = "Wind Speed"
FieldsArray[0][4] = "Cloud Cover"
FieldsArray[0][5] = "Sonic Depth"
FieldsArray[0][6] = "1M Light"
FieldsArray[0][7] = "5M Light"
FieldsArray[0][8] = "5M Depth"
FieldsArray[0][9] = "Secchi Depth"
FieldsArray[0][10] = "Temperature"
FieldsArray[0][11] = "Turbidity"
FieldsArray[0][12] = "Total Suspended Solids"
FieldsArray[0][13] = "Volatile Suspended Solids"
FieldsArray[0][14] = "Percent Volatile Suspended Solids"
FieldsArray[0][15] = "Total Solids"
FieldsArray[0][16] = "Volatile Solids"
FieldsArray[0][17] = "Percent Volatile Solids"
FieldsArray[0][18] = "Discharge"
FieldsArray[0][19] = "1% Light"

FieldsArray[1] = new Array(23)
FieldsArray[1][0] = "Titrant Normality"
FieldsArray[1][1] = "Oxidation-Reduction Potential"
FieldsArray[1][2] = "Conductivity"
FieldsArray[1][3] = "Dissolved Oxygen"
FieldsArray[1][4] = "pH"
FieldsArray[1][5] = "Dissolved Organic Nitrogen"
FieldsArray[1][6] = "Dissolved Total Phosphorous"
FieldsArray[1][7] = "Total Kjeldahl Nitrogen"
FieldsArray[1][8] = "Total Phosphorous"
FieldsArray[1][9] = "Dissolved Organic Carbon"
FieldsArray[1][10] = "Phenyl Alkalinity"
FieldsArray[1][11] = "Total Alkalinity"
FieldsArray[1][12] = "Microcuries of Radioactivity (Prim. Prod.)"
FieldsArray[1][13] = "Dissolved Persulfate Nitrogen"
FieldsArray[1][14] = "Dissolved Persulfate Phosphorous"
FieldsArray[1][15] = "Total Persulfate Nitrogen"
FieldsArray[1][16] = "Total Persulfate Phosphorous"
FieldsArray[1][17] = "NH3"
FieldsArray[1][18] = "SO4"
FieldsArray[1][19] = "SiO2"
FieldsArray[1][20] = "Soluble Reactive Phosphorous"
FieldsArray[1][21] = "NO3/NO2"
FieldsArray[1][22] = "Cl"

FieldsArray[2] = new Array(19)
FieldsArray[2][0] = "Algae Genera"
FieldsArray[2][1] = "Algae Species"
FieldsArray[2][2] = "Algae Cells/10 ml"
FieldsArray[2][3] = "Counts/Minute Light (Prim. Prod.)"
FieldsArray[2][4] = "Counts/Minute Dark (Prim. Prod.)"
FieldsArray[2][5] = "Carbon Assimilation"
FieldsArray[2][6] = "B664 Abs."
FieldsArray[2][7] = "B750 Abs."
FieldsArray[2][8] = "A665 Abs."
FieldsArray[2][9] = "A750 Abs."
FieldsArray[2][10] = "Photosyn. Vs"
FieldsArray[2][11] = "Photosyn. Ve"
FieldsArray[2][12] = "Chlorophyll"
FieldsArray[2][13] = "Phaeophytin"
FieldsArray[2][14] = "Zooplankton Families"
FieldsArray[2][15] = "Zooplankton Species"
FieldsArray[2][16] = "Zooplankton Count A"
FieldsArray[2][17] = "Zooplankton Count B"
FieldsArray[2][18] = "Zooplankton Count C"

if (ListType == 1)
	{for (i = 0; i <= 19; i++)
		{ExcludeFields[i] = i}
	if (document.DatReq.chk5L.checked == true || document.DatReq.chk10L.checked == true || document.DatReq.chk11L.checked == true || document.DatReq.chk2N.checked == true || document.DatReq.chk3N.checked == true || document.DatReq.chk4N.checked == true)
		{if (EndTime >= Date.UTC(1990,3,25,0,0,0) && EndTime < Date.UTC(1996,10,29,0,0,0))
			{ExcludeFields[10] = -1;
			ExcludeFields[11] = -1;}
		else if (EndTime >= Date.UTC(1996,10,29,0,0,0))
			{ExcludeFields[10] = -1;
			ExcludeFields[11] = -1;
			ExcludeFields[12] = -1;
			ExcludeFields[13] = -1;
			ExcludeFields[14] = -1;
			ExcludeFields[15] = -1;
			ExcludeFields[16] = -1;
			ExcludeFields[17] = -1;
			ExcludeFields[18] = -1;}}
	if (document.DatReq.chk1L.checked == true || document.DatReq.chk2L.checked == true || document.DatReq.chk3L.checked == true || 
document.DatReq.chk4L.checked == true || document.DatReq.chkCB.checked == true || document.DatReq.chkCH.checked == true || document.DatReq.chkCW.checked == true || document.DatReq.chkEG.checked == true || document.DatReq.chkET.checked == true || document.DatReq.chkEV.checked == true || document.DatReq.chkUJ.checked == true || document.DatReq.chkWA.checked == true || document.DatReq.chkWB.checked == true || document.DatReq.chkWJ.checked == true || document.DatReq.chkWL.checked == true || document.DatReq.chkWP.checked == true || document.DatReq.chkWS.checked == true || document.DatReq.chkED.checked == true || document.DatReq.chkUA.checked == true || document.DatReq.chkUB.checked == true || document.DatReq.chkUD.checked == true || document.DatReq.chkUE.checked == true || document.DatReq.chkUM.checked == true || document.DatReq.chkUR.checked == true || document.DatReq.chkWE.checked == true || document.DatReq.chkWM.checked == true || document.DatReq.chkWR.checked == true)
		{ExcludeFields[0] = -1;
		ExcludeFields[1] = -1;
		ExcludeFields[2] = -1;
		ExcludeFields[3] = -1;
		ExcludeFields[4] = -1;
		ExcludeFields[5] = -1;
		ExcludeFields[6] = -1;
		ExcludeFields[7] = -1;
		ExcludeFields[8] = -1;
		ExcludeFields[9] = -1;
		ExcludeFields[10] = -1;
		ExcludeFields[11] = -1;
		ExcludeFields[19] = -1;}
	j = 0;
	for (i=0;i<=19;i++)
		{if (ExcludeFields[i] == -1)
			{j++}}
	document.DatReq.lstPhysical.length = j;
		j = 0;
		for (i=0;i<=19;i++)
			{if (ExcludeFields[i] == -1)
					{document.DatReq.lstPhysical.options[j].text = FieldsArray[0][i];
					document.DatReq.lstPhysical.options[j].value = FieldsArray[0][i];
					j++;}}}
else if (ListType == 2)
	{for (i=0;i<=22;i++)
		{ExcludeFields[i] = i}
	if (document.DatReq.chkWE.checked == true || document.DatReq.chkUE.checked == true || document.DatReq.chkWR.checked == true ||
document.DatReq.chkUR.checked == true || document.DatReq.chkWM.checked == true || document.DatReq.chkUM.checked == true || document.DatReq.chkUD.checked == true || document.DatReq.chkED.checked == true || document.DatReq.chkCW.checked == true || document.DatReq.chkWJ.checked == true || document.DatReq.chkUJ.checked == true || document.DatReq.chkEV.checked == true || document.DatReq.chkWL.checked == true || document.DatReq.chk1L.checked == true || document.DatReq.chk2L.checked == true || document.DatReq.chk3L.checked == true || document.DatReq.chk4L.checked == true || document.DatReq.chkCH.checked == true || document.DatReq.chkET.checked == true || document.DatReq.chkWA.checked == true || document.DatReq.chkUA.checked == true || document.DatReq.chkWS.checked == true || document.DatReq.chkWB.checked == true || document.DatReq.chkUB.checked == true || document.DatReq.chkCB.checked == true || document.DatReq.chkEG.checked == true || document.DatReq.chkWP.checked == true)
	{for (i=0;i<=22;i++)
		{ExcludeFields[i] = -1}
	if (EndTime < Date.UTC(2000,3,22,0,0,0))
		{ExcludeFields[9]=9}
	if (StartTime > Date.UTC(1994,3,4,0,0,0))
		{ExcludeFields[5] = 5;
		ExcludeFields[6] = 6;
		ExcludeFields[7] = 7;
		ExcludeFields[8] = 8;}
	if (EndTime < Date.UTC(1994,2,27,0,0,0))
		{ExcludeFields[13] = 13;
		ExcludeFields[14] = 14;
		ExcludeFields[15] = 15;
		ExcludeFields[16] = 16;}}
	
	if (document.DatReq.chk5L.checked == true || document.DatReq.chk10L.checked == true || document.DatReq.chk11L.checked == true || document.DatReq.chk2N.checked == true || document.DatReq.chk3N.checked == true || document.DatReq.chk4N.checked == true || document.DatReq.chk1N.checked == true || document.DatReq.chk2L.checked == true)
		{for (i=0;i<=22;i++)
			{ExcludeFields[i] = -1}
		if (EndTime < Date.UTC(1995,11,29,0,0,0))
			{ExcludeFields[9] = 9;}
		else
			{ExcludeFields[9] = -1;}
		if (StartTime > Date.UTC(1993,12,16,0,0,0))
			{ExcludeFields[5] = 5;
			ExcludeFields[6] = 6;
			ExcludeFields[7] = 7;
			ExcludeFields[8] = 8;}
		if (EndTime < Date.UTC(1994,2,27,0,0,0))
			{ExcludeFields[13] = 13;
			ExcludeFields[14] = 14;
			ExcludeFields[15] = 15;
			ExcludeFields[16] = 16;}}
	j = 0;
	for (i=0;i<=22;i++)
		{if (ExcludeFields[i] == -1)
			{j++}}
	document.DatReq.lstChemical.length = j;
	j = 0;
		for (i=0;i<=22;i++)
			{if (ExcludeFields[i] == -1)
				{document.DatReq.lstChemical.options[j].text = FieldsArray[1][i];
				document.DatReq.lstChemical.options[j].value = FieldsArray[1][i];
				j++;}}}
else if (ListType == 3)
	{for (i=0;i<=18;i++)
		{ExcludeFields[i] = i}		
	if (document.DatReq.chk5L.checked == true || document.DatReq.chk10L.checked == true || document.DatReq.chk11L.checked == true ||
document.DatReq.chk2N.checked == true || document.DatReq.chk3N.checked == true || document.DatReq.chk4N.checked == true)
		{ExcludeFields[6] = -1;
		ExcludeFields[7] = -1;
		ExcludeFields[8] = -1;
		ExcludeFields[9] = -1;
		ExcludeFields[10] = -1;
		ExcludeFields[11] = -1;
		ExcludeFields[12] = -1;
		ExcludeFields[13] = -1;}
	if (document.DatReq.chkWE.checked == true || document.DatReq.chkUE.checked == true || document.DatReq.chkWR.checked == true ||
document.DatReq.chkUR.checked == true || document.DatReq.chkWM.checked == true || document.DatReq.chkUM.checked == true || document.DatReq.chkUD.checked == true || document.DatReq.chkED.checked == true || document.DatReq.chkCW.checked == true || document.DatReq.chkWJ.checked == true || document.DatReq.chkUJ.checked == true || document.DatReq.chkEV.checked == true || document.DatReq.chkWL.checked == true || document.DatReq.chk1L.checked == true || document.DatReq.chk2L.checked == true || document.DatReq.chk3L.checked == true || document.DatReq.chk4L.checked == true || document.DatReq.chkCH.checked == true || document.DatReq.chkET.checked == true || document.DatReq.chkWA.checked == true || document.DatReq.chkUA.checked == true || document.DatReq.chkWS.checked == true || document.DatReq.chkWB.checked == true || document.DatReq.chkUB.checked == true || document.DatReq.chkCB.checked == true || document.DatReq.chkEG.checked == true || document.DatReq.chkWP.checked == true)
		{for (i=0;i<=18;i++)
			{ExcludeFields[i] = -1}
		if (document.DatReq.chk2L.checked == true || document.DatReq.chk4L.checked == true || document.DatReq.chkWL.checked == true || document.DatReq.chkCH.checked == true)
			{ExcludeFields[0] = -1;
			ExcludeFields[1] = -1;
			ExcludeFields[2] = -1;}
		else
			{ExcludeFields[0] = 0;
			ExcludeFields[1] = 1;
			ExcludeFields[2] = 2;}
		if (EndTime < Date.UTC(1991,1,1,0,0,0) || StartTime > Date.UTC(1992,12,11,0,0,0))
			{ExcludeFields[0] = 0;
			ExcludeFields[1] = 1;
			ExcludeFields[2] = 2;}}
	var j = 0;
	for (i=0;i<=18;i++)
		{if (ExcludeFields[i] == -1)
			{j++}}
		document.DatReq.lstBiological.length = j;
		j = 0;
		for (i=0;i<=18;i++)
			{if (ExcludeFields[i] == -1)
				{document.DatReq.lstBiological.options[j].text = FieldsArray[2][i];
				document.DatReq.lstBiological.options[j].value = FieldsArray[2][i];
				j++;}}}
if (document.DatReq.lstBiological.length == 0)
	{document.DatReq.lstBiological.length = 1;
	document.DatReq.lstBiological.options[0].text = "No options currently available";}
if (document.DatReq.lstChemical.length == 0)
	{document.DatReq.lstChemical.length = 1;
	document.DatReq.lstChemical.options[0].text = "No options currently available";}
if (document.DatReq.lstPhysical.length ==0)
	{document.DatReq.lstPhysical.length = 1;
	document.DatReq.lstPhysical.options[0].text = "No options currently available";}
}
