// JavaScript Document
(function($){
	$.fn.validateNumbers = function (options) {
		config = {};
		$.extend(config, options);
		var row = this;
		$(row).each( function (index, element )
			{
				$(element).focusout(
					function()
					{
						var value = parseInt($(this).val());
						if ( value < options.minValue || value > options.maxValue || ( isNaN(value) && $(this).val() != 'AP' ) )
						{
							$(this).val('');
						}
						else
						{
							if ( $(this).val() == 'AP' )
							{
								value = 'AP';
							}
							else
							{
								$(row).each( function ( rowIndex, rowElement ) 
									{
										if ( $(rowElement).val() == value && rowIndex != index && value != '' )
										{
											value = '';
										}
									}
								);
							}
							$(this).val(value);
						}
					}
				);
			}
		);
	}
})(jQuery);
