var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function focusNext(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !cPres(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIdx(input)+1) % input.form.length].focus();
}

function cPres(a, b) {
var exist = false, index = 0;
while(!exist && index < a.length)
if(a[index] == b)
exist = true;
else index++;
return exist;
}

function getIdx(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}

function setPageStateForMessageDisplay()
{
	document.body.scroll = "no";
	var selectElements = document.getElementsByTagName("select");
	for(var i = 0; i < selectElements.length; i++)
	{
		selectElements[i].style.visibility = "hidden";
	}
}

function findElement(elementId)
{
	//alert("findElement start");
	//alert("elementId : " + elementId);
	var divElement = document.getElementById(elementId);
	if (divElement == null && opener != null)
	{
		divElement = opener.document.getElementById(elementId);
	}
	//alert("divElement : " + divElement);
	return divElement;
	//alert("findElement end");
}

function openInfoWindow(infoPage,infoName,features) {
  window.open(infoPage,infoName,features);
}

function filter(url){
	var element1 = findElement("corporation");
	var element2 = findElement("program");
	var element3 = findElement("sort");
	if (element1 != null && element2 != null && element3 != null)
	{
		url = url + "&page=sort&sort=" + element3.options[element3.selectedIndex].value + "&" + element1.name + "=" + element1.options[element1.selectedIndex].value + "&" + element2.name + "=" + element2.options[element2.selectedIndex].value;
		parent.location.replace(url);
    }
}

function quickSort(url, selObj){
    url = url + "&page=sort&sort=" + selObj.options[selObj.selectedIndex].value;
    parent.location.replace(url);
}

function quickSortSection(url, selObj, arg1){
    url = url + "&id=" + arg1 + "&page=sort&sort=" + selObj.options[selObj.selectedIndex].value + "#sectionSort"
    parent.location.replace(url); 
}

function radioJump(loc) {
		window.location.href = loc;
}

function formSuspend() {
    document.employerAddStaffingRequest.submit.disabled=true;
}
