/*************************************************************************** * * Common javascript functions - applies across pages * * Dependencies: prototype.js, openrico.js ***************************************************************************/ String.prototype.capitalize = function() { var val = this; var newVal = ""; val = val.split(' '); for(var c=0; c < val.length; c++) { newVal += val[c].substring(0,1).toUpperCase() + val[c].substring(1,val[c].length) + ' '; } return newVal; } document.getElementsByTagAndClassName = function(tagName, className) { if ( tagName == null ) tagName = '*'; var children = document.getElementsByTagName(tagName) || document.all; var elements = new Array(); if ( className == null ) return children; for (var i = 0; i < children.length; i++) { var child = children[i]; var classNames = child.className.split(' '); for (var j = 0; j < classNames.length; j++) { if (classNames[j] == className) { elements.push(child); break; } } } return elements; } /* ------Style Sheet Switch ----------------------------------------------*/ /** * Switches style sheets * From A List Apart http://www.alistapart.com/articles/alternate/ */ function setActiveStyleSheet(title) { var i, a, main; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { a.disabled = true; if(a.getAttribute("title") == title) a.disabled = false; } } } /** * Changes the skin preference. * Saves skin preference as a cookie, and loads new skin * @param id - the cookie name to set pref under (this allows you to set * different skins for different sections of the site * @param skin - the name of the skin */ function setSkinByID(id, skin) { setCookie(id, skin, getExpDate(120,0,0)); //getExpDate in cookies.js setActiveStyleSheet(skin); } /** * Changes the skin preference. * Saves skin preference as a cookie, and loads new skin */ function setSkin(title) { setSkinByID("skin", title); } /** * Initialize skin preference. * Retrieves skin preference from cookie, and loads new skin. */ function initSkinPref(id) { var skin = getCookie(id); if (skin != null && skin.length>0){ setSkinByID(id, skin); } } /* ------ Form Validation & error handling ----------------------------------------------*/ var ErrorDisplay = { showErrors: function(errorCollector, errorElem) { var s = "
Please correct the following errors and submit the form again:
"; s += "