function EditDate (id) { var id = id; this.onload = function () { var self = this; setTimeout (function () {self.setValue (self.defaultValue); hasChanged (id, true, true);}, 0); } this.setValue = function (value) { new Form ().set ("value["+id+"]", value); } this.getValue = function () { return new Form ().get ("value["+id+"]"); } this.setUpdateValue = function (obj, value) { var request = new Ajax ("tpl_edit_action.php", "action=date&tabid="+id+"&value="+value); request.onCompletion = function (response) { obj.innerHTML = response; document.getElementById ("value["+id+"]").className = (response == value) ? "error" : ""; } request.run (); } this.insertText = function (text) { var input = document.getElementById ("value["+id+"]"); var start = input.selectionStart; var end = input.selectionEnd; input.value = input.value.substr (0, start) + text + input.value.substr (end); input.selectionStart = input.selectionEnd = start + text.length; } this.focus = function () { new Form ().focus ("value["+id+"]"); } }