
function getDateObject(oHtml)
{
	if(!oHtml || !oHtml.oUp || oHtml.value==""){return null;}
	return oHtml.oUp.setDateObjectFromLocal(oHtml.value);
}
function getNumberObject(oHtml)
{
	if(!oHtml || !oHtml.oUp || oHtml.value==""){return null;}
	return oHtml.oUp.toJSNumber(oHtml.value);
}
function getIntegerStringByLocal(strValue)
{
	var oInt = new upIntegerControl();
	return oInt.toJSNumber(strValue);
}
function getFloatStringByLocal(strValue)
{
	var oFloat = new upFloatControl();
	return oFloat.toJSNumber(strValue);
}
function getCurrencyStringByLocal(strValue)
{
	var oCurr = new upCurrencyControl();
	return oCurr.toJSNumber(strValue);
}
function toLocalString(oHtml, obj)
{
	if(!obj || !oHtml || !oHtml.oUp){return null;}
	return oHtml.oUp.toLocalFormat(obj);
}
function writeLocalString(oHtml, obj)
{
	if(!obj || !oHtml || !oHtml.oUp){return false;}
	Browser.setValue(oHtml.oUp, oHtml.oUp.toLocalFormat(obj));
	return true;
}
function checkRequired(oHtml, strMessage)
{
	if(!oHtml || !oHtml.oUp){return false;}
	if(arguments.length<2)strMessage="";
	if(!oHtml || !oHtml.oUp){return false;}
	return oHtml.oUp.validateRequired(strMessage);
}
function getLocalDurationString(oHtmlDateFrom, oHtmlDateTo)
{
	if(!oHtmlDateFrom || !oHtmlDateFrom.oUp || !oHtmlDateTo || !oHtmlDateTo.oUp){return false;}
	var iDiff = Date.parse(getDateObject(oHtmlDateTo)) - Date.parse(getDateObject(oHtmlDateFrom));
	var oDateDiff = new Date();
	oDateDiff.setTime(Math.abs(iDiff));
	return oHtmlDateFrom.oUp.toLocalDurationString(oDateDiff);
}
function calculate(oHtml1, oHtml2, strOp, oHtmlResult)
{
	if(Browser.handleException)
	{
		try
		{
			if(!oHtml1 || !oHtml1.oUp || !oHtml2 || !oHtml2.oUp || !strOp || !oHtmlResult || !oHtmlResult.oUp){return false;}
			return oHtmlResult.oUp.calcValue("F" + oHtml1.name + "|" + strOp + "|" + "F" + oHtml2.name);
		}
		catch(e)
		{	if(e instanceof upException)
			{
				var toAlert = e.message;
				if(e.oControl && e.oControl.userName && e.oControl.userName!="")
				{
					toAlert = toAlert + "\n\(" + e.oControl.userName + "\)";
				}
				if(e.info && e.info!="")
				{
					toAlert = toAlert + "\n\(" + e.info + "\)";
				}
				alert(toAlert);
			}
			else
			{
				alert(Browser.getExceptionMessage(e));
			}
			return false;
		}	
	}
	else
	{
		if(!oHtml1 || !oHtml1.oUp || !oHtml2 || !oHtml2.oUp || !strOp || !oHtmlResult || !oHtmlResult.oUp){return false;}
		return oHtmlResult.oUp.calcValue("F" + oHtml1.name + "|" + strOp + "|" + "F" + oHtml2.name);
	}
}
function setTextValueById(id, strValue)
{
	return setTextValue(document.getElementById(id), strValue);
}
function setTextValue(oHtml, strValue)
{
	if(!oHtml)return false;
	if (oHtml.innerHTML)
	{
		oHtml.innerHTML = strValue;
		return true;
	}
	else if (oHtml.firstChild && oHtml.firstChild.nodeValue)
	{
		oHtml.firstChild.nodeValue = strValue;
		return true;
	}
	return false;
}
function getTextValueById(id)
{
	return getTextValue(document.getElementById(id));
}
function getTextValue(oHtml)
{
	if(!oHtml)return false;
	if (oHtml.innerHTML)
	{
		return oHtml.innerHTML;
	}
	else if (oHtml.firstChild && oHtml.firstChild.nodeValue)
	{
		return oHtml.firstChild.nodeValue;
	}
	return "";
}
function setFullDays(oHtmlCheck, oHtmlFrom, oHtmlTo)
{
	if(!oHtmlCheck.checked)
	{
		oHtmlFrom.disabled = false;
		oHtmlTo.disabled = false;	
		return;
	}
	if(oHtmlFrom.value=="")
	{
		oFrom = new Date();
	}
	else
	{
		oFrom = oHtmlFrom.oUp.setDateObjectFromLocal(oHtmlFrom.value);
	}	
	oFrom.setHours('00');
	oFrom.setMinutes('00');
	oFrom.setSeconds('00');
	oHtmlFrom.value = oHtmlFrom.oUp.toLocalFormat(oFrom);	
	if(oHtmlTo.value=="")
	{
		oTo = oHtmlTo.oUp.initDateObject();
		oTo.setDate(parseInt(oFrom.getDate(), 10) + 1);	
		oTo.setMonth(oFrom.getMonth());	
		oTo.setFullYear(oFrom.getFullYear());	
	}	
	else
	{
		oTo = getDateObject(oHtmlTo);	
		if(!(oTo.getHours()=="00" && oTo.getMinutes()=="00" && oTo.getSeconds()=="00"))
		{
			oTo.setDate(parseInt(oTo.getDate(), 10) + 1);	
		}
	}
	oTo.setHours('00');
	oTo.setMinutes('00');
	oTo.setSeconds('00');
	oHtmlTo.value = oHtmlTo.oUp.toLocalFormat(oTo);
	return;
}
function dateComparedToNow(p_oDate)
{
	if(p_oDate && p_oDate.value != "" && p_oDate.oUp && (p_oDate.oUp.upType=="upDateTimeControl" || p_oDate.oUp.upType=="upDateControl" || p_oDate.oUp.upType=="upTimeControl"))
	{
		var dCurrentDate = p_oDate.oUp.setDateObjectFromLocal(p_oDate.oUp.getCurrDate());
		var dInputDate = getDateObject(p_oDate);
		if( dCurrentDate > dInputDate )
			return 0;
		else if( dCurrentDate < dInputDate )
			return 2;
		else if( dCurrentDate == dInputDate )
			return 1;
		else
			return -1;
	}
	else
	{
		return -1;
	}
}