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 limitcheck(idof,lower,msg,higher,msg1)
	{
		if(document.getElementById(idof).value.length<lower)
		{
			alert(msg);
			document.getElementById(idof).focus();
	//		retval=false;
			return false;
		}
	if(document.getElementById(idof).value.length>higher)
		{
			alert(msg1);
			document.getElementById(idof).focus();
	//		retval=false;
			return false;
		}

	}

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 emailchk(emailid,msg)
{
			str=document.getElementById(emailid).value;
			var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	        if(str.match(emailExp)==null)	
	        {
		        alert("Invalid E-Mail ID"); 
				document.getElementById(emailid).focus();
				 return (false);
	        }
/*
	if(str.length>200)
		{
			alert(msg);
			return (false);
		}*/

}

function numberpho(idval,msg)
{
 var numericExp = /^[0-9+-]+$/;
	  if (document.getElementById(idval).value.match(numericExp)==null)
		   {
			alert(msg); 
//			document.getElementById('Telephone').value="";
			document.getElementById(idval).focus();
			return (false);
		   }
}

/*function multiphone(idof,msg)
  {
	  var numericExp = /^[0-9-,\/\]+$/;

if ((document.getElementById(idof).value.match(numericExp)==null)	&& (document.getElementById(idof).value.length>0))
   {
	    alert(msg); 
		document.getElementById(idof).value="";
		document.getElementById(idof).focus();
		return false;
    }

  }*/
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 ;
  }	
  
  
  function numberonly(idof,msg)
  {
	  var numericExp = /^[0-9]+$/;

if ((document.getElementById(idof).value.match(numericExp)==null)	&& (document.getElementById(idof).value.length>0))
   {
	    alert(msg); 
		document.getElementById(idof).value="";
		document.getElementById(idof).focus();
		return false;
    }

  }
  
  function charaonly(idof,msg)
  {
	  var numericExp = /^[a-zA-Z]+$/;

if ((document.getElementById(idof).value.match(numericExp)==null)	&& (document.getElementById(idof).value.length>0))
   {
	    alert(msg); 
		document.getElementById(idof).value="";
		document.getElementById(idof).focus();
		return false;
    }

  }

function chkpasslength(idof,msg)
{
	var len=document.getElementById(idof).value.length;
	if(len<5)
		 {
			 alert(msg);
			 document.getElementById(idof).focus();
			 return (false);
		 }
}

function domainchk(emailid,msg)
{
			strone=document.getElementById(emailid).value;
			str44=strone.split("/");
			str=str44[0];
			var emailExp = /^[\w\-\.\+]+\.[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	        if(str.match(emailExp)==null)	
	        {
		        alert(msg); 
				document.getElementById(emailid).focus();
				 return (false);
	        }
}
