var HELPER_IFRAME_ID = "IFrmHelper";
var topDivZIndex = 10000;

// Will show the div and the helper iframe.
function showDiv(divId){
var oBody = document.getElementsByTagName("BODY").item(0);
var oHelperIframe = document.getElementById(HELPER_IFRAME_ID+divId);
if(oHelperIframe == null ){
	oHelperIframe = document.createElement("IFRAME");
	oHelperIframe.setAttribute("id", HELPER_IFRAME_ID+divId);
	oHelperIframe.style.border = 0; 
	oHelperIframe.width = 0; 
	oHelperIframe.height = 0;
	oHelperIframe.style.position = "absolute";
	oBody.appendChild(oHelperIframe);	
}
var oDiv = document.getElementById(divId);
oDiv.style.zIndex = topDivZIndex;
oHelperIframe.style.zIndex = topDivZIndex - 1000;
topDivZIndex += 1; 
oHelperIframe.style.top = oDiv.style.top;
oHelperIframe.style.left = oDiv.style.left;
oHelperIframe.width = oDiv.offsetWidth - 1;
oHelperIframe.height = oDiv.offsetHeight - 1;
oHelperIframe.style.visibility = 'visible';
//oDivlstyle.visibility = 'visible';

// Attach to the onmousedown event
if(typeof(oDiv.addEventListener) != "undefined") {
oDiv.addEventListener("onpropertychange", function() { hideDiv(oDiv.id); }, false);
} else {
oDiv.attachEvent("onpropertychange", function() { hideDiv(oDiv.id); });
}
}

// Will hide the div and the helper iframe.
function hideDiv(divId){
if(divId != null)
{
	var oHelperIframe = document.getElementById(HELPER_IFRAME_ID+divId);
	var oDiv = document.getElementById(divId);
	if(oDiv.style.visibility=='hidden')
	{
		oHelperIframe.style.visibility = 'hidden';
	}
}
}

