// Event handler
function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be attached");
  }
}

function set_dropdown() {
  var options = document.getElementById("cfiwn").options;
  var loc = location.href;
  
  // The below has been commented out for now.  It was a script to automagically select the currently viewed
  // section in the dropdown, but wasn't working on URL's deeper than one directory.
  
  // if (loc.indexOf("http://") > -1) loc = loc.substr(7); // get rid of "http://" if it's there.
  // loc = loc.split('/'); // chop the URL into nice little segments
  // 
  // for (var count = 0; count < options.length; count++) {
  //   var option_value = options[count].value;
  //   if (option_value == "") {
  //     options[count].disabled = true;
  //   }
  // }
  // 
  // // Is the first segment blank? If so, we're on the homepage, and we're done.
  // if (loc[1] == '') {
  //   options.selectedIndex = 0;
  //   return;
  // }
  // 
  // // loop through each option in the CFI web network dropdown and select the current subsite.
  // for (var count = 0; count < options.length; count++) {
  //   var option_value = options[count].value;
  //   
  //   if (option_value.indexOf("http://") > -1) option_value = option_value.substr(7); // get rid of "http://" if it's there.
  //   option_value = option_value.split('/'); // chop the URL into nice little segments
  //   
  //   if (option_value[1].indexOf(loc[1]) == 0) {
  //     options.selectedIndex = count;
  //     break;
  //   }
  // }
}

addEvent(window, "load", set_dropdown); // add it to the event handler for window.onload

function auto_submit() {
	box = document.forms[0].url;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = destination;
}

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}