//This function is a counter for the text boxes to limit the number of characters typed in.
function textCounter(field,counter,limit){
	if(document.getElementById(field).value.length>limit){
		document.getElementById(field).value=document.getElementById(field).value.substring(0,limit);
	}
	document.getElementById(counter).innerHTML="&nbsp;"+document.getElementById(field).value.length+"/"+limit;
}

//Function for disabling submit buttons
function disablebutton(button,span,tabs){
	if(tabs){
		disabletabbing=1;
	}
	document.getElementById(button).disabled=true;
	document.getElementById(span).innerHTML="Processing...";
	return true;
}

//Function for handling keypresses, used for handling the Enter key during form filling to prevent premature submission
function handleKeyPress(e,form){
	var key=e.keyCode || e.which;
	if (key==13){
		tlnumfetch=1;
		fetchInfo();
	}
}

//Job Highlighting Function for Works Listing Pages - Global because it's used almost everywhere
function highlight(id, jobDiv, infoArray){
	var detailsbox = document.getElementById(jobDiv);
	var highlighted = document.getElementById(id);
	highlighted.bgColor = '#ecfc68';
	id = id.replace("job","");
	detailsbox.innerHTML = "<span style='font-weight: bold'>Job ID: </span>"+infoArray[id][0]+"<br/><span style='font-weight: bold'>Job Type: </span>"+infoArray[id][1]+"<br/><span style='font-weight: bold'>Job Status: </span>"+infoArray[id][2]+"<br/><br/>";
	detailsbox.innerHTML = detailsbox.innerHTML+"<span style='font-weight: bold'>Requester: </span>"+infoArray[id][3]+" "+infoArray[id][4]+"<br/><span style='font-weight: bold'>Department: </span>"+infoArray[id][5]+"<br/><br/>";
	detailsbox.innerHTML = detailsbox.innerHTML+"<span style='font-weight: bold'>Region: </span>"+infoArray[id][6]+"<br/><span style='font-weight: bold'>Suburb: </span>"+infoArray[id][8]+"<br/><span style='font-weight: bold'>Street: </span>"+infoArray[id][7]+"<br/><span style='font-weight: bold'>Location Details: </span>"+infoArray[id][9]+"<br/><span style='font-weight: bold'>Job Description: </span>"+infoArray[id][10]+"<br/><span style='font-weight: bold'>Job Reason: </span>"+infoArray[id][11];
}

//Job Highlighting Function for Works Listing Pages - Global because it's used almost everywhere
function BCChighlight(id, jobDiv, infoArray){
	var detailsbox = document.getElementById(jobDiv);
	var highlighted = document.getElementById(id);
	highlighted.bgColor = '#ecfc68';
	id = id.replace("job","");
	detailsbox.innerHTML = "<span style='font-weight: bold'>Job ID: </span>"+infoArray[id][0]+"<br/><span style='font-weight: bold'>Job Type: </span>"+infoArray[id][1]+"<br/><span style='font-weight: bold'>Job Status: </span>"+infoArray[id][2]+"<br/><br/>";
	detailsbox.innerHTML = detailsbox.innerHTML+"<span style='font-weight: bold'>Requester: </span>"+infoArray[id][3]+" "+infoArray[id][4]+"<br/><span style='font-weight: bold'>Department: </span>"+infoArray[id][5]+"<br/><br/>";
	detailsbox.innerHTML = detailsbox.innerHTML+"<span style='font-weight: bold'>Suburb: </span>"+infoArray[id][7]+"<br/><span style='font-weight: bold'>Street: </span>"+infoArray[id][6]+"<br/><span style='font-weight: bold'>Job Description: </span>"+infoArray[id][8];
}

//Job Highlighting Function for Works Listing Pages - Global because it's used almost everywhere
function nolight(id){
	var nolighted = document.getElementById(id);
	nolighted.bgColor = '';
}

//Submenu script for Transeducom Information Page
startList = function(){

	if (document.getElementById("content").offsetHeight>503){
		var avon = document.getElementById("content").offsetHeight+"px";
		document.getElementById("menu").style.height=avon;
	}
	
	if (document.all&&document.getElementById)
	{
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++)
		{
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI")
			{
				node.onmouseover=function()
				{
					this.className+=" over";
				}
				node.onmouseout=function()
				{
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

//Function for deselecting radio buttons
function deselect(buttonid){
	var button = document.getElementById(buttonid);
	if (button.checked)
	{
		button.checked = false;
	}
}

window.onload = startList;
