var xmlHttp
var gSpanId="ukgs302", gTierId="", gYear,gState, gView, gExpand, gUnits, gFy, gPie

var dsi=13;
var keyH="72",keyh="104"
var keyJ="74",keyj="106";
var keyK="75",keyk="107";
var keyL="76",keyl="108";
var x='';
function handler(e) 
{
	if (document.all) {
		var evnt = window.event; 
		x=evnt.keyCode;
	}
	else 
		x=e.charCode;
	var elem1 = document.getElementById('selyear')
	gYear = elem1.value
	elem1 = document.getElementById('selstate')
	gState = elem1.value
	elem1 = document.getElementById('selunits')
	gUnits = elem1.value
	elem1 = document.getElementById('selpie')
	gPie = elem1.value
	elem1 = document.getElementById('selfy')
	if(elem1 == null)
		gFy = '2010'
	else	
		gFy = elem1.value
  
	if (x==keyH || x==keyh) getAjaxSpending(gSpanId,gTierId,(gYear-5),gState,gView, gExpand, gUnits, gFy, gPie)
	if (x==keyJ || x==keyj) getAjaxSpending(gSpanId,gTierId,(gYear-1),gState,gView, gExpand, gUnits, gFy, gPie)
	if (x==keyK || x==keyk) getAjaxSpending(gSpanId,gTierId,(parseInt(gYear)+1),gState,gView, gExpand, gUnits, gFy, gPie)
	if (x==keyL || x==keyl) getAjaxSpending(gSpanId,gTierId,(parseInt(gYear)+5),gState,gView, gExpand, gUnits, gFy, gPie)
}
function incFontSize(p) {
	if (p == "grow") {
		dsi++;
	}
	else {
		dsi--;
	}
	document.getElementById('ukgs303').style.fontSize=dsi+"px";
	document.getElementById('ukgs342').style.fontSize=dsi+"px";
}
function getQik(spanId)
{
	gSpanId = spanId
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="ukgs_ajax.php"
	url=url+"?p="+spanId
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 
function getAjaxDownload(spanId,tierCode,year,state,view, expand, units, fy)
{
window.open("ukgs_down.php?span="+spanId+"&year="+year+"&state="+state+"&view="+view
		+"&expand="+expand+"&units="+units+"&fy="+fy
		,'printfriendly','scrollbars=yes,width=600,height=400')
}
function getAjaxPrint(spanId,tierCode,year,state,view, expand, units, fy)
{
window.open("ukgs_print.php?span="+spanId+"&year="+year+"&state="+state+"&view="+view
		+"&expand="+expand+"&units="+units+"&fy="+fy
		,'printfriendly','scrollbars=yes,width=555,height=400')
}
function getHelp(spanId,help)
{
	getAjaxHelp(spanId,help)
}
function getDownAll(codes, group, units, fy)
{
	location ="downloadsrs_ukgs.php?codes="+codes+"&units="+units+"&group="+group+"&fy="+fy
}
function getDownAddCode(codes, code, group, units, fy)
{
	location ="downloadsrs_ukgs.php?codes="+codes+"_"+code
		+"&units="+units+"&group="+group+"&fy="+fy
} /*
function getAjaxSpending(spanId,tierCode,year,state,view, expand, units, fy, pie)
{
	gSpanId = spanId
	gTierId = tierCode
	gExpand = expand
	gView = view
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="ukgs_ajax.php"
	url=url+"?p="+spanId+"&q="+year+"&r="+view+"&s="+expand+"&u="+units+"&v="+fy+"&w="+state+"&x="+pie
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 
function getSpending(spanId,tierCode,year,state, view, expand, units, fy, pie)
{
	gSpanId = spanId
	gExpand = expand
	location ="download_ukgs.php?span="+spanId+"&year="+year+"&state="+state+"&view="+view
		+"&expand="+expand+"&units="+units+"&fy="+fy+"&pie="+pie+"#"+spanId
} */
function getBudgetSpending(spanId,tierCode, year,state, view, expand, units, fy)
{
	gSpanId = spanId
	gTierId = tierCode
	gExpand = expand
	location = "budget_pie_ukgs.php?span="+spanId+"&year="+year+"&view="+view
		+"&expand="+expand+"&units="+units+"&fy="+fy
		+"&state="+state+"#"+spanId+tierCode
} /*
function getChart(code,view,state,year)
{
	location ="downchart_ukgs.php?chart="+code+"-total&view="+view+"&year="+year+"&state="+state
} */

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	var idCode = gSpanId
	var elem = document.getElementById(idCode+"s")
	var newSpan = document.createElement('span')
	newSpan.id = elem.id
	newSpan.innerHTML = xmlHttp.responseText
	for (var i = 0; i < document.getElementById(idCode).childNodes.length; i++) {
		var n = document.getElementById(idCode).childNodes[i]
		n.parentNode.removeChild(n)
	}
	document.getElementById(idCode).appendChild(newSpan) 
	location.hash = gSpanId + gTierId 
} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
} 
function show_box1(ani) {
 boxdiv = document.getElementById(ani);
 boxdiv.style.display='block';
 document.body.style.cursor='pointer'
}
function hide_box1(ani) {
 boxdiv = document.getElementById(ani);
 boxdiv.style.display='none';
 document.body.style.cursor='auto'
}

