
function setParam( sName, sValue, oWin )
{
	try
	{
		oWin.document.all.userSettings.load("cache");
		oWin.document.all.userSettings.setAttribute(sName, sValue);
		oWin.document.all.userSettings.save("cache");
	}
	catch (ex) {}
}

function deleteParam( sName, oWin )
{
	try
	{
		oWin.document.all.userSettings.load("cache");
		oWin.document.all.userSettings.removeAttribute(sName);
		oWin.document.all.userSettings.save("cache");	
	}
	catch (ex) {}
}

function fetchParam( sName, oWin )
{
	if (oWin == null)
	{
		oWin = window.top;
		if (oWin.document.frames.editMain != null)
			oWin = window.top.document.frames.editMain.document.frames.EditFrame;
	}
	
	try
	{
		oWin.document.all.userSettings.load("cache");
		return oWin.document.all.userSettings.getAttribute(sName);
	}
	catch (ex) {}
	return "";
}

function checkParamVer( sName, oWin )
{
	var d = new Date();
	var sCurrentVerDate = fetchParam( 'ParamVerDate', oWin )
	if (sCurrentVerDate == null)
	{
		sCurrentVerDate = d.toUTCString();
		setParam( 'ParamVerDate', sCurrentVerDate, oWin );
	}
	var sParamVerDate = fetchParam( 'V-' + sName, oWin );
	if (sParamVerDate != sCurrentVerDate)
	{
		deleteParam( 'N-' + sName, oWin );
		deleteParam( 'F-' + sName, oWin );
		setParam( 'V-' + sName, sCurrentVerDate, oWin );
	}
}

function popHelp( sCode, nMode, sMod, oWin )
{

	if (oWin == null)
	{
		oWin = window.top;
		if (oWin.document.frames.editMain != null)
			oWin = window.top.document.frames.editMain.document.frames.EditFrame;
	}

	var helpEnabled = fetchParam( 'helpEnabled', oWin );
	if (helpEnabled != null)
		if (helpEnabled == '0' && nMode != 0)
			return;
			
	if (helpEnabled == "")
		return;
			
	var sCookie = '';
	if (sMod != null && sMod != '')
		sCookie += sMod + "-";
	sCookie += sCode;

	checkParamVer( sCookie, oWin );

	var notShow = fetchParam( 'N-' + sCookie, oWin );
	var firstTime = fetchParam( 'F-' + sCookie, oWin );
	
	if (nMode == 1 && firstTime == '0')
		return false;
		
	if (nMode == 2 && notShow == '1')
		return false;
		
	if (firstTime != '0')
		setParam( 'F-' + sCookie, '0', oWin );

	var sRoot = '/';
	
	if (sRoot == '')
		sRoot = '/';
	
	if (sRoot.charAt(sRoot.length-1) != '/')
		sRoot += '/';

	var sURL = sRoot + 'help/help.aspx?c=' + sCode;
	
	if (nMode == 2)
		sURL += '&x=1';
	
	if (sMod != null && sMod != '')
		sURL += '&m=' + sMod;
	
	try
	{
		window.showModelessDialog( sURL, oWin, 'dialogWidth:345px;dialogHeight:250px;Help:no;Scroll:no;Status:no;Resizable:yes' );
	}
	catch (ex)
	{
		alert('Please disable your popup blocker for this site. During editing, you will receive important help via popups. You can disable all help popups (and this message) in Editor Settings. To access Editor Settings, switching to Edit Mode, and click on Editor Settings in the System menu.');
	}
	
	
	
	return true;
}

var SHOW_ALWAYS = 0;
var SHOW_ONCE = 1;
var SHOW_USER = 2;