	// var's that are set by the user
	// defines the system type "cps" or "cws"
	var sysType=""
	// pump capacity in gpm
	var pumpCap=0
	// actual water being pumped from pump, mainly used for cps
	var pumpAct=0
	// pressure tank's max drawdown
	var ptMax=0
	// pressure tank's total volume
	var ptv=0
	// var used for key in drawdownChart array and pswitch array "4060" or "3050", defined in selectPSetting() function
	var pswitchSet=0
	// used to flag a reset, used by etime
	var kill="k"
	// used to flag a timer pause, used by etime and pause()
	var pauseFlag=0

	// var's that are standard
	// elasped time
	var etime=0
	// total gallons used
	var ttg=0
	// current gallons in pressure tank
	var pt=ptMax

	// multideminsional array with item values in it (i.e. allThings["ksi"]["status"] would equal "OFF" or "ON"
	var allThings = new Array()
	// array with name of every item used (used to keep track of which items are being and have been ran)
	var thingsCount = new Array()
	// chart that gives psi for a drawdown percent, an elements key is the draw down percent and it's value is the psi
	var drawdownChart = new Array()
		drawdownChart["3050"] = new Array(30,31,31,32,32,33,33,34,34,35,35,36,36,37,37,38,39,39,40,41,41,42,43,43,44,45,46,46,47,48,49,50) //32
		drawdownChart["4060"] = new Array(40,41,41,42,43,43,44,44,45,46,46,47,48,48,49,50,51,51,52,53,54,54,55,56,57,58,59,60) //28 elements
	// pressure tank cutin/cutout psi settings
	var pswitch = new Array()
		pswitch["3050"]= new Array()
			pswitch["3050"]["cin"]=30
			pswitch["3050"]["cout"]=50
		pswitch["4060"]= new Array()
			pswitch["4060"]["cin"]=40
			pswitch["4060"]["cout"]=60

// pressure tank array ptcd[brand][tankname] value = total volume
// used to calc psi and drawdowns, also populates setting forms
// ptBrands is used to populate forms with full brand names
var ptdb = new Array()
var ptBrands = new Array()
	ptdb["wx"] = new Array()
	ptBrands["wx"] = "Well-X-Troll"
		ptdb["wx"]["WX-101"] = 2
		ptdb["wx"]["WX-102"] = 4.4
		ptdb["wx"]["WX-103"] = 7.6
		ptdb["wx"]["WX-104"] = 10.3
		ptdb["wx"]["WX-200"] = 14
		ptdb["wx"]["WX-202"] = 20
		ptdb["wx"]["WX-203"] = 32
		ptdb["wx"]["WX-205"] = 34
		ptdb["wx"]["WX-250"] = 44
		ptdb["wx"]["WX-251"] = 62
	ptdb["goulds"] = new Array()
	ptBrands["goulds"] = "Goulds"
		ptdb["goulds"]["V6"] = 2
		ptdb["goulds"]["V15"] = 4.5
		ptdb["goulds"]["V25"] = 8.2
		ptdb["goulds"]["V45"] = 13.9
		ptdb["goulds"]["V60"] = 19.9
		ptdb["goulds"]["V100"] = 31.8
		ptdb["goulds"]["V140"] = 45.2
		ptdb["goulds"]["V200"] = 65.1
	ptdb["fl"] = new Array()
	ptBrands["fl"] = "Flex~Lite"
		ptdb["fl"]["FL 5"] = 15
		ptdb["fl"]["FL 12"] = 35
		ptdb["fl"]["FL 17"] = 50
		ptdb["fl"]["FL 22"] = 65
	ptdb["wm"] = new Array()
	ptBrands["wm"] = "WellMate"
		ptdb["wm"]["WM4"] = 14.5
		ptdb["wm"]["WM9"] = 29.5
		ptdb["wm"]["WM12"] = 40.3
		ptdb["wm"]["WM14"] = 47.1
		ptdb["wm"]["WM20"] = 60
	ptdb["sr"] = new Array()
	ptBrands["sr"] = "StaRite"
		ptdb["sr"]["SR/FW35"] = 35
		ptdb["sr"]["SR/FW40"] = 40
		ptdb["sr"]["SR/FW48"] = 48
		ptdb["sr"]["SR/FW60"] = 60

// resets global variables that are defined internally, called by resetSettings()
function resetGlobals() {
	// var's that are standard
	// actual water being pumped from pump, mainly used for cps
	pumpAct=0
	// elasped time
	etime=0
	// total gallons used
	ttg=0
	// current gallons in pressure tank, ptMax is maxdraw down, defined by ptUpdate()
	pt=ptMax
	// array with name of every item used (used to keep track of which items are being and have been ran)
	thingsCount=0
	thingsCount = new Array()
	// multideminsional array with item values in it (i.e. allThings["ksi"]["status"] would equal "OFF" or "ON"
	allThings=0
	allThings = new Array()
}

// changes the system type, populates pt brand dropdown and pt buttons  (though ptBrandFilter() ) on setup page
// called by user/html upon pressing system select button on setup page and system page, and by resetForum()
function popStuff(IncsysType,isRun) {
	// cahnges systemtype
	sysType=IncsysType
	
	ptOut='<select class="vws_select" id="brand" onchange="ptBrandFilter()">'
	var stOut=""

	for (x in ptBrands) {
		ptOut=ptOut +"<option value="+ x +">"+ ptBrands[x] +"</option>"
	}
	ptOut=ptOut + "</select>"
	
	if (sysType=='cws') {
		psOut='<input class="vws_rbutton" type="button" id="pswitchSet46" value="40/60" onclick="selectPSetting(4060,this.id)"/><input class="vws_rbutton" type="button" id="pswitchSet35" value="30/50" onclick="selectPSetting(3050,this.id)"/>'
		stOut='CWS | <input class="vws_button" type="button" value="Change to CPS" onclick="'+ "popStuff('cps','1')" +'">'
		document.getElementById("systype_cws").style.background="#DDEEFF"
		document.getElementById("systype_cps").style.background="#A3E1FF"
	}
	else if (sysType=='cps') {
		psOut='<input class="vws_rbutton" type="button" id="pswitchSet46" value="60psi" onclick="selectPSetting(4060,this.id)"/><input class="vws_rbutton" type="button" id="pswitchSet35" value="50psi" onclick="selectPSetting(3050,this.id)"/>'
		stOut='CPS | <input class="vws_button" type="button" value="Change to CWS" onclick="'+ "popStuff('cws','1')" +'">'
		document.getElementById("systype_cws").style.background="#A3E1FF"
		document.getElementById("systype_cps").style.background="#DDEEFF"
	}
	else {
		psOut=""
		ptOut=""
		sysType=""
		document.getElementById("systype_cws").style.background="#A3E1FF"
		document.getElementById("systype_cps").style.background="#A3E1FF"
	}
	document.getElementById("pSetting").innerHTML=psOut
	document.getElementById("ptDropDown").innerHTML=ptOut
	if ((ptOut!="")&&(isRun!=1)) { ptBrandFilter() }
	document.getElementById("st").innerHTML=stOut
	if (sysType=="cps") {pumpAct=0}
	else {pumpAct=pumpCap}
	pumpChange(document.getElementById("ps").innerHTML)
	pumpAct=0;
}

// populates pt buttons based off of brand selected and system type
// called by resetForum() and popStuff() and by user/html by selecting a brand from the dropdown
function ptBrandFilter(reSet) {
	if (reSet=='1') { brand="wx" }
	else if (reSet=='-1') {
		brand="wx"
		document.getElementById("ptButtons").innerHTML=""
		return
	}
	else { brand=document.getElementById("brand").value }

	document.getElementById("ptButtons").innerHTML=0
	htmlOut=""
	for (x in ptdb[brand]) {
		lineOut="<input class='vws_rbutton' type='button' id='ptButton"+ x +"' value='"+ x +"' onclick='ptButton(this.value)'/>"
		if (sysType=="cws") {
			if (ptdb[brand][x]>17) {
				htmlOut=htmlOut+lineOut
			}
		} else {
			if (ptdb[brand][x]<=17) {
				htmlOut=htmlOut+lineOut
			}
		}
	}
	document.getElementById("ptButtons").innerHTML=htmlOut
	ptButton()
	return
}

// pt selection buttons on the setup page
// called by user by clicking on buttons, changing the custom pSetting text box, and by resetForum()
function ptButton(tank,customPt) {
	ptv=ptdb[brand][tank]
	if (tank==undefined) { ptv=0 } //used to clear all buttons and values, when called by resetForum()
	if (tank=='custom') { ptv=customPt } //used to clear all buttons and values, when called by resetForum()
	if ((ptMax!=undefined)&&(pswitchSet!=0)) {
		ptMax=ptv*((drawdownChart[pswitchSet].length-1)*.01)*1.1
		pt=ptMax // pt volume starts off at the max
		document.getElementById("ptMax").innerHTML=numFormat(ptMax,1,2) //displays the total volume to the html setup page
	} else { document.getElementById("ptMax").innerHTML=numFormat(0,1,2) }
	document.getElementById("ptv").value=numFormat(ptv,1,2) //displays the total volume to the html setup page

	for (x in ptdb[brand]) { //loops though each pt so the function can hit each button
		if (sysType=="cws") {
			if (ptdb[brand][x]>17) { htmlThing="ptButton"+x } //creates the css id name
			else { continue }
		} else if (sysType=="cps") {
			if (ptdb[brand][x]<=17) { htmlThing="ptButton"+x } //creates the css id name
			else { continue }
		}
		//if the tank is the one that the user clicks on, change the bg color to light blue
		if (tank==x) { document.getElementById(htmlThing).style.background="#DDEEFF" }
		//if not then change the bg color is dark blue
		else { document.getElementById(htmlThing).style.background="#A3E1FF" }
	}
	return
}

// sets the pressure setting(i.e. 30/50 or 40/60) from the user and assigns pswitchSet with it, also highlights the slections box
function selectPSetting (psetting,pbuttonId) {
	if (psetting==undefined) {
		psetting=0
		return
	}
	if (pbuttonId=="pswitchSet35") {
		document.getElementById(pbuttonId).style.background="#DDEEFF"
		document.getElementById("pswitchSet46").style.background="#A3E1FF"
	} else if (pbuttonId=="pswitchSet46") {
		document.getElementById(pbuttonId).style.background="#DDEEFF"
		document.getElementById("pswitchSet35").style.background="#A3E1FF"
	} else {
		document.getElementById("pswitchSet46").style.background="#A3E1FF"
		document.getElementById("pswitchSet35").style.background="#A3E1FF"
	}
	// var used for key in drawdownChart array and pswitch array
	pswitchSet=psetting
	if ((ptMax!=undefined)&&(pswitchSet!=0)) {
		ptMax=ptv*((drawdownChart[pswitchSet].length-1)*.01)*1.1
		pt=ptMax // pt volume starts off at the max
		document.getElementById("ptMax").innerHTML=numFormat(ptMax,1,2) //displays the total volume to the html setup page
	}
	return
}

// displays the system DIV with all of the user settings, also gives errors for incorrect user input
// called by user by clicking on "start system" button
function submitSettings() {
	if (sysType=="") {
		alert ("Please Select a System Type")
		return
	}
	if (!(pswitchSet=="4060" || pswitchSet=="3050")) {
		alert ("Please Select a Pressure Setting")
		return
	}
	pumpCap=document.getElementById("pumpCap").value
	if (!(pumpCap>0 && pumpCap<=100)) {
		alert ("Please Enter a Valid Pump Capacity (Below 100 GPM's)")
		return
	}
	if (!(ptv>0 && ptv<=250)) {
		alert ("Please Select a Pressure Tank or Enter a Valid Volume (Below 250 Gallons)")
		return
	}
	if (ptv==0) {
		alert ("Please Select a Pressure Tank or manually enter a Total Volume")
		return
	}
	resetSettings() // ran to ensure that var's are cleared from previous runnings
	document.getElementById("setup").style.visibility="hidden"
	document.getElementById("running").style.visibility="visible"
	
	document.getElementById("wp").innerHTML=pswitch[pswitchSet]["cout"]
	document.getElementById("pt").innerHTML=numFormat(pt,1,2)
	return
}

// turns all items OFF except for the pump, called by user on system page
function allOff() {
	for (x in thingsCount) {
		change(thingsCount[x],"ON")
		trThing="tr_" + thingsCount[x]
		document.getElementById(trThing).innerHTML="00:00"
		tguThing="tgu_" + thingsCount[x]
		document.getElementById(tguThing).innerHTML="00.00"
	}
}

// resets system so the user can make adjustments, switches from system to settings view
// called by user by clicking on RESET on the system page, NOT on the settings page
function resetSettings() {
	for (x in thingsCount) {
		change(thingsCount[x],"ON",0)
		trThing="tr_" + thingsCount[x]
		document.getElementById(trThing).innerHTML="00:00"
		tguThing="tgu_" + thingsCount[x]
		document.getElementById(tguThing).innerHTML="00.00"
	}
	resetGlobals()
	kill="k" //used to kill the clock
	timedCount()
	updateStuff()
	document.getElementById("setup").style.visibility="visible"
	document.getElementById("running").style.visibility="hidden"
}

// resets unconventional items in the forum, i.e. the js buttons
// called by user by the 'reset' button on the setup page
function resetForum() {
	popStuff()
	selectPSetting() //resets pressure switch buttons
	ptBrandFilter('-1')
	sysType=0
	ptv=0
	pswitchSet=0
}

// flushes the toilet, duh!
function flush(thing,status) {
	if (status=="Flush") { return }
	hgpmsThing="hgpms_" + thing
	var gpms=0
	gpms=document.getElementById(hgpmsThing).value
	gpms=Math.abs(gpms) //passed though Math.abs() to ensure the value is not a string
	document.getElementById(thing).value="Flush"
	document.getElementById(thing).style.background="#DDEEFF"
	gpmsThing="gpms_" + thing
	innerGpms=numFormat(gpms) + "/" + numFormat(gpms)
	document.getElementById(gpmsThing).innerHTML=innerGpms
	updateThings(thing,"Flush",gpms)
	// starts the clock if it has not been started yet
	if (etime==0) {
		if (pauseFlag==0) {
			kill="0"
			timedCount()
		}
	}
	return
}

// turns items on and off (called by html, allOff(), and resetSettings())
// !NOTE! status is passed to updateTHings() as a literial because the status variable holds the old (oppiset) status
function change(thing,status) {
	hgpmsThing="hgpms_" + thing
	var gpms=0
	gpms=document.getElementById(hgpmsThing).value
	gpms=Math.abs(gpms) //passed though Math.abs() to ensure the value is not a string
	if (status=="OFF") {
		document.getElementById(thing).value="ON"
		document.getElementById(thing).style.background="#DDEEFF"
		gpmsThing="gpms_" + thing
		innerGpms=numFormat(gpms) + "/" + numFormat(gpms)
		document.getElementById(gpmsThing).innerHTML=innerGpms
		updateThings(thing,"ON",gpms)
	} else if (status=="ON") {
		document.getElementById(thing).value="OFF"
		document.getElementById(thing).style.background="#A3E1FF"
		gpmsThing="gpms_" + thing
		innerGpms="0.0/" + numFormat(gpms)
		document.getElementById(gpmsThing).innerHTML=innerGpms
		document.getElementById(gpmsThing).style.color="#000000"
		updateThings(thing,"OFF",gpms)
	}
	// starts the clock if it has not been started yet
	if (etime==0) {
		if (pauseFlag==0) {
			kill="0"
			timedCount()
		}
	}
	return
}

function pause() {
	if (pauseFlag=='0') {
		document.getElementById('pauseButton').style.background="#DDEEFF"
		document.getElementById('pauseButton').value="Unpause"
		pauseFlag=1
	} else {
		document.getElementById('pauseButton').style.background="#A3E1FF"
		document.getElementById('pauseButton').value="Pause"
		pauseFlag=0
		if (etime==0) {
			kill="0"
			timedCount()
		}
	}
	return
}

// keeps running timer (called the first time change() is ran, also called each time resetSettings() is ran)
function timedCount() {
	if (kill==0) {  //only ticks time if kill==0, if it doesn't then the clock stay at 0
		if (pauseFlag==0) { //only tick the time if pauseFlag = 0
			etime=etime+1
			updateStuff()
		}
		t=setTimeout("timedCount()",1000)
	}
	else { etime=0 }
	document.getElementById('et').innerHTML=formatTime(etime)
	return
}

// updates the allThings[][] array as items are turned on and off (ran by change() every time)
function updateThings(thing,status,gpms) {
	if (allThings[thing]==undefined) {
		allThings[thing]=new Array()
		allThings[thing]["name"]=thing
		allThings[thing]["status"]=status
		allThings[thing]["gpms"]=gpms
		allThings[thing]["tgu"]=0
		thingsCount.push(thing)
	} else {
		allThings[thing]["status"]=status
	}
	//if the item is ON then it updates the timer, used to calc running time in updateStuff()
	if (allThings[thing]["status"]=="ON") {allThings[thing]["timer"]=etime}
	else if (allThings[thing]["status"]=="Flush") {allThings[thing]["timer"]=etime}
	else {allThings[thing]["timer"]="00"}

	return
}

// updates calculations based off of allThings array (ran by timedCount every second and by resetSettings)
function updateStuff() {
	tsg=0 //used to calc the current, system wide gpm's
	fie=0 //f internet explore
	ftime=0
	opMod=1 //over produce modifier, gives pumpCap / total usage
	// loops though the name of every item that is running or has ran
	for (x in thingsCount) {
		y=thingsCount[x]
		if ((allThings[y]["status"]==("Flush"))&&(numFormat(allThings[y]["tgu"],2,2)>=1.60)) { change(y,"ON") }

		if ((allThings[y]["status"]=="Flush")||(allThings[y]["status"]=="ON")) {
			tsg+=allThings[y]["gpms"] //adds the items gpm's to the total
			trThing="tr_" + y
			document.getElementById(trThing).innerHTML=formatTime(etime-allThings[y]["timer"])
		} else {
			trThing="tr_" + y
			document.getElementById(trThing).innerHTML=formatTime(0)
			tguThing="tgu_" + y
			document.getElementById(tguThing).innerHTML="00.00"
			allThings[y]["tgu"]=0
		}
	}

	if ((numFormat(pt,1)==0)&&(tsg>pumpCap)) { 
		opMod=pumpCap/tsg
		 }
	tsg*=opMod
	
	// updates the system-wide chart (i.e. total gallons, pressure tank info, psi, etc
	//gu=gallons per min currently being used, ttg=total gallons used so far, pt current gallons in pressure tank
	document.getElementById("gu").innerHTML=numFormat(tsg,1,2) // updates system wide gpm's
	if (opMod!=1) { document.getElementById("gu").style.color="#FF0000" }
	else { document.getElementById("gu").style.color="#000000" }
	ttg+=tsg/60 //total system wide gallons used so far (add's the current gpm each second
	document.getElementById("tg").innerHTML=numFormat(ttg,1,2)
	if (document.getElementById("ps").innerHTML=="OFF") { //if the pump is turned off...
		pt-=tsg/60  //takes the current gpm(divided by 60 for seconds) out of the pressure tank's total to show usage
	} else if (document.getElementById("ps").innerHTML=="ON") { //if pump is turned on...
		//subtracts the pump's gpm rating(pumpCap) by the total usage(tsg) to get the system's net usage (could be a negitive number meaning more water is being used then the pump is producing. this variable is then ADDed to the pressure tank's water level
	pt+=(pumpAct-tsg)/60
	}
	if (pt>=ptMax) {pt=ptMax} //if the pressure tank's water level exceeds it's volume then extra water is eleminated
	if (pt<0) {pt=0} ////if the pressure tank's water level is below 0, make it equal to 0
	document.getElementById("pt").innerHTML=numFormat(pt,1,2)
	psi=calcPsi()
	document.getElementById("wp").innerHTML=psi
	// turns pump on and off if the PSI is above or below the cutin and cutoff point


	if (sysType=="cws") {
		pumpAct=pumpCap
		if (psi <= pswitch[pswitchSet]["cin"]) { pumpChange("ON") }
		else if (psi >= pswitch[pswitchSet]["cout"]) { pumpChange("OFF") }
	}
	else if (sysType=="cps") {
		if ((tsg > 0)||(psi < pswitch[pswitchSet]["cout"])) {

			pumpCap=Math.abs(pumpCap)
			pumpAct=Math.abs(pumpAct)
			if (psi < pswitch[pswitchSet]["cout"]) { pumpAct+=(pumpCap*.25) }
			else if (tsg>pumpAct+(pumpCap*.25)) { pumpAct+=(pumpCap*.25) }
			else if (tsg<=pumpAct+(pumpCap*.25)) {
				if (tsg!=0) { pumpAct=tsg }
			}
			
			if (pumpAct>pumpCap) { pumpAct=pumpCap }
			pumpChange("ON")
		} else { pumpChange("OFF") }
	}

	for (x in thingsCount) {
		y=thingsCount[x]
		if ((allThings[y]["status"]=="Flush")||(allThings[y]["status"]=="ON")) {
			ngpms=allThings[y]["gpms"]*opMod
			gpmsThing="gpms_" + y
			innerGpms=numFormat(ngpms)+ "/" + numFormat(allThings[y]["gpms"])
			document.getElementById(gpmsThing).innerHTML=innerGpms
			tguThing="tgu_" + y
//			tguOld=document.getElementById(tguThing).innerHTML
			allThings[y]["tgu"]+=(ngpms/60)
			document.getElementById(tguThing).innerHTML=numFormat(allThings[y]["tgu"],2,2)
			if (opMod!=1) { document.getElementById(gpmsThing).style.color="#FF0000" }
			else { document.getElementById(gpmsThing).style.color="#000000" }
		}
	}
	return
}

// Calculates the systems PSI based off of how many gallons are in the pressure tank, pt's total vol, and pt's max drawdown
// Called by updateStuff() every second
function calcPsi() {
	var psiOut = 0
	// calc's the percent of tanks volume at cutin - divides tank max draw down(ptMax) by total volume(ptv) (! changed to .6 !) and subtracts the drawdown at cutoff((drawdownChart.length-1)/100)
	drawDiff=ptMax/11
	// gets the tanks current percent of draw volume not including the cutin voume (i.e. cutin voume is 0) - current gallons in tank(pt) divided by total tank volume(ptv), then subtracted by the drawDiff
//	pt=pt/1.2
	currentDrawVol=(pt/ptv)-(drawDiff/ptv)
	// converts the currentDrawDiff from a percent/decimal to a non-float(currentDrawVol*100), then passed to numFormat to ensure there's no float.  This is done to ensure the int can be used as a key
	key=numFormat((currentDrawVol*100),0)
	// ensures that the currentDrawDiff is 0 or higher (meaning the psi is at or above the cutin)
	if ((key>-1) && (key<drawdownChart[pswitchSet].length-1)) {
		// uses the currentDrawDiff value(key) to select the element in the drawdownChart() array that has the currect psi
		psiOut=drawdownChart[pswitchSet][key]
	}
	// to determine the psi if it is below the cutin (above formula only works if psi is within 30/50 or 40/60
	else if (key<0) {
		if (key=="-1") { psiOut=39 }
		else if (key=="-2") { psiOut=39 }
		else if (key=="-3") { psiOut=38 }
		else { psiOut=0 }
		if (numFormat(pt,1)==0) { psiOut=0 }
	}
	// to determine the psi if it is above the cutoff
	// simply sets psi to the psi coutoff point and then shutsdown the pump
	//-2 so the pump shuts off at 60psi, not past it.  also sets pump to 60 on startup
	else if (key>drawdownChart[pswitchSet].length-2) {
		psiOut=pswitch[pswitchSet]["cout"]
	}
	return(psiOut)
}

// turns pump on and off, called by updateStuff() and calcPsi() every second (called redudently to avoid bugs)
function pumpChange(changeTo) {
	if (changeTo=="ON") {
		document.getElementById("ps").innerHTML=changeTo
		document.getElementById("ps").style.color="#FF0000"
		document.getElementById("fp").innerHTML=numFormat(pumpAct,1,2)
	} // if on displays pump's gpms on the page
	else if (changeTo=="OFF") {
		document.getElementById("ps").innerHTML=changeTo
		document.getElementById("ps").style.color="#000000"
		document.getElementById("fp").innerHTML="00.0"
		pumpAct=0
	} // if off dispalys 0 for gpm's
}

function cellFormat(cvalue,cid) {
	document.getElementById(cid).value=numFormat(cvalue,1,2)
}

// formats numbers to be in the currect format
// inputNum=number to be formated, rightP=max digits right of the decimal (rounds off if required), leftP=min digits left of the decimal
// i.e. 2.345,2,2 will return 02.35
// defaults for rightP and leftP are 1 and 0 respectivly
function numFormat(inputNum,rightP,leftP){
	if (rightP==undefined) { rightP=1 }//sets defaults
	if (leftP==undefined) { leftP=0 }//sets defaults
	var leftSide="" //var used to hold numbers left of the decimal
	var rightSide="" //var used to hold numbers right of the decimal
	// the next three lines round the number to the value set in rightP
	inputNum=inputNum*Math.pow(10, rightP) //multiplies the number by 10 to the rightP power
	inputNum=Math.round(inputNum) //rounds off any remaining var's
	inputNum=inputNum/Math.pow(10, rightP) //divies the number back to it's orignal value minus anything that was rounded off
	var inputNumS = inputNum + ""; //turns the number into a string
	var stringNum=0 //ensures the stringNum array is purged
	stringNum=new Array() //turns stringNum into an array
	stringNum=inputNumS.split(".") //splits inputNumS(the string holding the number) into 2 halfs, cut off at the decimal
	leftSide=stringNum[0] //gives the left side of the string to leftSide (everything left of the decimal)
	rightSide=stringNum[1] //gives the right side of the string to rightSide (everything right of the decimal)
	if (leftSide==undefined) { leftSide="0" } //if the left side empty a '0' is assigned to avoid "undefined" errors
	if (rightSide==undefined) { rightSide="0" }  //if the right side empty a '0' is assigned to avoid "undefined" errors
	if (rightSide.length > rightP) { //checks if there are any extra numbers (sometimes Math.round leaves extra zeros
		rightSide=rightSide.split("",rightP)
		rightSide=rightSide.join("")
	}
	while (1) {
		if (rightSide.length < rightP) { rightSide=rightSide+"0" }
		else { break }
	}
	//checks if any zeros need to be added to the left side (i.e. if you had 43 but wanted 043)
	if (leftP!=0) { //zero's are onyl added if leftP does not equal 0, leftSide is smaller then 10, and leftSide does not equal "00"
		if ((leftSide<10)&&(leftSide!="00")) { leftSide="0"+leftSide }
	}
	if (rightP==0) { outNum=leftSide } // if there is no decimal the rightSide is descarded and only the leftSide value is returned
	else { outNum=leftSide + "." + rightSide } //otherwise the leftSide and rightSide are reunited (awe!) and a decimal is placed between them
	return(outNum); //finished copy is returned
}


// formats raw seconds into the MM:SS format
// timem is minutes, times is seconds
function formatTime(incTime) {
	if (incTime==0) { //if time equals 0 both seconds and minutes equal 0
		// note, this conditional is nessasary to ensure the output is in 00:00 format
		times="0"
		timem="0"
	}
	else if (incTime>59) { //if over 59 seconds (1 minute or more)...
		timem=Math.floor(incTime/60) //minutes= the time diveded by 60 and remander cutoff
		times=incTime%60 //seconds= remander of time devided by 60
	}
	else if (incTime<60) { //if under 1 minute... note(does not run if time == 0 because of the function's first if
		timem="0" //minutes= 0
		times=incTime //seconds= time
	}
	if ((timem<10)&&(timem!="00")) { timem="0"+timem } //adds 0's if the number is only one diget (i.e. 3 would be 03
	if ((times<10)&&(times!="00")) { times="0"+times } //same but for seconds
	timeOut=timem + ":" + times
	return (timeOut)
}

function helpBoxOn(helpId) {
	document.getElementById(helpId).style.visibility="visible"
}
function helpBoxOff(helpId) {
	document.getElementById(helpId).style.visibility="hidden"
}