function setHiddenValue(button) {
  if (button.name) {
    var q = document.createElement('input');
    q.type = 'hidden';
    q.name = button.name;
    q.value = button.value;
    button.form.appendChild(q);
  }
  return true;
}

function disableSubmit() {
	for(var i=0; i<arguments.length; i++) {
		arguments[i].disabled = true;
		if(arguments[i].id == safeSubmit.element.id) {
			setHiddenValue(arguments[i]);
		}
	}
	return true;
}

var safeSubmit = {
		element : null,
		userFunc : new Array(),
		systemFunc : new Array(),
		notifyClear : function(){},
		
		_click : function(fArray) {
			for(var i = 0; i < fArray.length; i++) {
				if(typeof(fArray[i]) == 'function') {
					//処理打ち切り
					if(!fArray[i](this.element)) {
						return false;
					}
				}
			}
			return true;
		},
		click : function() {
			if(!this._click(this.userFunc)) return false;
			if(!this._click(this.systemFunc)) return false;
			return true;
		},
		clear : function() {
			this.element = null;
			this.systemFunc = new Array();
			this.userFunc = new Array();
			if(typeof(this.notifyClear) == 'function') {
				this.notifyClear();
			}
		},
		
		addListener : function(f) {
			this.userFunc.push(f);
		}
}
