/*
 * jQuery Number Input plugin 1.0
 * Released: July 14, 2008
 * 
 * Copyright (c) 2008 Chris Winberry
 * Email: M8R-tk5fe51@mailinator.com
 * 
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * @license http://www.opensource.org/licenses/mit-license.php
 * @license http://www.gnu.org/licenses/gpl.html
 * @project jquery.numberInput
 */
(function($){
	$.fn.numberInput = function() {
		return this.each(function() {
			$(this).keydown(function(event){
				return KEYS_ALLOWED[event.keyCode] ? true : false;
			});
		});
	};
	var KEYS_ALLOWED = {
		   8 : 'BACKSPACE'
		, 13 : 'ENTER'
		, 37 : 'LEFT_ARROW'
		, 39 : 'RIGHT_ARROW'
		, 46 : 'DELETE'
		, 48 : 'ZERO'
		, 49 : 'ONE'
		, 50 : 'TWO'
		, 51 : 'THREE'
		, 52 : 'FOUR'
		, 53 : 'FIVE'
		, 54 : 'SIX'
		, 55 : 'SEVEN'
		, 56 : 'EIGHT'
		, 57 : 'NINE'
		, 96 : 'ZERO' //Keypad
		, 97 : 'ONE' //Keypad
		, 98 : 'TWO' //Keypad
		, 99 : 'THREE' //Keypad
		, 100 : 'FOUR' //Keypad
		, 101 : 'FIVE' //Keypad
		, 102 : 'SIX' //Keypad
		, 103 : 'SEVEN' //Keypad
		, 104 : 'EIGHT' //Keypad
		, 105 : 'NINE' //Keypad
	};
})(jQuery);