LibManager.require("dom"); function attachHotelRoomValidators() { if (document.getElementsByTagName) { var a = window.document.getElementsByTagName("form"); hRForms = []; for (var b = 0; b < a.length; b++) if (a[b].id.match(/hotelForm_[0-9]+/)) { hRValid = new hRValidator(a[b].id); hRForms[hRValid.id] = hRValid; Event.observe(hRValid.form, "submit", hRSubmit, false) } } } function hRSubmit(a) { var b = Event.element(a), c = false; if (b.id) c = hRForms[b.id].hRValidateRooms(); c || Event.stop(a) }
function hRValidator(a) { this.id = a; this.form = document.getElementById(a); this.xUA = navigator.userAgent.toLowerCase(); if (document.all && this.xUA.indexOf("msie") != -1) { xIE4 = this.xUA.indexOf("msie 4") != -1; xIE5 = this.xUA.indexOf("msie 5") != -1 } this.hasError = false; this.hRValidateRooms = hRValidateRooms; this.hRRaiseError = hRRaiseError; this.hRClearError = hRClearError; this.hRGetElementsByTagName = hRGetElementsByTagName }
function hRValidateRooms() { for (var a = document.getElementsByClassName(this.form, "roomSel"), b = false, c = 0; c < a.length; c++) if (a[c].selectedIndex != 0) { b = true; break } if (b) { this.hasError && this.hRClearError(); return true } else { this.hasError || this.hRRaiseError(); return false } } function hRGetElementsByTagName(a, b) { var c = null; if (this.xIE4 || this.xIE5) c = b.all.tags(a); else if (b.getElementsByTagName) c = b.getElementsByTagName(a); return c || [] }
function hRRaiseError() { var a = this.hRGetElementsByTagName("table", this.form)[0]; Element.addClassName(a, "error"); a = this.hRGetElementsByTagName("tbody", a)[0]; var b = document.createElement("tr"); b.className = "errormsg"; var c = document.createElement("td"); c.colSpan = 4; c.width = "100%"; var e = document.createElement("span"); e.className = "errormsg"; var d = $j("#roomValidationMsg"); d = d.length ? d.val() : ""; d = document.createTextNode(d); e.appendChild(d); c.appendChild(e); b.appendChild(c); a.appendChild(b); this.hasError = true }
function hRClearError() { this.hasError = false; var a = this.hRGetElementsByTagName("table", this.form)[0]; Element.removeClassName(a, "error"); a = this.hRGetElementsByTagName("tbody", a)[0]; a.removeChild(a.childNodes[a.childNodes.length - 1]) } $j(function() { attachHotelRoomValidators(); $j(".sortBy").length > 0 && $j(".sortBy").change(function() { $j(this).parent().parent().submit() }) });