/** For purposes of starting to impose a little order, below is a list of DOM modifications: All form elements with labels link back to them. All form labels gain an extra empty text node for error text. window.onload is overridden All text areas with a maximum length must set it in the variable textLengthLimit (name picked to avoid collisions) textarea onchange is currently set to inputCount function if textLengthLimit is set. **/ if(window.IE===undefined) IE = false; function _ID(id) {return document.getElementById(id);} function _NODE(s) {return document.createElement(s); } var TRIM = new RegExp('^\\s*|\\s*$','g') var LINNL = new RegExp('([^\r])\n','g'); var LINNL2 = new RegExp('\n\n','g'); var LINNL3 = new RegExp('^\n'); var MACNL = new RegExp('\r([^\n])','g'); var MACNL2 = new RegExp('\r\r','g'); var MACNL3 = new RegExp('\r$'); // this deliberately does not play nice with any existing onload. window.onload = function() // global window onload { var a = document.getElementsByTagName("a"); for(var i=0;i 1000000) // IE is kind of an idiot about this, looks like it sets it to some maxint value, but not going to take its word for it if (e.textLengthLimit > 1000000) e.textLengthLimit = null; t = document.createTextNode(""); e.errorText = l[i].appendChild(t); e.labelRef = l[i]; if (e.textLengthLimit!==undefined) if (e.nodeName.toLowerCase()=='textarea') e.onkeyup = inputCount; // used to start lines with * to require them - could possibly handle both // if (l[i].firstChild.data.charAt(0)=="*" && e.required===undefined) if (/^\s*\*/.test(l[i].firstChild.data) && e.required===undefined) e.required = true; else if (l[i].firstChild.data.indexOf("(required)")!=-1 && e.required===undefined) { l[i].firstChild.data = l[i].firstChild.data.replace(/\s*\(required\)/,''); e.required = true; } setErrorDefault(e); } } } function getXHR() { var xhr; try { xhr=new XMLHttpRequest; } // necessary due to IE7 not responding properly to an XMLHttpRequest defined check catch (e) { try { xhr=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xhr=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xhr = false; } } } return xhr; } function removeClass(e,c) { if (!e.className) return; e.className = e.className.replace(new RegExp("(^|\\s+)"+c),''); } function addClass(e,c) { if (!e.className) e.className = c; else if (!hasClass(e,c)) e.className += " "+c; } function hasClass(e,c) { if (!e.className) return false; return (new RegExp("(^|\\s+)"+c+"(\\s+|$)")).test(e.className); } function delayedReload(x) { setTimeout(function() { window.location.reload(true) }, x); } function closeRefresh() { if (opener && !opener.closed) opener.delayedReload(500); close(); } /******************** general form manipulation *******************************/ function inputCount() { txt = dosnl(this.value); this.errorText.data = ' ('+txt.length+' of '+this.textLengthLimit+')'; if(txt.length>this.textLengthLimit) this.errorText.data+='!!!'; } // can't do as a prototype due to a flaw in IE function formValue(e) { if(!e) return null; if (e.options) { if (e.selectedIndex==-1) return null; else return e.options[e.selectedIndex].value; } else if (e.length) { for(var i=0;i