// nb customised to return null if no style object exists for the given id
function getIE4StyleObject(id) 
{ 
	el = document.all[id];
	if (el) return el.style; 
	return null;
}
function getNS4StyleObject(id) { return document.layers[id]; }
function getW3CStyleObject(id) 
{ 
	el = document.getElementById(id)
	if (el) return el.style;
	return null; 
}
var getStyleObject = null;
if (document.getElementById)
	getStyleObject = getW3CStyleObject;
else if (document.all)
	getStyleObject = getIE4StyleObject;
else 
	getStyleObject = getNS4StyleObject;

function getIE4Object(id) { return document.all[id]; }
function getNS4Object(id) { return document.layers[id]; }
function getW3CObject(id) { return document.getElementById(id); }
var getObject = null;
if (document.getElementById)
	getObject = getW3CObject;
else if (document.all)
	getObject = getIE4Object;
else 
	getObject = getNS4Object;

// from Danny Goodman's JavaScript & DHTML Cookbook, p.333
// Does not work with Safari though, bah!
function getElementStyle(elemID, IEStyleProp, CSSStyleProp)
{
	var elem = document.getElementById(elemID);
	if (elem)
	{
		if (elem.currentStyle)
		{
			//trace("getElementStyle currentStyle is defined");
			return elem.currentStyle[IEStyleProp];
		}
		else if (window.getComputedStyle)
		{
			var compStyle = window.getComputedStyle(elem, "");
			//trace("getElementStyle compStyle is defined");
			return compStyle.getPropertyValue(CSSStyleProp);
		}
		else if (document.defaultView.getComputedStyle)
		{
			var compStyleV2 = document.defaultView.getComputedStyle(elem, "");
			//trace("getElementStyle document.defaultViewcompStyle is defined");
			return compStyleV2.getPropertyValue(CSSStyleProp);
		}
		else if (elem.style.display == "none")
		{
			// maybe it is cos element has display:none
			elem.style.display = "block";
			if (document.defaultView.getComputedStyle)
			{
				var compStyle = document.defaultView.getComputedStyle(elem, "");
				//trace("getElementStyle document.defaultViewcompStyle is defined after setting elem display style to block");
				return compStyle.getPropertyValue(CSSStyleProp);
			}
		}
		else
		{
			// give up
			//trace("getElementStyle no idea what is going wrong!");
		}
		//trace ("getElementStyle neither currentStyle nor compStyle are defined");

	}
	else
	{
		//trace("getElementStyle elem undefined");
	}
	return "";
}

