﻿
function getById(id) {
	return document.getElementById(id);
}
function ajaxButtonClick(id) {
	var elem = getById(id);

	elem.parentNode.className = 'ajaxButtonDisabled';

	var save = elem.innerHTML;

	elem.outerHTML = '<a id="' + id + '">' + save + '</a>';
}
function disableAjaxButton(button) {
	button.parentNode.className = 'ajaxButtonDisabled';

	var onClick = button.getAttribute("onclick");

	alert(onClick);
}
function enableAjaxButton(id) {
	var button = getById(id);

	button.parentNode.className = 'ajaxButton';

	var onClick = new String(button.getAttribute("onclick"));

	button.setAttribute("onclick", onClick.replace("return false;", ""));
}

function getOuterHTML(id) {

	return getById(id).outerHTML;
}
function setOuterHTML(id, outer) {

	getById(id).outerHTML = outer;
}
function FormButtons(resetId, saveId) {
	this.resetId = resetId;
	this.saveId = saveId;

	this.onChange = function () {
		if (getById(this.resetId).parentNode.className == 'ajaxButtonDisabled') {
			enableAjaxButton(this.resetId);
			enableAjaxButton(this.saveId);
		}
	}
	this.postBack = function () {
		if (this.field.value == "") {
			disableAjaxButton(this.resetId);
			disableAjaxButton(this.saveId);

		}
	}

}
