﻿
function UpdateForm(formId, updateId) {
	if ($(formId)) {
		$(formId).addEvent('submit', function(e) {

			this.set('send', {onComplete: function(response) {
				$(updateId).set('html', response);
			}});

			this.send('/ajaxcontent.ajax');
			return false;
		});
	}
}

function AjaxSubmit(formId, updateId) {
	if ($(formId)) {
		$(formId).set('send', {onComplete: function(response) {
				$(updateId).set('html', response);
			}});

		$(formId).send('/ajaxcontent.ajax');
	}
	else {
		alert('Form not found: ' + formId);
	}
	return false;
}

function Update(htmlId, arguments, action) {
	if ($(htmlId)) {
		var request = new Request.HTML({method: 'get', url: '/ajaxcontent.ajax', onSuccess: function(html) {
			$(htmlId).set('text', '');
			$(htmlId).adopt(html);
		}, onFailure: function() {
			$(htmlId).set('text', 'The action failed!');
		}});
		if (arguments.length > 0) {
			arguments += '&';
		}
		arguments += 'Action=' + action;
		//$(htmlId).get('load', )
		request.send(arguments);
	}
}
