///////////////////////////////////////////////////////////////////////////
//
//	Filename:		ESWeb.js
//
//	Author:			Sky Bristol (sbristol@fws.gov)
//
//	Last Modified:	October 22, 1999
//
///////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////
//
//	Standard JavaScripts for ES Web Sites
//
///////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////
// 	loadPopup() loads a Popup Window with specified parameters
version = ""
                if (navigator.appName == "Netscape" && ((parseInt(navigator.appVersion) == 3) || (parseInt(navigator.appVersion) == 4))) {version = "n3"}

function loadPopUp(html,title,parameters) {
        var popup = window.open(html,title,parameters)
        popup = window.open(html,title,parameters)
        if (version == "n3") {
                popup.focus()
        }
        return false
}


///////////////////////////////////////////////////////////////////////////
// 	Functions for Office Directory Application

// remove the spacer line from the Select box 
function init(){ 
  removelast(document.theform.personnelid); 
} 

//For Leaving FWS - External Message
function Exit(){
     alert("You are now leaving the U.S. Fish and Wildlife Service web site. We do not control the content or policies of the site you are about to visit. You should always check a site's policies before providing personal information or reusing content.")
}

// if the choice merits a search, launch it 
// otherwise just the original message 
function getmatches(){ 
  var theElement = document.theform.orgcode; 
  var theIndex = theElement.selectedIndex; 
  var theValue = theElement.options[theIndex].value; 

  removeAll(document.theform.personnelid); 

  // if they picked the instruction option 
  if (theValue == "X"){ 
    addToSelectUnique(document.theform.personnelid, "List of matches", ""); 
  
  // otherwise get their results 
  }else{ 
    top.hidden.document.location = "blank.cfm?orgcode=" + theValue; 
  } 
} 

// this will remove all the contents of the Select object passed in 
function removeAll(formelement){ 
  var selectLength = formelement.length; 
  for (var i = 0; selectLength > i; i++) { 
    removelast(formelement); 
  } 
} 

// will remove the LAST entry in a Select box 
function removelast(formelement){ 
  var thelength = formelement.length; 

  formelement.options[thelength - 1].value = ""; 
  formelement.options[thelength - 1].text = ""; 
  formelement.length = thelength - 1; 
} 

// will add a text/value pair to a Select box if that value 
// isn't already in the list 
function addToSelectUnique (destSelect, thetext, thevalue){ 
  if (destSelect.length > 0){ 
    for (var i = 0; destSelect.length > i; i++) { 
      if (destSelect.options[i].value == thevalue){ 
        return ("0"); 
      } 
    } 
  } 

  var d = new Option(thetext); 
  d.value = thevalue; 
  d.text = thetext; 

  destSelect.length ++; 
  thelength = destSelect.length; 
  
  destSelect.options[thelength - 1] = d; 
  return ("1"); 
} 

