// version 1.38
var hDisplay = ""
var sDisplay = ""
var trackList = new Array()
var isLoading = true
var autoHide = false
var willHide = false
var doNotify = false
var dCount = 0
var dCols = 2
var oVisible = true
var vSize = 300
var doWrap = true
var colorVal = true
var isBold = true
var colorNum = 0
var moveUp = false
var colorStr = "#000000"
var cView = 0
var lCount = 0
var cPer = 50
var useTables = false
var errStr = ""
var calVal = ""
var oldStatus = ""
var isIE = (navigator.appVersion.indexOf("MSIE ") != -1)
var fSize = 14
var waitCount = 0
var showShort = 1
var showFA = 0
var showAt = 0
var showFloor = 0
var showSponsors = 1
var tFiscalBills = 0
var skipCount = 1
var cShow = new Array()
var hArr = new Array()
var mArr = new Array()
var sArr = new Array()
var cText = new Array()
var cBill = new Array()
var ctBill = new Array()
var sOff = new Array()
var hCount = new Array()
var noCalText = "<CENTER>No calendars are currently selected.</CENTER>"
var titles = new Array()
var maxLines = 200
var lMatrix = new Array()
lMatrix[0] = 2
lMatrix[1] = 3
lMatrix[2] = 4
lMatrix[3] = 5
lMatrix[4] = 6
lMatrix[5] = 7
lMatrix[6] = 8
lMatrix[7] = 9
lMatrix[8] = 0
lMatrix[9] = 1
lMatrix[10] = 12
lMatrix[11] = 13
lMatrix[12] = 14
lMatrix[13] = 15
lMatrix[14] = 16
lMatrix[15] = 18
lMatrix[16] = 17
lMatrix[17] = 19
lMatrix[18] = 10
lMatrix[19] = 11
cBill[0] = ""
cBill[10] = ""
ctBill[0] = ""
ctBill[10] = ""
titles[0] = "&nbsp;&nbsp;Display Board"
titles[1] = "&nbsp;&nbsp;Concurrence"
titles[2] = "&nbsp;&nbsp;Consent"
titles[3] = "&nbsp;&nbsp;Time Certain"
titles[4] = "&nbsp;&nbsp;3rd Reading"
titles[5] = "&nbsp;&nbsp;Senate Bills"
titles[8] = "&nbsp;&nbsp;House Video"
titles[10] = "&nbsp;&nbsp;Display Board"
titles[11] = "&nbsp;&nbsp;Concurrence"
titles[12] = "&nbsp;&nbsp;Consent"
titles[13] = "&nbsp;&nbsp;Time Certain"
titles[14] = "&nbsp;&nbsp;2nd Reading"
titles[15] = "&nbsp;&nbsp;3rd Reading"
titles[16] = "&nbsp;&nbsp;Tabled on 2nd"
titles[17] = "&nbsp;&nbsp;Tabled on 3rd"
titles[18] = "&nbsp;&nbsp;Senate Video"
var myYellow = "#FFFF00"
var myGreen = "#00FF00"
var myBlue = "#FFFFFF"
var myRed = "#FF3333"
var myCyan = "#66FFFF"
var myWhite = "#FFFFFF"
var lookupAddress = "http://www.le.utah.gov/asp/roster/leglookup.asp?irc=true&house="
//var billAddress = "http://www.le.utah.gov/jsp/dbill/dbill.jsp?bill="
var billAddress = "/DynaBill/dbill.jsp?bill="
var tAttorney = ""
var tLegislator = ""
var tFiscalAnalyst = ""
var sVid = false
var hVid = false
var sVote = false
var hVote = false
var ActSen = 0
var ActHou = 0
var autos = new Array()
autos[0] = false
autos[1] = false
autos[2] = false
autos[3] = false
autos[4] = false
autos[5] = false
var hidList = new Array()
var url = "/FloorCalendars/DisServ8?cals="
var sp = -1

function changeColor()
{
	colorVal = true
	colorNum = document.forms[0].changecolor.selectedIndex
	if(document.forms[0].changecolor.selectedIndex == 0)
		colorVal = false
	for(x=0; x<6; x++)
		changeOneColor(x)
	changeOneColor(9)
	for(x=10; x<18; x++)
		changeOneColor(x)
	changeOneColor(19)
	if(colorVal)
	{
		myYellow = "#FFFF00"
		myGreen = "#00FF00"
		myBlue = "#FFFFFF"
		myRed = "#FF3333"
		myCyan = "#66FFFF"
		myWhite = "#FFFFFF"
	}
	else
	{
		myYellow = "#CC9900"
		myGreen = "#009900"
		myBlue = "#FFFFFF"
		myRed = "#FF0000"
		myCyan = "#339999"
		myWhite = "#7F7F7F"
	}
	if(!isLoading) updateDisplay()
}

function changeOneColor(index)
{
	obj = document.getElementById("dt" + lMatrix[index])
	if(colorVal)
	{
		if(colorNum==1)
			obj.style.background = "#6F6F6F"
		else if(colorNum==2)
			obj.style.background = "#000000"
		else if(colorNum==3)
			obj.style.background = "#00006F"
		else if(colorNum==4)
			obj.style.background = "#6F0000"
		else if(colorNum==5)
			obj.style.background = "#006F00"
		else if(colorNum==6)
			obj.style.background = "#6F6F00"
		else if(colorNum==7)
			obj.style.background = "#6F006F"
		else if(colorNum==8)
			obj.style.background = "#006F6F"
		obj.style.color = "#FFFFFF"
	}
	else
	{
		obj.style.background = "#FFFFFF"
		obj.style.color = "#000000"
	}
	colorStr = obj.style.background
}

function changeML()
{
	maxLines = document.forms[0].mLines.options[document.forms[0].mLines.selectedIndex].value - 0
	for(ch = 0; ch < 20; ch++) sOff[ch] = 0
	updateDisplay()
}

function changeFont()
{
	fSize = document.forms[0].fontSize.options[document.forms[0].fontSize.selectedIndex].value
	for(x=0; x<6; x++)
		changeOneFont(x)
	changeOneFont(9)
	for(x=10; x<18; x++)
		changeOneFont(x)
	changeOneFont(19)
	if(useTables)
	{
		updateDisplay()
		return
	}
	if(cShow[9])
	{
		txtObj = document.getElementById("dt" + lMatrix[9])
		txtObj.innerHTML = processBills(9)			
	}
	if(cShow[19])
	{
		txtObj = document.getElementById("dt" + lMatrix[19])
		txtObj.innerHTML = processBills(19)			
	}
}

function changeOneFont(index)
{
	obj = document.getElementById("dt" + lMatrix[index])
	obj.style.fontSize = fSize + "px"
}

function setVSize()
{
	vSize = document.forms[0].vsize.options[document.forms[0].vsize.selectedIndex].value
	resizePlayer()
}

function resizePlayer()
{
	mplayer = null
	pHouse = 0
	if(document.forms[0].c8.checked) mplayer = document.mplayer8
	else if(document.forms[0].c18.checked)
	{
		mplayer = document.mplayer18
		pHouse = 1
	}
	
	if(mplayer!=null)
	{
		mplayer.height = vSize
		mplayer.width = vSize*4/3
	}
}

function toggleAuto(index, doChange)
{
	obj = eval("document.forms[0].auto" + index)
	if(doChange) obj.checked = !obj.checked
	autos[index] = obj.checked
	if(obj.checked) processStatus(oldStatus)
}

function toggleTable(doCheck)
{
	checkObj = document.forms[0].tbl
	if(doCheck) checkObj.checked = !checkObj.checked

	if(!checkObj.checked)
		useTables = false
	else
		useTables = true
		
	if(!useTables)
		for(x=0; x<20; x++)
			changeOneWrap(x)
	updateDisplay()
}

function toggleWrap(doCheck)
{
	checkObj = document.forms[0].twt
	if(doCheck) checkObj.checked = !checkObj.checked

	if(!checkObj.checked)
		doWrap = false
	else
		doWrap = true
	if(useTables)
		updateDisplay()
	else
		for(x=0; x<20; x++)
			changeOneWrap(x)
}

function changeOneWrap(index)
{
	obj = document.getElementById("dt" + lMatrix[index])
	if(doWrap)
	{
		obj.style.whiteSpace = ""
	}
	else
		obj.style.whiteSpace = "nowrap"
}

function addAction(index, doCheck)
{
	if(index==9||index==19) return
	checkObj = eval("document.forms[0].c" + index)
	if(doCheck) checkObj.checked = !checkObj.checked

	if(!checkObj.checked)
	{
		cShow[index] = false
		panelObj = document.getElementById("d" + lMatrix[index])
		panelObj.innerHTML = ""	
		panelObj.style.display = "none"
		txtObj = document.getElementById("dt" + lMatrix[index])
		txtObj.innerHTML = ""
		txtObj.style.display = "none"
	}
	else
	{
		cShow[index] = true
		setOneCal(index)
		if(!isLoading) requestData(true)
	}
	doResize()
}

function clearOneCal(index, cCheck)
{
	if(index==9||index==19) return
	panelObj = document.getElementById("d" + lMatrix[index])
	if(cCheck)
	{
		checkObj = eval("document.forms[0].c" + index)
		checkObj.checked = false
	}
	panelObj.innerHTML = ""
	panelObj.style.display = "none"
	txtObj = document.getElementById("dt" + lMatrix[index])
	txtObj.innerHTML = ""
	txtObj.style.display = "none"
}

function allCals()
{
	var billList = ""
		
	// Create the list of bills to track
	for(x = 0; x < parent.trackList.length; x++)
	{
		if(x > 0) billList += "|"
		billList += parent.trackList[x];
	}
	newWin = window.open("nallcals.jsp?billlist=" + billList + "&leg=" + tLegislator.replace(" ","_") + "&fa=" + tFiscalAnalyst + "&att=" + tAttorney + "&tfiscal=" + tFiscalBills)
	newWin.focus()
}

function changeList(cList)
{
	obj = document.getElementById("lc" + cList)
	newVal = obj.options[obj.selectedIndex].value
	hidList[cList] = newVal
	sOff[cList] = 0
	listObj = document.getElementById("dt" + lMatrix[cList])
	listObj.innerHTML = processBills(cList)	
	//fixScroll(cList)
}
/*
function scrollItem(mIndex, amount)
{
	sOff[mIndex] += amount
	if(amount<0) moveUp = true
	if(sOff[mIndex]<=0) sOff[mIndex] = 0
	if(sOff[mIndex]>=hCount[mIndex]) sOff[mIndex] = hCount[mIndex]
	setOneCal(mIndex)
	moveUp = false
}

function fixScroll(sIndex)
{
	uStyle = ""
	dStyle = ""
	if(sOff[sIndex]>=hCount[sIndex]) sOff[sIndex] = hCount[sIndex]//test
	if(sOff[sIndex]<=0) uStyle = "none"
	else uStyle = ""
	if(sOff[sIndex]>=hCount[sIndex]) dStyle = "none"
	else dStyle = ""
	siu = document.getElementById("sbu" + sIndex)
	if(siu) siu.style.display = uStyle
	sid = document.getElementById("sbd" + sIndex)
	if(sid) sid.style.display = dStyle
}*/

function moveItem(mIndex,upDown)
{
	cPos = lMatrix[mIndex]
	lOff = 0
	mItem = -1
	mLoc = 0
	if(mIndex>9) lOff = 10
	if(upDown==0)
	{
		if(lMatrix[mIndex]<=lOff) return
		for(mx=lOff; mx<(lOff+10); mx++)
			if(lMatrix[mx]<cPos&&cShow[mx]&&lMatrix[mx]>mItem)
			{
				mItem = lMatrix[mx]
				mLoc = mx
			}
	}
	else
	{
		mItem = 21
		if(lMatrix[mIndex]>=lOff+10) return
		for(mx=lOff; mx<(lOff+10); mx++)
			if(lMatrix[mx]>cPos&&cShow[mx]&&lMatrix[mx]<mItem)
			{
				mItem = lMatrix[mx]
				mLoc = mx
			}
	}
	if(mItem<0||mItem>19) return
	clearOneCal(mLoc,false)
	clearOneCal(mIndex,false)
	lMatrix[mIndex] = mItem
	lMatrix[mLoc] = cPos
	setOneCal(mLoc)
	setOneCal(mIndex)
}

function changeMouse(e, oType)
{
	if(oType==1) document.getElementById("dTable").style.cursor = 'e-resize'
	else if(sp<1) document.getElementById("dTable").style.cursor = 'default'
	if(document.selection) document.selection.empty()
	else document.getElementById("cenCol").focus()
}

function getStartPoint(e)
{
	sp = e.clientX
}

function getEndPoint(e)
{
	var ep = e.clientX
	if(sp>0)
	{
		tWidth = 0	
		if(document.all) tWidth = document.body.clientWidth
		else tWidth = window.innerWidth
		mWidth = 16
		if(oVisible) mWidth = 180
		tWidth -= mWidth
		pMove = (ep-sp)/tWidth*100
		cPer += pMove
		if(cPer>99) cPer = 99
		else if(cPer<1) cPer = 1
		cPerStr = cPer + "%"
		c2PerStr = (100-cPer-1) + "%"
		mt = document.getElementById("dTable")
		mt.rows[0].cells[0].width = cPerStr
		mt.rows[0].cells[1].width = "16"
		mt.rows[0].cells[2].width = c2PerStr
		document.getElementById("cenCol").focus()
	}
	sp = -1
}

function setOneCal(index)
{
	if(index==9||index==19) return
	panelObj = document.getElementById("d" + lMatrix[index])
	panelObj.style.display = ""

	cal = index
	h = "h"
	oVideo = 18
	house = 0
	pList = ""
	if((cal>13)&&(cal<18))
	{
		pList = " <SELECT id=\"lc" + index + "\" onChange=\"changeList(" + index + ")\"><OPTION value=\"0\""
		if(hidList[cal]==0) pList += " SELECTED"
		pList += ">All Bills</OPTION><OPTION value=\"1\" STYLE=\"background-color: #99CCFF\""
		if(hidList[cal]==1) pList += " SELECTED"
		pList += ">Senate Bills</OPTION><OPTION value=\"2\" STYLE=\"background-color: #FFCCCC\""
		if(hidList[cal]==2) pList += " SELECTED"
		pList += ">House Bills</OPTION></SELECT>"
	}
	if(cal > 9)
	{
		cal -= 10
		house = 1
		h = "s"
		oVideo = 8
	}
	if(cal>0&&cal<8) pList = "<FONT face=\"Arial\" size=-1> - <A HREF=\"javascript:viewList(" + house + "," + cal + ")\" class=clink>Printable List</A>" + pList + "</FONT>"
	if(cal!=8)
	{
		panelObj.innerHTML = "<HR><A HREF=\"javascript:addAction('" + index + "',true)\"><IMG src=\"images/minus.gif\"border=0 align=left></A><A HREF=\"javascript:moveItem(" + index + ",0)\"><IMG SRC=\"images/up.gif\" border=0 align=right></A><A HREF=\"javascript:moveItem(" + index + ",1)\"><IMG SRC=\"images/down.gif\" border=0 align=right></A><B>" + titles[index] + "</B>" + pList
		txtObj = document.getElementById("dt" + lMatrix[index])
		txtObj.style.display = ""
		txtObj.innerHTML = processBills(index)
		txtObj.style.fontSize = fSize + "px"
		txtObj.style.borderStyle='ridge'
		txtObj.style.borderColor='gold'
		txtObj.style.borderWidth=4
		if(colorVal)
		{
			//txtObj.style.background = "#000000"
			txtObj.style.color = "#FFFFFF"
		}
		else
		{
			//txtObj.style.background = "#FFFFFF"
			txtObj.style.color = "#000000"
		}
		txtObj.style.background = colorStr
	}
	else
	{
		vHeight = vSize
		vCheck = eval("document.forms[0].c" + oVideo)
		if(vCheck.checked)
		{
			clearOneCal(oVideo,true)
			setTimeout("setOneCal(" + index + ")",500)
		}
		else
		{
			vh = vSize
			vw = vh*4/3
			panelObj.innerHTML = "<HR><A HREF=\"javascript:addAction('" + index + "',true)\"><IMG src=\"images/minus.gif\"border=0 align=left></A><A HREF=\"javascript:moveItem(" + index + ",0)\"><IMG SRC=\"images/up.gif\" border=0 align=right></A><A HREF=\"javascript:moveItem(" + index + ",1)\"><IMG SRC=\"images/down.gif\" border=0 align=right></A><B>" + titles[index] + "</B> -&nbsp;<FONT face=\"Arial\" size=-1><A HREF=\"javascript:doPlay(" + index + ")\" class=clink><IMG src=\"images/play.gif\" border=0>&nbsp;Play</A>&nbsp;&nbsp;<A HREF=\"javascript:doStop(" + index + ")\" class=clink><IMG src=\"images/stop.gif\" border=0>&nbsp;Stop</A>&nbsp;&nbsp;</FONT><BR><EMBED  NAME=mplayer" + index + " SRC=\"rtsp://ra.le.state.ut.us:554/broadcast/room" + h + "vid.rm\" TYPE=\"audio/x-pn-realaudio-plugin\" WIDTH=\"" + vw + "\" HEIGHT=\"" + vh + "\" CONTROLS=ImageWindow BACKGROUNDCOLOR=white MAINTAINASPECT=true >"
			panelObj.innerHTML += "<EMBED  NAME=pvolume" + index + " TYPE=\"audio/x-pn-realaudio-plugin\" WIDTH=\"20\" HEIGHT=\"100\" CONTROLS=VolumeSlider CONSOLE=one >"
			setTimeout("delayPlay(" + index + ")",1000)
		}
	}
	//fixScroll(index)
}

function allHouse()
{
	var harr = new Array()
	for(hc = 0; hc < 9; hc++) 
	{
		if(hc<6||hc>7)
		{
			checkObj = eval("document.forms[0].c" + hc)
			harr[hc] = checkObj.checked
			checkObj.checked = true
		}
		else harr[hc] = true
	}

	for(hc = 0; hc < 9; hc++) 
	{
		if(!harr[hc]) addAction(hc, false)
	}
	doResize()
} 

function noHouse()
{
	for(x = 0; x < 9; x++) 
	{
		if(x<6||x>7) clearOneCal(x,true)
	}
	doResize()
}

function allSenate()
{
	var sarr = new Array()
	for(sc = 10; sc < 19; sc++) 
	{
		checkObj = eval("document.forms[0].c" + sc)
		sarr[sc] = checkObj.checked
		checkObj.checked = true
	}
	for(sc = 10; sc < 19; sc++) 
	{
		if(!sarr[sc]) addAction(sc, false)
	}
	doResize()
}

function noSenate()
{
	for(x = 10; x < 19; x++) 
		clearOneCal(x,true)
	doResize()
}

function delayPlay(index)
{
	vObj = eval("document.mplayer" + index)
	if(vObj!=null) vObj.DoPlay()
}

function doPlay(index)
{
	vObj = eval("document.mplayer" + index)
	if(vObj!=null) vObj.DoPlay()
}

function doStop(index)
{
	vObj = eval("document.mplayer" + index)
	if(vObj!=null) vObj.DoStop()
}

function findBill()
{
	var billLoc = billAddress
	var billNumber = ""		
	billNumber = document.forms[0].inputBill.value.toUpperCase()
		
	if(billNumber == "") return
		
	var isHouseBill = true
	var isSub = false
	var subChar = ""
	var stringLoc = 0
	var sBeg = ""
	var sEnd = ""
		
	// remove spaces
	var spaceLoc = billNumber.indexOf(" ")
	while(spaceLoc > -1)
	{
		var beg = ""
		var end = ""
			
		beg = billNumber.slice(0,spaceLoc)
		end = billNumber.slice(spaceLoc+1, billNumber.length)
		billNumber = beg + end
		spaceLoc = billNumber.indexOf(" ")
	}
		
	if(billNumber.length < 3)
	{
		gotoPage("search.jsp?String=" + document.form4.inputBill.value)
		return
	}
		
	// check for substitute bill
	if((billNumber.charAt(0) >= '0')&&(billNumber.charAt(0) <= '9'))
	{
		isSub = true
		subChar = billNumber.charAt(0)
		if((billNumber.charAt(1) >= '0')&&(billNumber.charAt(1) <= '9'))
			subChar += billNumber.charAt(1)
	}
	else if((billNumber.charAt(1) >= '0')&&(billNumber.charAt(1) <= '9'))
	{
		isSub = true
		subChar = billNumber.charAt(1)
		if((billNumber.charAt(2) >= '0')&&(billNumber.charAt(2) <= '9'))
			subChar += billNumber.charAt(2)
	}
		
	// check for substitute at end of number
	else if((billNumber.length > 4)&&(billNumber.charAt(billNumber.length-2)=='S')&&(billNumber.charAt(billNumber.length-1) >= '0')&&(billNumber.charAt(billNumber.length-1) <= '9'))
	{
		isSub = true
		subChar = billNumber.charAt(billNumber.length-1)
		billNumber = billNumber.slice(0,-2)
	}
		
	// check for substitute at end of number
	else if((billNumber.length > 4)&&(billNumber.charAt(billNumber.length-3)=='S')&&(billNumber.charAt(billNumber.length-1) >= '0')&&(billNumber.charAt(billNumber.length-1) <= '9'))
	{
		isSub = true
		subChar = billNumber.charAt(billNumber.length-2)
		subChar += billNumber.charAt(billNumber.length-1)
		billNumber = billNumber.slice(0,-3)
	}
		
	if((stringLoc = billNumber.indexOf("HB"))>-1)
	{
		sBeg = "HB"
		sEnd = billNumber.slice(stringLoc + 2, billNumber.length)
	}
	else if((stringLoc = billNumber.indexOf("HCR"))>-1)
	{
		sBeg = "HCR"
		sEnd = billNumber.slice(stringLoc + 3, billNumber.length)
	}
	else if((stringLoc = billNumber.indexOf("HJR"))>-1)
	{
		sBeg = "HJR"
		sEnd = billNumber.slice(stringLoc + 3, billNumber.length)
	}
	else if((stringLoc = billNumber.indexOf("HR"))>-1)
	{
		sBeg = "HR"
		sEnd = billNumber.slice(stringLoc + 2, billNumber.length)
	}
	else if((stringLoc = billNumber.indexOf("SB"))>-1)
	{
		sBeg = "SB"
		sEnd = billNumber.slice(stringLoc + 2, billNumber.length)
		isHouseBill = false
	}
	else if((stringLoc = billNumber.indexOf("SCR"))>-1)
	{
		sBeg = "SCR"
		sEnd = billNumber.slice(stringLoc + 3, billNumber.length)
		isHouseBill = false
	}
	else if((stringLoc = billNumber.indexOf("SJR"))>-1)
	{
		sBeg = "SJR"
		sEnd = billNumber.slice(stringLoc + 3, billNumber.length)
		isHouseBill = false
	}
	else if((stringLoc = billNumber.indexOf("SR"))>-1)
	{
		sBeg = "SR"
		sEnd = billNumber.slice(stringLoc + 2, billNumber.length)
		isHouseBill = false
	}
	else
	{
		var newPage = "search.jsp?String="
		var searchString
		searchString = document.forms[0].inputBill.value
		newPage += searchString.replace(/ /g, "%20")
		gotoPage(newPage)
		return
	}
		
	var len = sBeg.length + sEnd.length
	billNumber = sBeg
	for(x = len; x < 6; x++)
		billNumber += "0"
	billNumber += sEnd
		
	billNumber = billLoc + billNumber
	if(isSub)
	{
		billNumber += "S"
		if(subChar.length < 2) billNumber += "0"
		billNumber += subChar
	}
	gotoPage(billNumber)
}

function viewList(h,c)
{
	var billList = ""
		
	// Create the list of bills to track
	for(x = 0; x < parent.trackList.length; x++)
	{
		if(x > 0) billList += "|"
		billList += parent.trackList[x];
	}
	newWin = window.open("nallcals.jsp?house=" + h + "&cal=" + c + "&billlist=" + billList + "&leg=" + tLegislator.replace(" ","_") + "&fa=" + tFiscalAnalyst + "&att=" + tAttorney + "&tfiscal=" + tFiscalBills)
	newWin.focus()
}

function doResize()
{
	col1 = 0
	col2 = 0
	for(x = 0; x < 10; x++)
	{
		if(x==6||x==7||x==9) continue
		checkObj = eval("document.forms[0].c" + x)
		if(checkObj.checked) col1 = 1
	}
	for(x = 10; x < 20; x++)
	{
		if(x==19) continue
		checkObj = eval("document.forms[0].c" + x)
		if(checkObj.checked) col2 = 1
	}
	colCount = col1 + col2
	if(col1==1) document.getElementById("t1").innerHTML = "<CENTER><B><A HREF=\"javascript:noHouse()\"><img src=\"images/minus.gif\" border=0></A>&nbsp;&nbsp;HOUSE</B></CENTER>"
	else document.getElementById("t1").innerHTML = ""
	if(col2==1) document.getElementById("t2").innerHTML = "<CENTER><B><A HREF=\"javascript:noSenate()\"><img src=\"images/minus.gif\" border=0></A>&nbsp;&nbsp;SENATE</B></CENTER>"
	else document.getElementById("t2").innerHTML = ""
	if(colCount<1)
		document.getElementById("t0").innerHTML = noCalText
	else 
		document.getElementById("t0").innerHTML = ""
		
	mt = document.getElementById("dTable")
	if(colCount==0)
	{
		mt.rows[0].cells[0].width = "1"
		mt.rows[0].cells[2].width = "1"
		cPer = 50
	}
	else if(colCount==1)
	{
		if(col1==1)
		{		
			mt.rows[0].cells[0].width = "100%"
			mt.rows[0].cells[2].width = "1"
			cPer = 100
		}
		else
		{
			mt.rows[0].cells[0].width = "1"
			mt.rows[0].cells[2].width = "100%"
			cPer = 0
		}
	}
	else
	{
		mt.rows[0].cells[0].width = "49%"
		mt.rows[0].cells[2].width = "49%"
		cPer = 50
	}	
	mt.rows[0].cells[1].width = "16"
}

function toggleOptions()
{
	oVisible = !oVisible
	optionObj = document.getElementById("disOptions")
	if(oVisible)
	{
		optionObj.style.display = ""
		document.pImage.src = "images/shim180.gif"
	}
	else
	{	
		optionObj.style.display = "none"
		document.pImage.src = "images/plus.gif"
	}
}


function toggleMenu(optionObj, imgObj)
{
	if(optionObj.style.display == "none")
	{
		optionObj.style.display = ""
		imgObj.src = "images/minus.gif"
	}
	else
	{	
		optionObj.style.display = "none"
		imgObj.src = "images/plus.gif"
	}
}

function loadSetup()
{
	for(x=0;x<20;x++)
	{
		cShow[x] = false
		hArr[x] = 1
		mArr[x] = 1
		sArr[x] = 1
		cText[x] = ""
		hidList[x] = 0
		sOff[x] = 0
		hCount[x] = 0
	}	
	theCookie = document.cookie.split("; ")
	for(i=0; i<theCookie.length; i++)
	{
		par = theCookie[i].split("=")[0]
		val = theCookie[i].split("=")[1]
		if(par == "leg")
		{
			tLegislator = val
			if(tLegislator==null) tLegislator = ""
			selectOption(document.forms[0].legTrack, tLegislator)
			tLegislator = tLegislator.replace(/_/g, " ")
		}
		else if(par == "att")
		{
			tAttorney = val
			selectOption(document.forms[0].atTrack, tAttorney)
			
		}
		else if(par == "fa")
		{
			tFiscalAnalyst = val
			selectOption(document.forms[0].faTrack, tFiscalAnalyst)
		}
		else if(par == "fsize")
		{
			fSize = val
			selectOption(document.forms[0].fontSize, fSize)
		}
		else if(par == "mlines")
		{
			maxLines = val
			selectOption(document.forms[0].mLines, maxLines)
		}
		else if(par == "discols")
		{
			dCols = val
			selectOption(document.forms[0].discols, dCols)
		}
		else if(par == "dowrap")
		{
			if(val=="0")
			{
				doWrap = false
				document.forms[0].twt.checked = false
			}
			else
			{
				doWrap = true
				document.forms[0].twt.checked = true
			}
			toggleWrap(false)
		}
		else if(par == "dobold")
		{
			if(val=="0")
			{
				isBold = false
				document.forms[0].tbt.checked = false
			}
			else
			{
				isBold = true
				document.forms[0].tbt.checked = true
			}
			toggleBold(false)
		}
		else if(par == "dotable")
		{
			if(val=="0")
			{
				useTables = false
				document.forms[0].tbl.checked = false
			}
			else
			{
				useTables = true
				document.forms[0].tbl.checked = true
			}
			toggleTable(false)
		}
		else if(par == "autohide")
		{
			if(val=="0")
			{
				autoHide = false
				document.forms[0].tah.checked = false
			}
			else
			{
				autoHide = true
				document.forms[0].tah.checked = true
			}
			toggleAutoHide(false)
		}
		else if(par == "color")
		{
			if(val=="0") colorVal = false
			else colorVal = true
			colorNum = val
			selectOption(document.forms[0].changecolor, val)
			changeColor()
		}
		else if(par == "dshort")
		{
			if(val=="0") document.forms[0].dst.checked = false
			else document.forms[0].dst.checked = true
			showShort = val
		}
		else if(par == "dspon")
		{
			if(val=="0") document.forms[0].ds.checked = false
			else document.forms[0].ds.checked = true
			showSponsors = val
		}
		else if(par == "dfloor")
		{
			if(val=="0") document.forms[0].dfs.checked = false
			else document.forms[0].dfs.checked = true
			showFloor = val
		}
		else if(par == "datt")
		{
			if(val=="0") document.forms[0].da.checked = false
			else document.forms[0].da.checked = true
			showAt = val
		}
		else if(par == "vsize")
		{
			vSize = val
			selectOption(document.forms[0].vsize, vSize)
		}
		else if(par == "dfa")
		{
			if(val=="0") document.forms[0].dfa.checked = false
			else document.forms[0].dfa.checked = true
			showFA = val
		}
		else if(par == "tn")
		{
			if(val=="0") document.forms[0].tn.checked = false
			else 
			{
				document.forms[0].tn.checked = true
				doNotify = true
			}
		}
		else if(par == "tf")
		{
			if(val=="0") document.forms[0].tf.checked = false
			else document.forms[0].tf.checked = true
			tFiscalBills = val
		}
		else if(par == "auto")
		{
			for(x=0; x<val.length; x++)
			{
				if(x==2||x==3) continue;
				if(x>5) break;
				if(val.charAt(x)=='1')
				{
					autos[x] = true
					obj = eval("document.forms[0].auto" + x)
					if(obj) obj.checked = true
				}
			}
		}
		else if(par == "dis")
		{
			calVal = val
		}
		else if(par=="Bills")
		{
			if(val)
			{
				for(bsp = 0; bsp < val.split("|").length; bsp++)
				{
					trackList[bsp] = val.split("|")[bsp];
				}
			}
		}
	}
	loadCals()
	doResize()
	requestData(true)
	isLoading = false
	setTimeout("updateView()",1000)
}

function saveSetup()
{
	var newCookie = ""
	expireDate = new Date
	expireDate.setMonth(expireDate.getMonth()+2)
	
	newCookie = ""
	for(x = 0; x<20; x++)
		if(x!=6&&x!=7&x!=9&x!=19)
		{
			obj = eval("document.forms[0].c" + x)
			if(obj&&obj.checked) newCookie += "1"
			else newCookie += "0"
		}
		else newCookie += "0"
	newCookie = "dis=" + newCookie
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
		
	newCookie = "Bills="
	for(x = 0; x < trackList.length; x++)
	{
		newCookie += trackList[x];
		if(x < (trackList.length - 1))
			newCookie += "|";
	}
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie

	newCookie = "leg="
	newCookie += tLegislator.replace(/\s/g, "_")
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "att="
	newCookie += tAttorney
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "fa="
	newCookie += tFiscalAnalyst
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "vsize="
	newCookie += vSize
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "color="
	newCookie += document.forms[0].changecolor.options[document.forms[0].changecolor.selectedIndex].value
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "fsize="
	newCookie += document.forms[0].fontSize.options[document.forms[0].fontSize.selectedIndex].value
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "mlines="
	newCookie += document.forms[0].mLines.options[document.forms[0].mLines.selectedIndex].value
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "discols="
	newCookie += document.forms[0].discols.options[document.forms[0].discols.selectedIndex].value
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "dowrap="
	if(document.forms[0].twt.checked) newCookie += "1"
	else  newCookie += "0"
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "dobold="
	if(document.forms[0].tbt.checked) newCookie += "1"
	else  newCookie += "0"
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "dotable="
	if(document.forms[0].tbl.checked) newCookie += "1"
	else  newCookie += "0"
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "autohide="
	if(document.forms[0].tah.checked) newCookie += "1"
	else  newCookie += "0"
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "dshort="
	if(document.forms[0].dst.checked) newCookie += "1"
	else  newCookie += "0"
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "dspon="
	if(document.forms[0].ds.checked) newCookie += "1"
	else  newCookie += "0"
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "dfloor="
	if(document.forms[0].dfs.checked) newCookie += "1"
	else  newCookie += "0"
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "datt="
	if(document.forms[0].da.checked) newCookie += "1"
	else  newCookie += "0"
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "dfa="
	if(document.forms[0].dfa.checked) newCookie += "1"
	else  newCookie += "0"
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "tn="
	if(document.forms[0].tn.checked) newCookie += "1"
	else  newCookie += "0"
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "tf="
	if(document.forms[0].tf.checked) newCookie += "1"
	else  newCookie += "0"
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
	
	newCookie = "auto="
	for(x=0;x<6;x++)
	{
		if(x==2||x==3) continue
		obj = eval("document.forms[0].auto" + x)
		if(obj&&obj.checked) newCookie += "1"
		else newCookie += "0"
	}
	newCookie += ";expires="
	newCookie += expireDate.toGMTString()
	document.cookie = newCookie
}

function loadCals()
{
	for(v=0; v<calVal.length; v++)
	{
		if(v>19) break;
		if((calVal.charAt(v)=='1')&&(v!=6)&&(v!=7))
		{
			obj = eval("document.forms[0].c" + v)
			obj.checked = true
			addAction(v,false)
		}
	}
}

function selectOption(obj, value)
{
	for(x=0; x<obj.options.length; x++)
		if(obj.options[x].value==value) 
		{
			obj.selectedIndex=x
			break
		}
}

function requestData(doAll)
{
	if(waitCount>5)
	{
		waitCount = 0
		errStr = "<BR><FONT face=\"Arial\" size=+1 color=red>Server not responding</FONT>"
		updateStatus()
	}
	waitCount++
	if((waitCount>1)&&(waitCount!=4)) return
	var haveReq = false
	var rTimes = ""
	var tUrl = url
	for(x = 0; x < 20; x++)
	{
		if(x==8||x==18) continue
		if(cShow[x]&&(doAll||x==0||x==10||x==9||x==19))
		{	 
			rTimes += "&h" + x + "=" + hArr[x] + "&m" + x + "=" + mArr[x] + "&s" + x + "=" + sArr[x]
			tUrl += "," + x
			haveReq = true
		}
	}
	if(!haveReq)
	{
		rTimes = "statonly"
		tUrl = url
	}
	else tUrl += ","
	http_request = false;

    if (window.XMLHttpRequest) 
	{ 
		http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) 
		{
			http_request.overrideMimeType('text/xml');
        }
    } 
	else if (window.ActiveXObject) 
	{
        try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } 
		catch (e) 
		{
            try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } 
			catch (e) 
			{}
        }
	}

    if (!http_request) 
	{
        errStr = 'Giving up :( Cannot create an XMLHTTP instance)'
		updateStatus()
        return;
    }
	http_request.onreadystatechange = waitForResponse;
	http_request.open('GET', tUrl + rTimes, true);
    http_request.send(null);
}

function waitForResponse()
{
	if (http_request.readyState == 4) 
	{		
		waitCount = 0
        if (http_request.status == 200) 
		{
			updateStatus()
			errStr = ""
			test = http_request.responseText;
        } 
		else 
		{
			if(isIE&&http_request.status == 12152)
				errStr = "<FONT face=\"Arial\" color=red size=-2>Error parsing server response</FONT>";
			else
				errStr = "<FONT face=\"Arial\" color=red size=+2>Error requesting data.  The status is: " + http_request.status + "</FONT>";
			updateStatus()
			return
        }
    }
	else return
	
	var buffer = ""
	index = test.indexOf("<r>")+3
	if(index>-1)
	{
		buffer = test.substring(index,index+6)
		if(buffer!=oldStatus) processStatus(buffer)
	}
	
	sa = test.split(/<\/CAL>/)
	z = 0
	for(x = 0; x < sa.length; x++)
	{
		for(y = z; y < cText.length; y++)
		{
			if(sa[x].indexOf("seq=\"" + y + "\"")>0)
			{
				buffer = sa[x].substr(sa[x].indexOf(">")+1)
				h = buffer.substr(buffer.indexOf("<hr value=")+11,2)
				if(h.indexOf("\"")>0) h = h.substr(0,1)
				m = buffer.substr(buffer.indexOf("<min value=")+12,2)
				if(m.indexOf("\"")>0) m = m.substr(0,1)
				s = buffer.substr(buffer.indexOf("<sec value=")+12,2)
				if(s.indexOf("\"")>0) s = s.substr(0,1)
				if(h!=hArr[y]||m!=mArr[y]||s!=sArr[y])
				{
					hArr[y] = h
					mArr[y] = m
					sArr[y] = s
				}
				z = y + 1
				cText[y] = processLine(buffer)
				if(y==0||y==10)
				{
					bPos = buffer.indexOf("bill value=\"")
					if(bPos>0)
					{
						cBill[y] = buffer.substr(bPos+12,6)
					}
					else cBill[y] = ""
				}
				
				if(cShow[y])
				{
					txtObj = document.getElementById("dt" + lMatrix[y])
					var spVar = 0
					if(document.getElementById("divScroll" + y)) spVar = document.getElementById("divScroll" + y).scrollTop
					txtObj.innerHTML = processBills(y)	
					if(document.getElementById("divScroll" + y)) document.getElementById("divScroll" + y).scrollTop = spVar
					//fixScroll(y)
				}
				continue
			}
		}
	}
}

function updateDisplay()
{
	for(x = 0; x < 20; x++)
		if(cShow[x])//&&(x!=8)&&(x!=18))
		{
			txtObj = document.getElementById("dt" + lMatrix[x])
			txtObj.innerHTML = processBills(x)	
			//fixScroll(x)		
		}
}

function hiLeg()
{
	tLegislator = document.forms[0].legTrack.options[document.forms[0].legTrack.selectedIndex].value
	tLegislator = tLegislator.replace(/_/g, " ")
	updateDisplay()
}

function hiAt()
{
	tAttorney = document.forms[0].atTrack.options[document.forms[0].atTrack.selectedIndex].value
	updateDisplay()
}

function hiFA()
{
	tFiscalAnalyst = document.forms[0].faTrack.options[document.forms[0].faTrack.selectedIndex].value
	updateDisplay()
}

function processBills(cIndex)
{
	var dType = 1
	var cChar = " "
	var proText = ""
	var mCount = 0
	var tLen = 0
	var conCount = 0
	if(cText[cIndex].length<1) return "<UL></UL>"
	if((cIndex==9)||(cIndex==19)) dType = 2
	if((cIndex==0)||(cIndex==10)) dType = 0
	if(isIE)
	{
		cText[cIndex] = cText[cIndex].replace(/<BR><BR>/g, "<BR> <BR>")
		while(cText[cIndex].indexOf("<BR><BR>")>0)
			cText[cIndex] = cText[cIndex].replace(/<BR><BR>/g, "<BR> <BR>")
	}
	lines = cText[cIndex].split(/<BR>/)
	len1 = lines.length
	if(!isIE) len1--
	var newText = "<OL>"
	if(useTables) newText = "<TABLE width=\"100%\" border=0 cellpadding=1>"
	if(dType==2) newText = "<TABLE width=\"100%\"><TR>"
	else if(dType==0) newText = "<CENTER>"
	
	tLen = len1
	if(dType==1) len1--
	if((len1>maxLines)&&(dType!=0))
	{
		mCount = len1-maxLines
		if(dType!=2&&maxLines==0) len1 = maxLines
	}
	
	if(dType!=2)
	{
		if(hidList[cIndex]==1)
		{
			newText = "<BR><FONT color=\"#9F9F9F\">(House bills are hidden)</FONT>" + newText
			cChar = 'H'
		}
		else if(hidList[cIndex]==2)
		{
			newText = "<BR><FONT color=\"#9F9F9F\">(Senate bills are hidden)</FONT>" + newText
			cChar = 'S'
		}
		//for(l = 0; l < len1; l++)
			//newText += processItem(lines[l],cIndex,dType,cChar)
		si = 0
		if(dType==1)
		{
			si=1			
			newText = processItem(lines[0],cIndex,-1,cChar,0) + newText
		}
		var firstGood = tLen
		var lastGood = -1
		if(moveUp)
		{
			for(ng = si; ng <= sOff[cIndex]+si; ng++)
			{
				sgText = processItem(lines[ng],cIndex,dType,cChar,ng)
				if(sgText!=""&&ng>lastGood) lastGood = ng
			}
			if(lastGood!=-1&&(lastGood-si)<=sOff[cIndex]) sOff[cIndex] = lastGood-si
			else sOff[cIndex]++
		}
		sOff[cIndex] = 0
		for(l = si+sOff[cIndex]; l < tLen; l++)
		{
			//if(conCount>=len1) break
			proText = processItem(lines[l],cIndex,dType,cChar,l)
			if(proText!="") 
			{
				if(l<firstGood-si) firstGood = l
				conCount++
				newText += proText
			}
		}
		if(!moveUp)
		{
			sOff[cIndex] = firstGood-si
			moveUp = false
		}
		if(conCount<len1) mCount+= (len1-conCount)
		sOff[cIndex] = 0
	}
	else
	{
		newText += "<TD colspan=" + dCols + ">"
		newText += "<DIV STYLE=\"font-size: " + fSize + "px; font-style: italic\">" + processItem(lines[0],cIndex,0,cChar,0) + "</DIV></TD></TR><TR>"
		var lCount = 0

		for(l = 1; l < len1; l++)
		{
			if(lCount>=dCols)
			{
				lCount = 0
				newText += "</TR><TR>"
			}
			newText += "<TD>" + processItem(lines[l],cIndex,dType,cChar,0) + "</TD>"
			lCount++
		}

	}
	if(dType==1)
	{
		if(useTables)
			newText += "</TABLE>"	
		else
			newText += "</OL>"	
	}
	else if(dType==2) newText += "</TR></TABLE>"
	else if(dType==0)
	{
		newText += "</CENTER>"
		if(cBill[cIndex].length==6)
		{
			if(isTracked(cBill[cIndex])&&ctBill[cIndex]!=cBill[cIndex]&&doNotify) 
			{
				ctBill[cIndex] = cBill[cIndex]
				aWin = window.open('','alertWin','toolbar=no,scrollbars=no,resizable=no,width=400,height=20')
				aWin.document.write("<HTML><HEAD><TITLE>Bill Notification</TITLE></HEAD><BODY><EMBED src=\"/FloorCalendars/gavel.mp3\" autoplay=\"true\" hidden=\"true\" /><FONT face='Arial' color=red><CENTER><B><BLINK>" + ctBill[cIndex] + " is currently under discussion</BLINK></B></CENTER></FONT></BODY></HTML>")
				aWin.focus()
				setTimeout('aWin.close()',5000)
				//alert(ctBill[cIndex] + " is currently under discussion")
			}
			else ctBill[cIndex] = ""
			newText = "<A HREF=\"javascript:gotoBillPage('" + cBill[cIndex] + "')\" class=\"billLink\">" + newText + "</A>"
		}
	}
	//if(dType==1) newText = "<A HREF=\"javascript:scrollItem(" + cIndex + ",-1)\"><IMG SRC=\"images/up.gif\" border=0 align=right id=\"sbu" + cIndex + "\"></A>" + newText + "<A HREF=\"javascript:scrollItem(" + cIndex + ",1)\"><IMG SRC=\"images/down.gif\" border=0 align=right id=\"sbd" + cIndex + "\"></A>"
	//if(mCount>0) newText += mCount + " hidden line(s)"
	//else newText += "&nbsp;"
	newText += "&nbsp;"
	hCount[cIndex] = mCount
	if(maxLines == 0 || cIndex == 0 || cIndex == 10){
	    return newText
	}
	else {
	    return "<div style=\"overflow:auto; height:" + maxLines + "px; \" id=\"divScroll" + cIndex + "\">" + newText + "</div>"
	}
	
	//return newText 
}

function isTracked(billStr)
{
	for(tlc=0; tlc<trackList.length; tlc++)
		if(billStr==trackList[tlc]) return true
		
	return false
}

function addTrack(addBill)
{
	if(trackList.length>9) return false
	for(tla=0; tla<trackList.length; tla++)
		if(addBill==trackList[tla]) return false
	trackList[trackList.length] = addBill
	updateDisplay()
	return true
}

function clearTrackList()
{
	trackList.length = 0
	updateDisplay()
}

function delTrack(delBill)
{
	for(tld=0; tld<trackList.length; tld++)
		if(delBill==trackList[tld])
		{
			for(tlt=tld; tlt<trackList.length-1; tlt++)
				trackList[tlt]=trackList[tlt+1]
			trackList.length--
			updateDisplay()
			return true
		}
	return false
}

function processItem(inItem, calNum, disType, chChar, liVal)
{
	var uTable = false
	var sMatch = false
	var fsMatch = false
	var isFB = false
	var aMatch = false
	var faMatch = false
	var tBill = false
	var lBuff = ""
	if(isIE)
	{
		abc = inItem.replace(/%%/g, "% %")
		while(abc.indexOf("%%")>0)
			abc = abc.replace(/%%/g, "% %")
		items = abc.split(/%/)
		//if((items[0]==1)||(items[0]==0)) items[0]=""
		//minLen = 10
	}
	else
	{
		items = inItem.split(/%/)
		//minLen = 11
	}
	//items[0]=inItem
	if(inItem.indexOf("%")==0) items[0] = "&nbsp;"
	if(useTables&&disType==1) uTable = true;
	//if((calNum==9)||(calNum==19)) minLen-=9
	//if(items.length<minLen) return "<LI><FONT color=\"" + myRed + "\">Line Error: length=" + items.length + "</FONT></LI>"

	
	if((disType==1)&&(hidList[calNum]>0))
	{
		tStr = items[3] + " "
		if(tStr.indexOf(chChar)==0) return ""
	}
	
	var hic = "1"
	if(!colorVal) hic = "2"
	var fc = myWhite
	if(items[1]=="0") fc = myYellow
	else if(items[1]=="1") fc = myGreen
	else if(items[1]=="2") fc = myRed
	else if(items[1]=="10") fc = myGreen
	else if(items[1]=="12") fc = myRed
	else if(items[1]=="14") fc = myYellow
	else if(items[1]=="20") fc = myRed
	else if(items[1]=="21") fc = myCyan
	
    // hack for making house bills green
    hkStr = items[3] + " "
    if(hkStr.indexOf("S")==0) fc = myRed
    // hack for making senate bills red
    if(hkStr.indexOf("H")==0) fc = myGreen
	// hack for house making circled bills yellow
    //if((items[10]=="1")&&(calNum<10)) fc = myYellow	
    if(items[10]=="1") fc = myYellow	
	
	if(disType==0)
	{
		fc = myYellow
	}
	
	var fStr = "<FONT color=\"" + fc + "\">"
	if(isBold) fStr += "<B>"
	var vStr = ""
	if(disType==2)
	{
		if(items[1]=="1") vStr += "Y "
		else if(items[1]=="2") vStr += "N "
		else vStr += "X "
	}
	var fEnd = "</FONT>"
	if(isBold) fEnd = "</B>" + fEnd
	var tdEnd = "</FONT></FONT></A></TD>"
	var dStr = ""
	var dEnd = ""
	var tfs = 3
	if(fSize==10) tfs=1
	else if(fSize==12) tfs=2
	else if(fSize==14) tfs=2
	else if(fSize==16) tfs=3
	else if(fSize==18) tfs=4
	else if(fSize==20) tfs=4
	else if(fSize==22) tfs=4
	else if(fSize==24) tfs=5
	var wStr = "<TD><FONT size=" + tfs + ">"
	if(!doWrap) wStr = "<TD nowrap><FONT size=" + tfs + ">"
	
	var newItem = items[0]
	if((items.length>2)&&(items[3]!=null)&&(items[3].length>4))
	{
		if(tLegislator!="")
		{
			if(items[5]==tLegislator) sMatch = true
			if(items[6]==tLegislator) fsMatch = true
		}
		if((tFiscalBills==1)&&(items.length>8)&&(items[9]=="1")) isFB = true
		if((tAttorney!="")&&(items.length>6)&&(items[7]==tAttorney)) aMatch = true
		if((tFiscalAnalyst!="")&&(items.length>7)&&(items[8]==tFiscalAnalyst)) faMatch = true
		if((items[3])&&(isTracked(items[3].substring(0,6)))) tBill = true
		
		dEnd = "</DIV>"
		if(sMatch) dStr = "<DIV class=\"sleg" + hic + "\">"
		else if(fsMatch) dStr = "<DIV class=\"fsleg" + hic + "\">"
		else if(isFB) dStr = "<DIV class=\"f" + hic + "\">"
		else if(aMatch||faMatch||tBill) dStr = "<DIV class=\"ot" + hic + "\">"
		else dEnd = ""
		
		wStr += "<A HREF=\"javascript:gotoBillPage('" + items[3] + "')\" class=\"billLink\">" + fStr
		wStr = wStr + dStr
		tdEnd += dEnd 
		
		if(uTable) newItem = wStr + newItem + tdEnd
		if((showSponsors==1)&&(items[5]))
		{
			if(sMatch) lBuff = "<B><U>" + items[5] + "</U></B>"
			else lBuff = items[5]
			
			if(uTable) newItem += wStr + lBuff + tdEnd
			else newItem += " - " + lBuff
		}
		if((showFloor==1)&&(items[6]))
		{
			if(fsMatch) lBuff = "<B><I><U>" + items[6] + "</U></I></B>"
			else lBuff = "<I>" + items[6] + "</I>"
			
			if(uTable) newItem += wStr + lBuff + tdEnd
			else newItem += " - " + lBuff
		}
		else if((showFloor==1)&&(uTable)) newItem += wStr + "&nbsp;" + tdEnd
		if((showAt==1)&&(items[7]))
		{
			if(aMatch) lBuff = "<B><U>" + items[7] + "</U></B>"
			else lBuff = items[7]
			
			if(uTable) newItem += wStr + lBuff + tdEnd
			else newItem += " - " + lBuff
		}
		else if((showAt==1)&&(uTable)) newItem += wStr + "&nbsp;" + tdEnd
		if((showFA==1)&&(items[8]))
		{
			if(faMatch) lBuff = "<B><U>" + items[8] + "</U></B>"
			else lBuff = items[8]
			
			if(uTable) newItem += wStr + lBuff + tdEnd
			else newItem += " - " + lBuff
		}
		else if((showFA==1)&&(uTable)) newItem += wStr + "&nbsp;" + tdEnd
		if((showShort==1)&&(items[4]))
		{
			lBuff = items[4]
			
			if(uTable) newItem += wStr + lBuff + tdEnd
			else newItem += " - " + lBuff
		}
		if(items[2]!=""&&items[2]!=" ")
		{
			lBuff = "<small><I>" + items[2] + "</I></small>"
			
			if(uTable) newItem += wStr + lBuff + tdEnd
			else newItem += " - " + lBuff
		}
		if(!uTable)
		{
			newItem = fStr + newItem + fEnd
			newItem = "<A HREF=\"javascript:gotoBillPage('" + items[3] + "')\" class=\"billLink\">" + newItem + "</A>"
		}
	}
	else
	{
		cSpan = 2
		if(showSponsors==1) cSpan++
		if(showFloor==1) cSpan++
		if(showAt==1) cSpan++
		if(showFA==1) cSpan++
		if(showShort==1) cSpan++
		if(uTable) newItem = "<TD colspan=" + cSpan + "><FONT color=\"" + fc + "\" size=\"" + tfs + "\">" + vStr + newItem + tdEnd
		else newItem = "<FONT color=\"" + fc + "\">" + vStr + newItem + "</FONT>"
	}
	
	if(disType==2)
	{
		lHouse = "H"
		if(calNum==19) lHouse = "S"
		newItem = "<A HREF=\"javascript:gotoPage('" + lookupAddress + lHouse + "&leg=" + items[0].replace(/\s/,"_") + "')\" class=\"billLink\">" + newItem + "</A>"
	}
	if(!uTable) newItem = dStr + newItem + dEnd
	
	if(disType==1)
	{
		if(uTable) newItem = "<TR>" + newItem + "</TR>"
		else newItem = "<LI value=\"" + liVal + "\">" + newItem + "</LI>"
	}
	//else if(disType==0) newItem += "<BR>"
	else if(disType==0) newItem = "<B>" + newItem + "</B><BR>"
	else if(disType==2) newItem = "<DIV STYLE=\"font-size: " + fSize + "px\">" + newItem + "</DIV>"
	return newItem
}

function processLine(nLine)
{
	newStr = nLine.substring(nLine.indexOf("<![CDATA[")+9,nLine.indexOf("]]>"))	
	if(isIE)
	{
		if(newStr.indexOf("<BR>")==0) newStr = " " + newStr
	}
	return newStr
}

function updateView()
{
	if(lCount==0) requestData(true)
	else requestData(false)
	lCount++
	if(lCount>2) lCount = 0
	
	//checkAuto()
	//updateStatus()
	setTimeout("updateView()",1000)
}

function setCols()
{
	dCols = document.forms[0].discols.options[document.forms[0].discols.selectedIndex].value
	txtObj = document.getElementById("dt" + lMatrix[9])
	txtObj.innerHTML = processBills(9)	
	txtObj = document.getElementById("dt" + lMatrix[19])
	txtObj.innerHTML = processBills(19)	
}

function updateStatus()
{
	now = new Date
	vChar = "|"
	switch(cView)
	{
		case 1:
			vChar = "/"
			break;
		case 2:
			vChar = "-"
			break;
		case 3:
			vChar = "\\"
			break;
			
	}
	sText = document.getElementById("s0")
	sText.innerHTML = "<CENTER><FONT face=\"Arial\" size=-2>" + vChar + " " + now + " " + vChar + "</FONT><FONT face=\"Arial\" color=red size=-2><B>" + errStr + "</B></FONT></CENTER>"
	if(++cView>3) cView = 0
}


function toggleShort(doToggle)
{
	if(doToggle)
	{
		if(showShort==1)
		{
			showShort = 0
			document.forms[0].dst.checked = false
		}
		else
		{
			showShort = 1
			document.forms[0].dst.checked = true
		}
	}
	else
	{
		if(document.forms[0].dst.checked) showShort = 1
		else showShort = 0
	}
	updateDisplay()
}


function toggleSponsor(doToggle)
{
	if(doToggle)
	{
		if(showSponsors==1)
		{
			showSponsors = 0
			document.forms[0].ds.checked = false
		}
		else
		{
			showSponsors = 1
			document.forms[0].ds.checked = true
		}
	}
	else
	{
		if(document.forms[0].ds.checked) showSponsors = 1
		else showSponsors = 0
	}
	updateDisplay()
}

function toggleFloor(doToggle)
{
	if(doToggle)
	{
		if(showFloor==1)
		{
			showFloor = 0
			document.forms[0].dfs.checked = false
		}
		else
		{
			showFloor = 1
			document.forms[0].dfs.checked = true
		}
	}
	else
	{
		if(document.forms[0].dfs.checked) showFloor = 1
		else showFloor = 0
	}
	updateDisplay()
}

function toggleAttorney(doToggle)
{
	if(doToggle)
	{
		if(showAt==1)
		{
			showAt = 0
			document.forms[0].da.checked = false
		}
		else
		{
			showAt = 1
			document.forms[0].da.checked = true
		}
	}
	else
	{
		if(document.forms[0].da.checked) showAt = 1
		else showAt = 0
	}
	updateDisplay()
}

function toggleFA(doToggle)
{
	if(doToggle)
	{
		if(showFA==1)
		{
			showFA = 0
			document.forms[0].dfa.checked = false
		}
		else
		{
			showFA = 1
			document.forms[0].dfa.checked = true
		}
	}
	else
	{
		if(document.forms[0].dfa.checked) showFA = 1
		else showFA = 0
	}
	updateDisplay()
}

function toggleFB(doToggle)
{
	if(doToggle)
	{
		if(tFiscalBills==1)
		{
			tFiscalBills = 0
			document.forms[0].tf.checked = false
		}
		else
		{
			tFiscalBills = 1
			document.forms[0].tf.checked = true
		}
	}
	else
	{
		if(document.forms[0].tf.checked) tFiscalBills = 1
		else tFiscalBills = 0
	}
	updateDisplay()
}

function toggleNotify(doToggle)
{
	if(doToggle)
	{
		if(doNotify)
		{
			doNotify = false
			document.forms[0].tn.checked = false
		}
		else
		{
			doNotify = true
			document.forms[0].tn.checked = true
		}
	}
	else
	{
		if(document.forms[0].tf.checked) tFiscalBills = 1
		else tFiscalBills = 0
	}
	updateDisplay()
}
	
function gotoPage(newPage)
{
	newWin = window.open(newPage)
	newWin.focus()
}

function gotoBillPage(lBill)
{
	var extLink = ""
	var bFound = false
	for(dcl=0; dcl<trackList.length; dcl++)
		if(trackList[dcl]==lBill.substring(0,6)) bFound = true
	if(bFound)
		extLink = "&trackadd=false"
	else if(trackList.length<10)
		extLink = "&trackadd=true"
	newWin = window.open(billAddress + lBill + extLink)
	newWin.focus()
}
	
function gotoPageNoFocus(newPage)
{
	newWin = window.open(newPage)
}

function processStatus(newStatus)
{	
	var vOn = false
	if(newStatus.length>5)
	{					
		if(newStatus.charAt(0)=='1')				
		{
			if(!hVid)
			{
				document.forms[0].ai8.src="images/vid.gif"
				hVid = true
			}
			if(autos[0])
			{		
				vOn = true
				if(!document.forms[0].c8.checked)
				{
					skipCount = 5
					addAction(8,true)
				}
			}
		}
		else if(newStatus.charAt(0)=='0')
		{
			if(hVid)
			{
				document.forms[0].ai8.src="images/inactive.gif"
				hVid = false
			}
			if((autos[0])&&(document.forms[0].c8.checked))
			{
				skipCount = 5	
				addAction(8,true)
			}
		}				
								
		if(newStatus.charAt(1)=='1')				
		{
			if(!sVid)
			{
				document.forms[0].ai18.src="images/vid.gif"
				sVid = true
			}
			if((autos[1])&&(!vOn))
			{		
				vOn = true
				if(!document.forms[0].c18.checked)
				{
					skipCount = 5
					addAction(18,true)
				}
			}
		}
		else if(newStatus.charAt(1)=='0')
		{
			if(sVid)
			{
				document.forms[0].ai18.src="images/inactive.gif"
				sVid = false
			}
			if((autos[1])&&(document.forms[0].c18.checked))
			{
				skipCount = 5	
				addAction(18,true)
			}
		}
		if(newStatus.charAt(4)=='0') setActive(true,'0')
		else if((newStatus.charAt(4)>'0')&&(newStatus.charAt(4)<'6'))				
		{
			if(autos[4])
				selOneCal(true,newStatus.charAt(4))
			setActive(true,newStatus.charAt(4))
		}
		if(newStatus.charAt(5)=='0') setActive(false,'0')
		else if((newStatus.charAt(5)>'0')&&(newStatus.charAt(5)<'8'))				
		{
			if(autos[5])
				selOneCal(false,newStatus.charAt(5))
			setActive(false,newStatus.charAt(5))
		}				
		oldStatus = newStatus
	}
}

function setActive(isHouse,cal)
{
	var c = cal-0
	var oldA = ActHou
	
	if(!isHouse)
	{
		c+=10
		if(ActSen==c) return
		oldA = ActSen
		ActSen = c
	}
	else if(ActHou==c) return
	else ActHou = c
	
	if(c!=0&&c!=10)
	{
		obj = eval("document.forms[0].ai" + c)
		obj.src = "images/active.gif"
	}
	
	if(oldA==0||oldA==10) return
	obj = eval("document.forms[0].ai" + oldA)
	obj.src = "images/inactive.gif"	
}

function selOneCal(isHouse,cal)
{
	skipCount = 5	
	c = cal - 0
	s = 1
	e = 6
	if(!isHouse)
	{
		c+=10
		s = 11
		e = 18
	}
	obj = eval("document.forms[0].c" + c)
	if(!obj.checked) addAction(c,true)
	for(z=s; z<e; z++)
	{
		obj = eval("document.forms[0].c" + z)
		if((z!=c)&&(obj.checked))
			addAction(z,true)
	}
}

function onMenu()
{ 
	//if(oVisible||!autoHide) return
	//toggleOptions()
	if((!autoHide)||(oVisible&&!willHide)) return
	//if((oVisible||!autoHide)&&(!willHide)) return
	willHide = false
	setTimeout("checkHide()",200)
}

function offMenu()
{ 
	//if(!oVisible||!autoHide) return
	//toggleOptions()
	//if((!oVisible||!autoHide)&&(willHide)) return
	if((!autoHide)||(!oVisible&&willHide)) return
	willHide = true
	setTimeout("checkHide()",200)
}

function checkHide()
{
	if((willHide&&oVisible)||(!willHide&&!oVisible)) toggleOptions()
}

function toggleAutoHide(doCheck)
{
	checkObj = document.forms[0].tah
	if(doCheck) checkObj.checked = !checkObj.checked

	if(!checkObj.checked)
		autoHide = false
	else
		autoHide = true
}

function toggleBold(doCheck)
{
	checkObj = document.forms[0].tbt
	if(doCheck) checkObj.checked = !checkObj.checked

	if(!checkObj.checked)
		isBold = false
	else
		isBold = true
	updateDisplay()
}