(function() {
	function IEInstallButtonFix(jForm, buttons) {
		function doSubmit(name, value) {
			//alert("doSubmit(" + name + ", " + value + ")");
			var hidden = jQuery(jForm.append("<input type='hidden' />").get(0).lastChild);
			hidden.attr("name", name).attr("value", value);
			jForm.submit();
			hidden.remove();
			return true;
		};

		buttons.each(function() {
			var jThis = jQuery(this);
			jThis.after("<a>" + jThis.html() + "</a>");
			var jLink = jQuery(jThis.get(0).nextSibling);
			jLink.attr("class", jThis.attr("class")).css("cursor", "pointer");
			var name = jThis.attr("name");
			var value = jThis.attr("value");
			jLink.click(function() { return doSubmit(name, value); });
			jThis.remove();
		});
	}

	jQuery.fn.extend({
		IEButtonFix: function() {
			this.each(function() {
				var jThis = jQuery(this);
				if (this.nodeName.toLowerCase() == "form") {
					//alert("IEButtonFix:submitbutton");
					IEInstallButtonFix(jThis, jThis.find("button[@type='submit']"));
				} else if (this.nodeName.toLowerCase() == "button") {
					//alert("IEButtonFix:exact");
					IEInstallButtonFix(jQuery(this.form), jThis);
				} else {
					//alert("IEButtonFix:allform");
					jThis.find("form").IEFixButton();
				}
			});
			return this;
		}
	});
})();
