﻿/*
* Numberformatter (v 1.1.2) jquery plugin customizations
*
* 2009 Andrey Tselishev
*/
(function(jQuery) {
	// Make numeric input field localized
	// Author: Andrey Tselishev
	jQuery.fn.formatter = function() {
		return this.each(function() {
			var value = $(this).val();
			var id = $(this).attr('id');
			var name = $(this).attr('name');
			var textId = id + '_Text';
			var textName = name + '_Text';
			// Rename original element
			$(this).attr('id', textId);
			$(this).attr('name', textName);
			// Create hidden one ('id', 'name' and 'value' attributes as in original)
			var hiddenNode = '<input type="hidden" id="' + id + '" name="' + name + '" value="' + value + '" />';
			$(this).after(hiddenNode);
			$(this).change(function() {
				$(this).format();
				var number = $(this).parse();
				$('#' + id).val(number);
			});
			$(this).change();
		});
	}
})(jQuery);

