 var _helpElement = null;
 var _backgroundElement = null;
 var _helpTime = null;
 var _helpLink = '';
 var _positionDivId = 'Layout_1_left';

 function InitHelp(){
	this._backgroundElement = document.createElement('div');
	//this._backgroundElement.style.visibility = 'hidden';
	this._backgroundElement.style.display = 'none';
	this._backgroundElement.style.position = 'absolute';
	//this._backgroundElement.style.overflow = 'hidden';
	this._backgroundElement.style.left = '0px';
	this._backgroundElement.style.top = '0px';
	this._backgroundElement.style.width = '450px';
	this._backgroundElement.style.height = '302px';
	this._backgroundElement.style.zIndex = 10000;
	this._backgroundElement.className = 'ms_background';

	var html = "<div id='helpFrameDiv'><iframe id='HelpFrame' scrolling='auto' frameborder='0' width='100%' height='100%' src='";
	html += _helpLink;
	html += "' onmouseout='HideHelpTipDiv(event);'></iframe></div>";

	document.write(html);
	this._helpElement = document.getElementById("helpFrameDiv");
	//this._helpElement.style.visibility = 'hidden';
	this._helpElement.style.display = 'none';
	this._helpElement.style.position = 'absolute';
	//this._helpElement.style.overflow = 'hidden';
	this._helpElement.style.left = '0px';
	this._helpElement.style.top = '0px';
	this._helpElement.style.width = '450px';
	this._helpElement.style.height = '302px';
	this._helpElement.style.border = '1px solid #c8c8c8';
	this._helpElement.style.zIndex = 10001;
	this._helpElement.parentNode.appendChild(this._backgroundElement);
 }

 function PopHelpTipDiv(){
	var help = document.getElementById("helpDiv");
	var titlebar = document.getElementById(_positionDivId);

	var reducedWidth = 450;
	if (help != null && titlebar != null){
		var helpx = getAbsolutePos(help).x;
		var titleBarX = getAbsolutePos(titlebar).x;

		if (helpx - titleBarX < 450) reducedWidth = helpx - titleBarX;
	}

	this._helpElement.style.width = reducedWidth + 'px';

	if (this._helpElement.style.display == 'none' ){
		var help = document.getElementById("helpDiv");
		var p = getAbsolutePos(help);

		var top = getAbsolutePos(document.getElementById(_positionDivId));

		var left = p.x - _helpElement.offsetWidth + help.offsetWidth;
		if (left < 0) left = 0;

		var helpWidth = _helpElement.style.width.replace("px","");

		_helpElement.style.left = (parseFloat(left) - parseFloat(helpWidth) - 6) + "px";
		_helpElement.style.top = (p.y + 6) + "px";

		_backgroundElement.style.left = (parseFloat(helpWidth) + 4) + "px";
		_backgroundElement.style.top = (p.y + 5 + 4) + "px";

		if (_helpLink == ''){
			this._backgroundElement.style.display = 'none';
			this._helpElement.style.display = 'none';
		}else{
			this._backgroundElement.style.display = 'block';
			this._helpElement.style.display = 'block';
		}
	}
	_helpTime = null;
 }

 function HideHelpTipDiv(evt){
	if (_helpTime){
		clearTimeout(_helpTime);
		_helpTime = null;
	}

	if (this._helpElement.style.display == 'block'){
		var id = undefined;
		if (window.event){
			if (window.event.toElement != null) id = window.event.toElement.id;
		}else if (evt != undefined){
			id = evt.relatedTarget.id;
		}

		if (id == undefined || id.toLowerCase().indexOf('help') == -1){
			this._helpElement.style.display = 'none';
			this._backgroundElement.style.display = 'none';
		}
	}
}