// JavaScript Document

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function jbe_set_nav(sectionName,objName) {
	if (sectionName == objName)
	{
		// changes the section class
		MM_changeProp(sectionName,'','className','ln_main_select','A');
	}
	else
	{
		// changes the subsection class
		MM_changeProp(objName,'','className','ln_sub_select','A');

		// changes the section class
		MM_changeProp(sectionName,'','className','ln_main_select_sub','A');
	}

	// shows the sub navigation
	MM_changeProp(sectionName+'_sub','','style.display','block','DIV');
}


var ns4 = (document.layers) ? true : false;
var ie4 = (document.all) ? true : false;
var ns5 = (document.getElementById) ? true : false;
var is4 = (ns4 || ie4 || ns5)
var isMac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false;
if(isMac && ie4)
{  // ie mac currently acts like a 3.0 browser so let's just force it to now to prevent errors
	ie4 = false;
	is4 = false;
}

function tnFormValidator(theForm)
{
	var reNpa = /\d\d\d/;
	var reNnx = /\d\d\d/;
	var reLine = /\d\d\d\d/;
	if (!(reNpa.test(theForm.npa.value) && reNnx.test(theForm.nnx.value) && reLine.test(theForm.line.value)))
	{
		alert("Please enter your 10 digit numeric phone number starting with area code.");
		theForm.npa.focus();
		return (false);
	}
	else
	{
		return (true);
	}
}
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
// autotab functionality
function autoTab(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 && !containsElement(filter,keyCode))
	{
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	function containsElement(arr, ele)
	{
		var found = false, index = 0;
		while(!found && index < arr.length)
			if(arr[index] == ele)
				found = true;
			else
				index++;
		return found;
	}
	function getIndex(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;
}