
// Add a function called trim as a method of the prototype object of the String constructor
String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.trimcrlf = function()
{
	return this.replace(/\r\n/, "");
}

//
function Date4Sql(d)
{
	return d.getFullYear()+"/"+(d.getMonth()+1)+"/"+d.getDate()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
}

//
function ChkAndTrim( oObj )
{
	var s = new String(oObj.value).trim();
	oObj.value = s;
	return s.length > 0;
}
//
function ChkAndTrimNum( oObj )
{
	var n = parseInt( oObj.value );
	if( isNaN(n) ||  n <= 0 )
	{
		oObj.value = 0;
		return 0;
	}
	oObj.value = n;
	return n;
}

//
function OnLinkIn(o)
{
	o.style.cursor = "hand";
	o.style.textDecorationUnderline = true;
	o.style.letterSpacing = "1px";
	o.title = o.innerText;
}
function OnLinkOut(o)
{
	o.style.cursor = "auto";
	o.style.textDecorationUnderline = false;
	o.style.letterSpacing = "0px";
}

var crOldBg;

function OnRowIn(o)
{
	crOldBg = o.style.backgroundColor;
	o.style.backgroundColor = "#F0F0CC";
	o.style.cursor = "hand";
}
function OnRowOut(o)
{
	o.style.backgroundColor = crOldBg;
}
