// a bug in MSIE in which getElementById is way out of compliance 
// by using the name field as well as the id field for object retrieval.
// Aaargh!
// The following code redefines getElemenById for MSIE so that it works correctly
// From
// from http://www.sixteensmallstones.org/ie-javascript-bugs-overriding-internet-explorers-documentgetelementbyid-to-be-w3c-compliant-exposes-an-additional-bug-in-getattributes

// Actually, I am getting an error running his version and I cannot debug in IE. Aaargh...
// It appears the the syntax:
//		document.all[id]
// should be replaced by
//		document.all(id)
// see http://msdn2.microsoft.com/en-us/library/ms537434.aspx

if (/msie/i.test (navigator.userAgent)) //only override IE
{
	document.nativeGetElementById = document.getElementById;

	document.getElementById = function(id)
	{
		var elem = document.nativeGetElementById(id);
		if (elem)
		{
			// make sure that it is a valid match on id
			if (elem.attributes['id'].value == id)
			{
				return elem;
			}
			else
			{				
				if (document.all(id) != null)
				{
					// otherwise find the correct element
					for (var i = 1; i < document.all(id).length; i++)
					{				
						if (document.all(id)[i].attributes['id'] && document.all(id)[i].attributes['id'].value == id)
						// if (document.all[id][i].getAttributeNode('id').value == id)
						{
							return document.all(id)[i];
						}
					}
				}
				else
				{				
					return null;
				}
				
			}
		}
		return null;
	};
}
