function setValue() {

	formulaArray[whichChannel]=formulaArray[whichChannel]+ document.getElementById("team").value + "." + document.getElementById("year").value;
	document.getElementById(whichChannel).value=formulaArray[whichChannel];
	
	
//document.getElementById("dump").innerHTML=document.getElementById("team").value + "." + document.getElementById("year").value;
}

var textArray=new Array();
textArray["xChannel"]="column 1"
textArray["yChannel"]="column 2"


var formulaArray=new Array();
formulaArray["xChannel"]="="
formulaArray["yChannel"]="="

var whichChannel;
var isText;//corrects a key error latter on

function setChannel(channelStatus,eventType,number) {

	 
	
	document.getElementById("calculator").style.visibility="visible";
	
	if(eventType=="focus") {
	document.getElementById(channelStatus).value=formulaArray[channelStatus];
	//whichChannel=channelStatus;
	
	
	
	} else if (eventType=="keyInput") {
	
	formulaArray[whichChannel]=formulaArray[whichChannel]+number;
	document.getElementById(whichChannel).value=formulaArray[whichChannel];
	channelStatus=whichChannel;//keep vari going
	
	isText="no";
	
	
	}  else if (eventType=="blur") {
	
	document.getElementById("xChannel").value=textArray["xChannel"];
	document.getElementById("yChannel").value=textArray["yChannel"];
	document.getElementById("calculator").style.visibility="hidden";
	
	} else if (eventType=="alphaNumericDown") { //should the user use the keyboard instead of the onscreen calculator
		
		//must find an event that fires just after keypress
		//maybe do action on keydown and read on keyup?
		if (document.getElementById(channelStatus).value.charAt(0)=="=") {
			
			//number.preventDefault();
			formulaArray[channelStatus]+=String.fromCharCode(number.charCode);
			
			isText="no";
			
			
		} else {
		//alert(number.keyCode);
			textArray[channelStatus]+=String.fromCharCode(number.charCode);
			
			isText="yes";
		
		}
	
	
	} else if (eventType=="alphaNumericUp") {
		if (document.getElementById(channelStatus).value.charAt(0)=="=") {
	
			formulaArray[channelStatus]=document.getElementById(channelStatus).value;
			document.getElementById(channelStatus).value=formulaArray[channelStatus];
		} else {
		//alert(number.keyCode);
		
			//when you enter the title the fist key press will register as formula
			//this correct that
			
			if (isText=="no") { 
			var textLength=formulaArray[channelStatus].length;
			textLength=textLength-1;
			formulaArray[channelStatus]=formulaArray[channelStatus].substr(0,textLength);//corrects a key that appears in formula
			}
			
			//document.getElementById("dump").innerHTML=formulaArray[channelStatus];
			//formulaArray[channelStatus]=formulaArray[channelStatus].substring(0,textLength);//corrects a key that appears in formula
			//formulaArray[channelStatus]=formulaArray[channelStatus]
			textArray[channelStatus]=document.getElementById(channelStatus).value;
			document.getElementById(channelStatus).value=textArray[channelStatus];
		
		}
	
	}
	
	whichChannel=channelStatus;

}

function buildQuery(number) {
	//document.getElementById(whichChannel).focus();
	formulaArray[whichChannel]=formulaArray[whichChannel]+number;
	document.getElementById(whichChannel).value=formulaArray[whichChannel]
	

}

function clearChannel() {
	
	formulaArray[whichChannel]="=";
	document.getElementById(whichChannel).value=formulaArray[whichChannel];


}


function blipColor(buttonId) {//temp highlights button when pressed

document.getElementById(buttonId).style.backgroundColor="gray";




}

function resetColor(buttonId){//returns button to normal state

document.getElementById(buttonId).style.backgroundColor="white";

}
