// JavaScript Document
function trim(s)
{
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
	{
                 s = s.substring(1,s.length);
         }
	return s;
}

function checknull(idof,msg)
	{
		retvalof=isnullof(idof,msg);
		if(retvalof==false)
		return retvalof;
		retvalof=isnotnullof(idof,msg);
		if(retvalof==false)
		return (retvalof);
	}
function isselectof(idof,msg)
	{
		if(document.getElementById(idof).value=="0")
		{
			alert(msg);
			document.getElementById(idof).focus();
	//		retval=false;
			return false;
		}
	}

function isnullof(idof,msg)
	{
		var retval=true;
		if(document.getElementById(idof).value=="")
		{
			alert(msg);
			document.getElementById(idof).focus();
			retval=false;
		}
		return (retval);
	}
function isnotnullof(idof,msg)
	{
		var retval=true;
		if(document.getElementById(idof).value!="")
		{
			document.getElementById(idof).value=trim(document.getElementById(idof).value);
			retval=isnullof(idof,msg);
		}
		return (retval);
	}
	
	function textMaxLength(obj, maxLength, evt,msg)
{
    var charCode=(evt.which) ? evt.which : event.keyCode
    var max = maxLength - 0;
    var text = obj.value;
    if(text.length >= max)
    {
       if(charCode==8)
       {
           return true;
       }
	   alert(msg + " can be maximum " + maxLength + " characters.");
       return false;
    }
    else
    {
		return true;
    }
}     

function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length < MaxLen);
}
function fnPaste(sen)
{
   var intMaxLength, intCurrLength, strClip ;
   var intClipLength, intAvailLength ;
   var blnReturn ;

   blnReturn = true ;
   intMaxLength = sen.getAttribute("maxlength") ;
   intCurrLength = sen.value.length ;
   strClip = window.clipboardData.getData("Text") ;
   intClipLength = strClip.length ;
   intAvailLength = intMaxLength - intCurrLength ;

   if (intAvailLength > 0)
     {
       if (intAvailLength < intClipLength)
         {
    	    strClip = strClip.substr(0, intAvailLength) ;
            window.clipboardData.setData("Text",strClip) ;
         }
     }
    else
      {
      blnReturn = false ;
      }
 return blnReturn ;
  }	
  
	
