function jsTrim(value){
  return value.replace(/(^\s*)|(\s*$)/g,"");
}

function isNULL( chars ) {
	if (chars == null)
		return true;
	if (jsTrim(chars).length==0)
		return true;
	return false;
}

function isValidDecimal( chars ) {
	chars += '';
	var re=/^[\d\.]+$/;
	if (chars.match(re) == null)
		return false;
	else
		return true;
}

function isNumber( chars ) {
	chars += '';
	var re=/^\d+$/;
	if (chars.match(re) == null)
		return false;
	else
		return true;
}

function tkDrawImage(ImgD,FitWidth,FitHeight){
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		if(image.width/image.height>= FitWidth/FitHeight){
			if(image.width>FitWidth){
				ImgD.width=FitWidth;
				ImgD.height=(image.height*FitWidth)/image.width;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		} else{
			if(image.height>FitHeight){
				ImgD.height=FitHeight;
				ImgD.width=(image.width*FitHeight)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		}
	}
} 

function showWW(turl,tname)
{
	document.write('<a href="'+turl+'" target="_blank"><img src="/images/online.gif" border="0" width="77" align="absmiddle" /></a>');
}

function bytes(str)
{
    if(typeof(str)!='string'){
		str = str.value;
	}
	var len = 0;
	for(var i = 0; i < str.length; i++){
		if(str.charCodeAt(i) > 127){
			len++;
		}
		len++;
	}
	return len;
}
function eventLoader(srcPanelId, tarPanelId)
{
    if (document.getElementById(srcPanelId) && document.getElementById(tarPanelId))
    {
        var srcObj = document.getElementById(srcPanelId);
        var tarObj = document.getElementById(tarPanelId);
        tarObj.innerHTML = srcObj.innerHTML;
        srcObj.innerHTML="";
    }
}
