Hi everyone,

I am playing around trying to get a script to work.
This is what I want it to do.
When the first input box is clicked on it will display a hidden division with links in it and then focus on the first link in that division. The user can then tab through the links. When the last link has been tabbed off of it should hide the link division and then focus on the next input element. In Firefox this works perfectly fine. In I.E. it does not return the focus to the input. It ends up focusing on the browsers location bar.

Can anyone help?

HTML Code:
<html>

<script type="text/javascript" language="javascript">

  //Set the division to the coordinates of the input element or hide the element
  function getCoords(e)
  {
		
	div = document.getElementById('hide');
	if(div.style.display == 'block')
		div.style.display = 'none';
	else
	{
		//Get position by cycling through parent nodes
	    var pos = { x: 0, y: 0 };
		var h = e.offsetHeight;
		var w = e.offsetWidth;
		while (e) {
	      pos.x += e.offsetLeft;
	      pos.y += e.offsetTop;
	      e = e.offsetParent;
	    }
		
		//Set the new position
		div.style.display = 'block';	  
		div.style.left = pos.x;
		div.style.top = pos.y + h;
		div.style.minWidth = w;
		div.style.width = w;	
	}
  }
  
  var nextEl;
  //If the div is shown then show links and focus on first link
  function unshow(e)
  {
	nextEl = e;
	a = document.getElementById('hide');
	if(a.style.display = 'block')
	{
		var lnks = a.getElementsByTagName('a');
		addEvent(lnks[(lnks.length-1)], 'blur', change, false);
		lnks[0].focus();
	}
  }
  
  //Hide display and focus on old next element
  function change(){
	document.getElementById('nextButton').focus();
	document.getElementById('hide').style.display='none';
  }
  
  function addEvent(elm, evType, fn, useCapture){
			// addEvent cross-browser event handling for IE5+ NS6/Mozilla
			//By Scott Andrew
			if(elm.addEventListener){
				elm.addEventListener(evType, fn, useCapture);
				return true;
			} else if(elm.attachEvent){
				var r = elm.attachEvent('on' + evType, fn);
				//EventCache.add(elm, evType, fn);
				return r;
			} else{
				elm['on' + evType] = fn;
			}
	}
</script>

<style type="text/css">
<!--
	a{text-decoration: none;
	font-family: sans-serif;
	color: #000}
	
	a:hover{text-decoration: underline}
	
	#hide{position: absolute;
		display: none;	
		z-index: 20; 
		background-color: #ccc; 
		border: 1px solid #000; 
		padding: 10px; 
		font-size: 10pt}
-->
</style>
<body>
<div align="center" style="padding: 50px">
<form action="">
	<h1>Testing DHTML Location Properties</h1>
	Customer: <input type="text" value="" name="" id="test" onClick="getCoords(this)" onBlur="unshow('nextButton')"><br>
	Some field: <input type="text" value="" name="" id="nextButton"><br>
	Some field: <input type="text" value="" name="">
	<div style="z-index: 1">
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
		Here is a bunch of text that will be covered up - hopefully :) <br>
	</div>
</form>
</div>
<div id="hide">
	<a href="" onClick="return false;">Andover Bank</a><br>
	<a href="" onClick="return false;">A. Brown</a><br>
	<a href="" onClick="return false;">Winters Plumbing</a>

</div>
</body>
</html>
Thanks,

Nick

P.S. I included all of the code being used. I don't believe the positioning code would cause a problem but I included it just in case. This is just a test, hence why some of the attributes are missing, to see if I can get the javascript working but any help would be appreciated.