function escapeVal(StingValue,replaceWith)
{ 
 StingValue = escape(StingValue) 
 for(i=0; i<StingValue.length; i++)
 { 
  if(StingValue.indexOf("%0D%0A") > -1)
  { 
   StingValue=StingValue.replace("%0D%0A",replaceWith)
  }
  else if(StingValue.indexOf("%0A") > -1)
  { 
   StingValue=StingValue.replace("%0A",replaceWith)
  }
  else if(StingValue.indexOf("%0D") > -1)
  { 
   StingValue=StingValue.replace("%0D",replaceWith)
  }
 }
 StingValue=unescape(StingValue) 
 return StingValue
}

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}


function ckEnter(event)
{ 	
 NS4 = (document.layers) ? true : false;
 var code = 0;
	
 if (NS4)
 {
  code = event.which;
 }
 else
 {
  code = event.keyCode;
  if (code==13)
  {
   event.keyCode = "";
  }
 }
}

function checkEnter(event)
{ 	
 var code = 0;
 NS4 = (document.layers) ? true : false;
	
 if (NS4)
 {
  code = event.which;
 }
 else
 {
  code = event.keyCode;
  if (code==13)
  {
   event.keyCode = "";
   dosave();
  }
 }
}


function Left(str, n)
{
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n)
{
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function checkemail(EmailValue)
{
 var str=EmailValue;
 var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
 if (filter.test(str))
 {
  testresults=true;
 }
 else
 {
  testresults=false;
 }
 return (testresults);
}

