jQuery.fn.forma=function ()
{
	$(this).each(function ()
	{
		var _form=this;
		
		// Data
			if ($.fn.attachDatepicker)
			{
				$(this).find(".input[tip=data]").attachDatepicker();
			}
		// Data End
		
		// File
			if ($.fn.input_file)
			{
				$(this).find(".input_file").input_file();
			}
		// File End
		
		// Tini
			if ($.fn.input_file)
			{
				$(this).find(".tini").input_tini();
			}
		// Tini End
		
		// Submit button
			$(this).find(".submit").hoverClass("submit_over").each(function ()
			{
				if ($(this).width()<150)
				{
					$(this).width(150);
				}
			});
		// Submit button End
		
		// Cancel button
			$(this).find(".cancel").hoverClass("cancel_over").each(function ()
			{
				if ($(this).width()<150)
				{
					$(this).width(150);
				}
			});
		// Cancel button End
		
		// Submit
			$(this).submit(function ()
			{
				// File Upload
					var _upload_file=$(this).find(".gotov_k_zagruzke:first");
					if ((1)&&($(_upload_file).length))
					{
						// Когда скрыт, надо показать, а то возникает ошибка
							var _vis_hid=$(_upload_file).closest(".dop_pola_vis");
							if ($(_vis_hid).length)
							{
								$(_vis_hid).removeClass('hid').show().css('position', 'fixed').css('opacity', 0).fadeOut(110)/*.css('left', screen.width)*/.oneTime(100, function ()
								{
									$(this)/*.css('left', screen.width)*/;
									input_file_upload_start($(_upload_file).attr("_id"));
								});
							}
						// Когда скрыт, надо показать, а то возникает ошибка End
						
						// Не скрыт, все в порядке
							else
							{
								input_file_upload_start($(_upload_file).attr("_id"));
							}
						// Не скрыт, все в порядке
						return false;
					}
				// File Upload End
				
				// Nado
					var form_ok=true;
					$(this).find(".input[nado], .check[nado]").each(function ()
					{
						var input_ok=true;
						
						if ($(this).attr("nado")==1)
						{
							if ($(this).val()=='') { input_ok=false; }
						}
						
						if ($(this).attr("nado")=='check')
						{
							if (!$(this).is(":checked")) { input_ok=false; }
						}
						
						// Ok
							if (input_ok)
							{
								$(this).closest(".forma_blok").removeClass("form_no");
							}
						// Ok End
						
						// No
							else
							{
								$(this).closest(".forma_blok").addClass("form_no");
								form_ok=false;
							}
						// No End
					});
					
					if (!form_ok)
					{
						alert($(_form).attr("_alert"));
					}
					
					// Ajax
						if ((form_ok)&&($(this).attr("_ajax")==1))
						{
							var _action=$(this).attr("action");
							var _serialize=$(this).serialize();
							var _div=$(this).closest(".ajax");
							//$(this).load();
							if (submit_load_swf!=undefined)
							{
								$(this).find(".submit").submit_load();
							}
							
							if (pop_test)
							{
								$.post(_action, _serialize, function (ob)
								{
									alert(ob);
								});
							}
							
							$.post(_action, _serialize, function (ob)
							{
								if (submit_load_swf!=undefined)
								{
									$(this).find(".submit").submit_unload();
								}
								$(_div).ajax_ob(ob);
							}, "json");
							
							return false;
						}
					// Ajax End
					
					return form_ok;
				// Nado End
			});
		// Sumbit End
	});
	
	return this;
};
