function inputRestrict(field, e, type)
{
  var key;
  var keychar;
  
  if (window.event)
    key = window.event.keyCode;
  else if (e)
    key = e.which;
  else
    return true;
  keychar = String.fromCharCode(key).toLowerCase();
  
  // control keys
  if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
  {
    return true;
  }
  else
  {
	// specific type keys
    if(type == "phone" && (("0123456789+/ ").indexOf(keychar) > -1))
      return true;
    else if(type == "email" && (("abcdefghijklmnopqrstuvwxyz@._-0123456789").indexOf(keychar) > -1))
      return true;
    else if(type == "url" && (("0123456789abcdefghijklmnopqrstuvwxyz:./@").indexOf(keychar) > -1))
      return true;
    else if(type == "alpha" && (("abcdefghijklmnopqrstuvwxyz").indexOf(keychar) > -1))
      return true;
    else if(type == "alphanumeric" && (("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1))
      return true;
    else if(type == "number" && (("-0123456789").indexOf(keychar) > -1))
      return true;
	else if(type == "unumber" && (("0123456789").indexOf(keychar) > -1))
      return true;  
    else if(type == "decimal" && (("-0123456789.").indexOf(keychar) > -1))
      return true;
	else if(type == "udecimal" && (("0123456789.").indexOf(keychar) > -1))
      return true;  
  }
  
  return false;
}

function trim(str)
{
  var str = str.replace(/^\s\s*/, ''), ws = /\s/, i = str.length;
  while (ws.test(str.charAt(--i)));
  return str.slice(0, i + 1);
}