var eventForm; var App_Event_Form = Class.create(); App_Event_Form.prototype = { formNode: null, tableNode: null, _seoFieldClasses: ['title', 'metakeywords', 'metadescription'], _newDocRows: ['new_doc_name', 'new_doc_number', 'new_renewal_date', 'new_ce_hours', 'new_status_id'], _existingDocRows: ['doc_number', 'ce_credits', 'doc_status_id'], initialize: function (idForm) { this.formNode = document.getElementById(idForm); this.tableNode = getParentTag(this.formNode, 'TABLE'); $('input[name=doc_action]:radio').click(function() {this.blur()}).change(function() {eventForm.docActionOnChange()}); this.typeOnChange(this.formNode.id_type); this.educationEventOnChange(document.getElementById('education')); }, docActionOnChange: function () { if ('new' == $('input[name=doc_action]:radio:checked').val()) { this.getNewDocRows().show(); this.getExistingDocRows().hide(); } else { this.getNewDocRows().hide(); this.getExistingDocRows().show(); } }, getNewDocRows: function() { return this.getRows(this._newDocRows); }, getExistingDocRows: function() { return this.getRows(this._existingDocRows); }, getRows: function (array) { if (!is_array(array) || empty(array)) { return $([]); } return $('tr.' + implode(', tr.', array), this.tableNode); }, typeOnChange: function (element) { var hideAll = ['nonmember_cost', 'group_name', 'group_limit', 'list_foursomes']; var showMap = { 1: [], 2: ['nonmember_cost'], 3: ['nonmember_cost'], 4: ['group_name', 'group_limit', 'list_foursomes'] }; this.getRows(hideAll).hide(); if (typeof showMap[element.value] != 'undefined') { this.getRows(showMap[element.value]).show(); } }, educationEventOnChange: function (element) { var selector = this.getRows(['groupDocCourse']); if (element.checked) { selector.show(); this.docActionOnChange(); } else { selector.hide(); this.getRows(['doc_number', 'ce_credits']).hide(); this.getNewDocRows().hide(); this.getExistingDocRows().hide(); } }, getSeoRows: function () { return this.getRows(this._seoFieldClasses); }, hideSeoRows: function() { this.getSeoRows().hide(); }, showSeoRows: function() { this.getSeoRows().show(); } }; // ---------------------------------- // Below the old not refactored code // ---------------------------------- var AddFormWindow=false; function donewform(url) { var width = 800; var height = 600; AddFormWindow = window.open(url, "AddFormWindow", "scrollbars=1;toolbar=0;width="+width+";height="+height) ; AddFormWindow.moveTo(100, 100); AddFormWindow.resizeTo(width, height); AddFormWindow.focus(); } window.onfocus = function() { if (typeof AddFormWindow.closed != "undefined" && !AddFormWindow.closed ){ AddFormWindow.focus(); } return true; }; function addform(id,name) { var formselect=document.getElementById('form_select'); var newoption=document.createElement('option'); newoption.text=name; newoption.value=id; try {formselect.add(newoption,null);} // standards compliant catch(ex) {formselect.add(newoption);} // IE only formselect.value=id; } function hideteaminfo() { $('#newteam').parent().parent().hide(); $('#exisitingteam').parent().parent().hide(); } function showteaminfo() { hideteaminfo(); $('#' + document.getElementById('registertype').value).parent().parent().show(); } function addanotheruser(button) { var tbl = getParentTag(button, 'TABLE'); row=tbl.insertRow(tbl.rows.length-2); row.className='anotheruser'; labelCell=row.insertCell(0); labelCell.className='form_tbl_label'; labelCell.innerHTML='Email'; inputCell=row.insertCell(1); inputEmail=document.createElement('input'); inputEmail.className='inp_width'; inputEmail.name='anothermember_emails[]'; inputCell.appendChild(inputEmail); } function setautocomplete() { $("#member").autocomplete("admin/event/report?action=showmember&id_event="+id_event, { width: 300, selectFirst: true, max:100 }); $("#member").result(function(event, data, formatted) { if (data) $("#member_id").val(data[1]); if (data) $("input[name='amount']").val(data[2]); }); } function getDOCInfo() { if ($('#education').get(0).checked) { $('#doc_number + div').remove(); $('#doc_number').after('