////////////////////////////////////////////////////////////////////////
function attachObjEvent(oObject, oEvent, oFunction)
{
	if(document.all)
	{
		oObject.attachEvent("on" + oEvent, oFunction);
	}
	else
	{
		oObject.addEventListener(oEvent, oFunction, false);
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkRegExp(str, pattern)
{
	reg = new RegExp(pattern);	
	
	if (reg.exec(str))
	{			
		ret = (RegExp.$1 == str);
	}
	else
	{
		ret = false;
	}

	return ret;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkNumber(str)
{
	return checkRegExp(str, "([0-9]\\d*)");
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkUInt(str)
{
	return checkRegExp(str, "(([1-9]\\d*)|(0))");
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkUFloat(str, decimals)
{
	if(decimals == 0)
	{
		if (checkUInt(str))
		{			
			ret = true;
		}
		else if (checkRegExp(str, "(([1-9]\\d*\\.\\d*)|(0\\.\\d*))"))
		{
			ret = true;
		}
		else
		{
			ret = false;
		}
	}
	else
	{	
	    if (checkUInt(str))
		{
			ret = true;
		}				    
		else if (checkRegExp(str, "(([1-9]\\d*\\.\\d{0," + decimals + "})|(0\\.\\d{0," + decimals + "}))"))
		{
			ret = true;
		}		
		else
		{
			ret = false;
		}		
	}
	
	return ret;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkCustom(str, pattern)
{
	return checkRegExp(str, "([" + pattern + "]+)");
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkEditKey(keycode)
{
	return keycode == 8 || keycode == 46 || keycode == 37 || keycode == 38 || keycode == 39 || keycode == 40;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function onKeyPressUIntTextBox(str, e)
{
    var keyCode = e.which ? e.which : e.keyCode;    
    return checkUInt(str + String.fromCharCode(keyCode));
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function onKeyPressUFloatTextBox(decimals, str, e)
{
    var keyCode = e.which ? e.which : e.keyCode;    
    return checkUFloat(str + String.fromCharCode(keyCode), decimals);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function onKeyPressCustomTextBox(pattern, str, e)
{
    var keyCode = e.which ? e.which : e.keyCode;    
    return checkCustom(str + String.fromCharCode(keyCode), pattern);
}