
function fnGetObject(sId)
{
	if (typeof(sId) == 'object')
	{
		return sId;
	}
	else
	{
		if (window.document.all)
			return window.document.all(sId);
		else if (window.document.getElementById)
			return window.document.getElementById(sId);
		else if (window.document.layers)
			return window.document.layers[sId];
		else
			return null;
	}
}


function fnGetObjectFromWindow(sId, oWindow)
{
	if (typeof(sId) == 'object')
	{
		return sId;
	}
	else if (typeof(oWindow) == 'object' && oWindow != null)
	{
		if (oWindow.document.all)
			return oWindow.document.all(sId);
		else if (oWindow.document.getElementById)
			return oWindow.document.getElementById(sId);
		else if (oWindow.document.layers)
			return oWindow.document.layers[sId];
		else
			return null;
	}
	else
	{
		return fnGetObject(sId);
	}
}


function fnFocus(sObject)
{
	var oObject = fnGetObject(sObject);
	if (typeof(oObject) == 'object' && oObject != null)
		oObject.focus();
}


function fnRedirect(sLink)
{
	window.location.href = sLink;
}


function fnOpenWindow(sLink, sTarget, sParameter)
{
	if (typeof(sParameter) == 'string' && sParameter.length > 0)
		window.open(sLink, sTarget, sParameter);
	else
		window.open(sLink, sTarget);
}


function fnPrompt(sMessage, sDefaultValue)
{
	return (window.prompt(sMessage, sDefaultValue));
}


function fnConfirm(sQuestion)
{
	return (window.confirm(sQuestion));
}


function fnConfirmSubmit(sQuestion, sForm)
{
	if (fnConfirm(sQuestion))
	{
		var oForm = fnGetObject(sForm);
		if (typeof(oForm) && oForm != null)
			oForm.submit();
	}
}


function fnConfirmRedirect(sQuestion, sUrl)
{
	if (fnConfirm(sQuestion))
		fnRedirect(sUrl);
}


function fnChangeDisplay()
{
	var sVisible = '';

	if (fnChangeDisplay.arguments.length > 0)
		if (fnChangeDisplay.arguments[0] == 'block'
		|| fnChangeDisplay.arguments[0] == 'inline'
		|| fnChangeDisplay.arguments[0] == 'inline-block'
		|| fnChangeDisplay.arguments[0] == 'inline-table'
		|| fnChangeDisplay.arguments[0] == 'list-item'
		|| fnChangeDisplay.arguments[0] == 'run-in'
		|| fnChangeDisplay.arguments[0] == 'table'
		|| fnChangeDisplay.arguments[0] == 'table-caption'
		|| fnChangeDisplay.arguments[0] == 'table-cell'
		|| fnChangeDisplay.arguments[0] == 'table-column'
		|| fnChangeDisplay.arguments[0] == 'table-column-group'
		|| fnChangeDisplay.arguments[0] == 'table-footer-group'
		|| fnChangeDisplay.arguments[0] == 'table-header-group'
		|| fnChangeDisplay.arguments[0] == 'table-row'
		|| fnChangeDisplay.arguments[0] == 'table-row-group'
		|| fnChangeDisplay.arguments[0] == 'inherit')
			sVisible = fnChangeDisplay.arguments[0];

	for (var i=0; i < fnChangeDisplay.arguments.length; i++)
	{
		var oId = fnChangeDisplay.arguments[i];
		var oRef = fnGetObject(oId);

		if (typeof(oRef) == 'object' && oRef != null)
			oRef.style.display = (oRef.style.display != 'none' ? 'none' : sVisible);
	}
}


function fnSetDisplayOn()
{
	for (var i=0; i < fnSetDisplayOn.arguments.length; i++)
	{
		var oId = fnSetDisplayOn.arguments[i];
		var oRef = fnGetObject(oId);

		if (typeof(oRef) == 'object' && oRef != null)
			oRef.style.display = '';
	}
}


function fnSetDisplayOff()
{
	for (var i=0; i < fnSetDisplayOff.arguments.length; i++)
	{
		var oId = fnSetDisplayOff.arguments[i];
		var oRef = fnGetObject(oId);

		if (typeof(oRef) == 'object' && oRef != null)
			oRef.style.display = 'none';
	}
}


function fnSetDisplay()
{
	for (var i=1; i < fnSetDisplay.arguments.length; i++)
	{
		var oId = fnSetDisplay.arguments[i];
		var oRef = fnGetObject(oId);

		if (typeof(oRef) == 'object' && oRef != null)
			oRef.style.display = (fnSetDisplay.arguments[0] > 0 ? '' : 'none');
	}
}


function fnSubmitForm(sForm)
{
	var oForm = fnGetObject(sForm);
	if (typeof(oForm) == 'object' && oForm != null)
		oForm.submit();
}


function fnUrlAddVar(sUrl, sVar, sValue)
{
	if (sVar=='') return sUrl;

	var sResult = sUrl;

	var iStart1 = sResult.indexOf('&'+sVar+'=');
	var iStart2 = sResult.indexOf('?'+sVar+'=');

	var iEnd = sResult.indexOf('&', (iStart1>-1 ? iStart1+sVar.length+2 : (iStart2>-1 ? iStart2+sVar.length+2 : 0)));

	if (sValue=='')
	{
		if (iStart1>-1)
			sResult = sResult.substr(0, iStart1)+(iEnd>-1 ? sResult.substr(iEnd) : '');
		else if (iStart2>-1)
			sResult = sResult.substr(0, iStart2+1)+(iEnd>-1 ? sResult.substr(iEnd+1) : '');
	}
	else
	{
		var iStart = (iStart2>-1 ? iStart2 : iStart1);

		if (iStart>-1)
			sResult = sResult.substr(0, iStart+1)+sVar+'='+sValue+(iEnd>-1 ? sResult.substr(iEnd) : '');
		else
		{
			sResult += (sResult.indexOf('?')>-1 ? '' : '?');
			sResult += (sResult.charAt(sResult.length-1)=='?' ? '' : '&')+sVar+'='+sValue;
		}
	}

	return sResult;
}
