(function($) {

	$.fn.hexfilter = function(settings) {
		
		// Default settings
		var config = {
			
		};
		
		// Custom settings
		if(settings) $.extend(config, settings);
		
		// Main routine
		this.filter("INPUT[type=text]").each(function(index) {
		
			$(this).attr("autocomplete", "off");
			$(this).attr("maxlength", "16");
			
			$(this).keyup(function() {
				var pattern = /^[0-9A-F]{0,16}$/i;
				if(pattern.test($(this).val())) {
					$(this).data("hex", $(this).val());
				}
				$(this).val($(this).data("hex")!=null?$(this).data("hex").toUpperCase():"");
			});
			
		});
		
		return this;
	}
	
})(jQuery);
