// This global code handles a focus timing bug in IE.
var global_valfield;	// retain valfield for timer thread

function setFocusDelayed()
{
  global_valfield.focus();
}

// --------------------------------------------
//                  setfocus
// Delayed focus setting to get around IE bug
// Update Jun 2005: discovered that reason IE 
// wasn't setting focus was due to an IE timing 
// bug. Added 0.1 sec delay to fix.

// --------------------------------------------
// found code at http://www.xs4all.nl/~sbpoley/webmatters/formval.js
function setfocus(valfield)
{
  // save valfield in global variable so value retained when routine exits
  global_valfield = valfield;
  setTimeout( 'setFocusDelayed()', 100 );
}

// This function reloads the animated gif to make sure that 
// it is animated when it is finally displayed to the user
  function showProgress(){ 
   var wi = document.getElementById("wait_image");
   wi.src=wi.src;
 }


// Make form disappear and show the wait page text
function showWaitSection() {
   var showForm = document.getElementById("display_form");
   var showWait = document.getElementById("display_wait");

   showWait.style.display="inline";
   showForm.style.display = "none";
   showForm.style.visibility="hidden";
   showWait.style.visibility="visible";
   window.setTimeout('showProgress()', 500);

}

// Show the form and make the wait page text disappear
function clearWaitSection() {
   var showForm = document.getElementById("display_form");
   var showWait = document.getElementById("display_wait");

   	showForm.style.display="inline";
   	showWait.style.display = "none";
   	showWait.style.visibility="hidden";
   	showForm.style.visibility="visible";
}

function ChangeFocus(box) {
   if (box != null)
	if (box != "") {
		// User has selected a value; Switch focus to next element
		var newFocus = document.getElementById (box);
                setfocus(newFocus);
		
	}
}