// Ver 2.0.110925 mod smartsite

function feedback(processor, actionclass, container) {

	this.processor = processor;
	this.actionclass = actionclass;
	this.container = $("#" + container);

}

feedback.prototype.disable = function(flag) {

	this.container.find("*").attr("disabled", flag);

}

feedback.prototype.error = function(msg) {

	if ($.fn.baloon)
		$.fn.baloon(msg, this.container.find("input:submit,input:image"));
	else
		alert(msg);

}

feedback.prototype.send = function(form) {

	var that = this;

	this.disable(true);

	var data = {
		src: "ajax",
		action: "send",
		actionclass: this.actionclass
	};

	$(form).find("input,textarea").each(function() {

		data[this.name] = this.value;

	});

	$.ajax({
		url: this.processor,
		type: "POST",
		data: data,
		error: function(jqXHR, textStatus, errorThrown) {

			that.error(textStatus);
			that.disable(false);

		},
		success: function(res) {

			if (res.indexOf("Error:") == 0)
				that.error(res.substr(7));
			else if (res.indexOf("You have an error") == 0)
				that.error(res);
			else
				that.container.find(".form1").html(res);

			that.disable(false);

		}
	});

	return false;

}

