// jQuery Custom Plugins/Functions

(function( $ ) {
	var cache = [];
	// Arguments are image paths relative to the current page.
	$.preLoadImages = function() {
		var args_len = arguments.length;
		for (var i = args_len; i--;) {
			var cacheImage = document.createElement('img');
			cacheImage.src = arguments[i];
			cache.push(cacheImage);
		}
	};
	// NumericOnly custom plug-in
	$.fn.numericOnly = function() {
		return this.each(function() {
			$(this).keydown(function(e) {
				var key = e.charCode || e.keyCode || 0;
				// Allow backspace, tab, del, arrows, numbers, keypad numbers, and enter key
				// Allow period and num decimal if has class "decimal" and doesn't already have a "."
				var allow_decimal = $(this).hasClass('decimal') && $(this).val().indexOf('.') < 0;
				return (
					 key ==  8 ||
					 key ==  9 ||
					 key == 13 ||
					 key == 46 ||
					(allow_decimal ? (key == 110 || key == 190) : false) ||
					(key >= 35 && key <=  40) ||
					(key >= 48 && key <=  57) ||
					(key >= 96 && key <= 105)
				);
			});
		});
	};
})( jQuery );

