﻿/*  Prototype JavaScript framework, version 1.5.1.1
 *  (c) 2005-2007 Sam Stephenson
 *
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://www.prototypejs.org/
 *
/*--------------------------------------------------------------------------*/

Object.extend = function(destination, source) {
  for (var property in source) {
    destination[property] = source[property];
  }
  return destination;
}

Object.extend(String.prototype, {  
  strip: function() {
    return this.replace(/^\s+/, '').replace(/\s+$/, '');
  },

  stripSpace: function() {
    return this.replace(/\s/g, '');
  },

  stripTags: function() {
    return this.replace(/<\/?[^>]+>/gi, '');
  },

  blank: function() {
    return /^\s*$/.test(this);
  },

  left: function(length) {
    return this.substr(0, length);
  },

  right: function(length) {
    return this.substr(this.length - length);	 
  }  
});

var KeyCode = {
   engNum: function() {
      var keyCode = event.keyCode;

      event.returnValue = (keyCode == 13 || keyCode >= 48 && keyCode <= 57 || keyCode >= 65 && keyCode <= 90 || keyCode >= 97 && keyCode <= 122);
   },

   engSpace: function() {
      var keyCode = event.keyCode;

      event.returnValue = (keyCode == 13 || keyCode == 32 || keyCode >= 65 && keyCode <= 90 || keyCode >= 97 && keyCode <= 122);
   },

   engNumComma: function() {
      var keyCode = event.keyCode;  

      event.returnValue = (keyCode == 13 || keyCode == 44 || keyCode >= 48 && keyCode <= 57 || keyCode >= 65 && keyCode <= 90 || keyCode >= 97 && keyCode <= 122);
   },

   number: function() {
      var keyCode = event.keyCode;

      event.returnValue = (keyCode == 13 || keyCode >= 48 && keyCode <= 57);
   },

   offSpace: function() {
      event.returnValue = (event.keyCode != 32);
   }
}