function BrowserInfo()
{
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.isNav  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.isNav4 = (this.isNav && (this.major == 4));
    this.isNav6 = (this.isNav && ( this.major >= 5));
    this.isIE   = (agent.indexOf("msie") != -1);
    this.isIE4  = (this.isIE && (this.major == 4));
    this.ie4  = this.isIE4
    this.isIE4Up  = (this.isIE && (this.major >= 4));
    this.isIE5  = ( this.isIE && (this.major == 4) && (agent.indexOf("msie 5.0")!=-1));
    this.isIE55  = ( this.isIE && (this.major == 4) && (agent.indexOf("msie 5.5")!=-1));
    this.isIE60  = ( this.isIE && (this.major == 4) && (agent.indexOf("msie 6.0")!=-1));
    this.isIE55Up = this.isIE55 || this.isIE60;
    this.isIE50Up = this.isIE5 || this.isIE55Up;
    this.isOpera = (agent.indexOf("opera") != -1);
    this.op3 = (agent.indexOf("opera") != -1);

    this.isSafari = agent.indexOf("safari") != -1;
    // IE 5 or greater and Netscape 6 or greater.

    this.isHTML4 = (this.isNav6 || this.isIE50Up);
    this.isDOM4 = (this.isNav6 || this.isSafarai)
}

var browserinfo = new BrowserInfo()

function handleKeyPress(evt)
{
	var event = browserinfo.isIE ? window.event : evt;
	var character = event.keyCode;
	
	if ( character == 13 )
	{
		return false;
	}
	return true;
}

if ( browserinfo.isIE ) {document.onkeydown = handleKeyPress;}
if ( browserinfo.isNav ) {document.onkeypress = handleKeyPress; document.onclick =handleKeyPress;}
	
function getElmById(aID){ 
var element = null;
 if ( browserinfo.isIE ) { element = jsGetObjectRef(aID); }
 else { element = document.getElementById(aID); }
 return element;
} 

function jsGetObjectRef(sID, sName) { //, sInForm
  var oObject;
  var bIsIE   = document.all?true:false;
  var bIsNav  = !bIsIE;
   
  if (typeof sName != "string" ) {sName = sID;}
  if (bIsIE) {
    oObject = eval("document.all." + sID);
  } else { //Navigator
    if (frames.length > 0) {
			navLoop:
			for (var h = 0; h < frames.length; h++) {
				for (var i = 0; i < frames[h].document.forms.length; i++) {
					for (var j = 0; j < frames[h].document.forms[i].elements.length; j++) {
						if (frames[h].document.forms[i].elements[j].name == sName) {
							oObject = frames[h].document.forms[i].elements[j];
							break navLoop;
						}
					}
        }
      }
		} else {
			navNFLoop:
			for (var i = 0; i < document.forms.length; i++) {
				for (var j = 0; j < document.forms[i].elements.length; j++) {
					if (document.forms[i].elements[j].name == sName) {
						oObject = document.forms[i].elements[j];
						break navNFLoop;
					}
				}
			}
    }
    //oObject = eval("document.forms['" + sInForm + "']." + sName);
  }
  return oObject;
} //jsGetObjectRef

function jsResize(sWidth, sHeight) {
	window.resizeTo(sWidth,sHeight);
}

function jsResizeScreen(sWidth) {
	sHeight = window.outerHeight;
	window.resizeTo(sWidth,sHeight);
}

function jsPopup(sUrl) {
	var winOpen = window.open(sUrl,'Information','width=760,height=550,menubar=no,toolbar=no')
}

function jsPrint(sUrl) {
	var winOpen = window.open(sUrl,'Print','width=790,height=550,menubar=yes,resizable=yes,scrollbars=yes')
}

function jsNRCSSearch() {
	var keyword = jsGetObjectRef('searchfield','searchfield');
	var sURL = 'http://www.usda.gov/wps/portal/!ut/p/_s.7_0_A/7_0_1OB?navid=SEARCH&amp;q=' + keyword.value;
	var winOpen = window.open(sURL,'Search','width=790,height=580,menubar=yes,toolbar=yes,resizable=yes,scrollbars=yes');
}

function jsDisplayDiv(item, node){ 
	var itm=document.getElementById(item);
	var nde=document.getElementById(node);

	if (itm.style.display == 'none') {
		nde.src='images/minus.gif';
		itm.style.display ='block';
	} else {
		nde.src='images/plus.gif';
		itm.style.display ='none';
	}
}	