/* This function is used to change the style class of an element */ function swapClass(obj, newStyle) { obj.className = newStyle; } function isUndefined(value) { var undef; return value == undef; } function checkAll(theForm) { // check all the checkboxes in the list for (var i=0;i */ function move(list,to) { var total=list.options.length; index = list.selectedIndex; if (index == -1) return false; if (to == +1 && index == total-1) return false; if (to == -1 && index == 0) return false; to = index+to; var opts = new Array(); for (i=0; i */ function selectAll(elementId) { var element = document.getElementById(elementId); len = element.length; if (len != 0) { for (i = 0; i < len; i++) { element.options[i].selected = true; } } } /* This function is used to select a checkbox by passing * in the checkbox id */ function toggleChoice(elementId) { var element = document.getElementById(elementId); if (element.checked) { element.checked = false; } else { element.checked = true; } } /* This function is used to select a radio button by passing * in the radio button id and index you want to select */ function toggleRadio(elementId, index) { var element = document.getElementsByName(elementId)[index]; element.checked = true; } /* This function is used to open a pop-up window */ function openWindow(url, winTitle, winParams) { winName = window.open(url, winTitle, winParams); winName.focus(); } /* This function is to open search results in a pop-up window */ function openSearch(url, winTitle) { var screenWidth = parseInt(screen.availWidth); var screenHeight = parseInt(screen.availHeight); var winParams = "width=" + screenWidth + ",height=" + screenHeight; winParams += ",left=0,top=0,toolbar,scrollbars,resizable,status=yes"; openWindow(url, winTitle, winParams); } /* This function is used to set cookies */ function setCookie(name,value,expires,path,domain,secure) { document.cookie = name + "=" + escape (value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); } /* This function is used to get cookies */ function getCookie(name) { var prefix = name + "=" var start = document.cookie.indexOf(prefix) if (start==-1) { return null; } var end = document.cookie.indexOf(";", start+prefix.length) if (end==-1) { end=document.cookie.length; } var value=document.cookie.substring(start+prefix.length, end) return unescape(value); } /* This function is used to delete cookies */ function deleteCookie(name,path,domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } // This function is for stripping leading and trailing spaces function trim(str) { if (str != null) { var i; for (i=0; i=0; i--) { if (str.charAt(i)!=" ") { str=str.substring(0,i+1); break; } } if (str.charAt(0)==" ") { return ""; } else { return str; } } } // This function is used by the login screen to validate user/pass // are entered. function validateRequired(form) { var bValid = true; var focusField = null; var i = 0; var fields = new Array(); oRequired = new required(); for (x in oRequired) { if ((form[oRequired[x][0]].type == 'text' || form[oRequired[x][0]].type == 'textarea' || form[oRequired[x][0]].type == 'select-one' || form[oRequired[x][0]].type == 'radio' || form[oRequired[x][0]].type == 'password') && form[oRequired[x][0]].value == '') { if (i == 0) focusField = form[oRequired[x][0]]; fields[i++] = oRequired[x][1]; bValid = false; } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return bValid; } // This function is a generic function to create form elements function createFormElement(element, type, name, id, value, parent) { var e = document.createElement(element); e.setAttribute("name", name); e.setAttribute("type", type); e.setAttribute("id", id); e.setAttribute("value", value); parent.appendChild(e); } function confirmDelete(obj) { var msg = "Are you sure you want to delete this " + obj + "?"; ans = confirm(msg); if (ans) { return true; } else { return false; } } function highlightTableRows(tableId) { var previousClass = null; var table = document.getElementById(tableId); var tbody = table.getElementsByTagName("tbody")[0]; var rows; if (tbody == null) { rows = table.getElementsByTagName("tr"); } else { rows = tbody.getElementsByTagName("tr"); } // add event handlers so rows light up and are clickable for (i=0; i < rows.length; i++) { rows[i].onmouseover = function() { previousClass=this.className;this.className+=' over' }; rows[i].onmouseout = function() { this.className=previousClass }; rows[i].onclick = function() { var cell = this.getElementsByTagName("td")[0]; var link = cell.getElementsByTagName("a")[0]; location.href = link.getAttribute("href"); this.style.cursor="wait"; } } } function highlightFormElements() { // add input box highlighting addFocusHandlers(document.getElementsByTagName("input")); addFocusHandlers(document.getElementsByTagName("textarea")); } function addFocusHandlers(elements) { for (i=0; i < elements.length; i++) { if (elements[i].type != "button" && elements[i].type != "submit" && elements[i].type != "reset" && elements[i].type != "checkbox" && elements[i].type != "radio") { if (!elements[i].getAttribute('readonly') && !elements[i].getAttribute('disabled')) { elements[i].onfocus=function() {this.style.backgroundColor='#ffd';this.select()}; elements[i].onmouseover=function() {this.style.backgroundColor='#ffd'}; elements[i].onblur=function() {this.style.backgroundColor='';} elements[i].onmouseout=function() {this.style.backgroundColor='';} } } } } function radio(clicked){ var form = clicked.form; var checkboxes = form.elements[clicked.name]; if (!clicked.checked || !checkboxes.length) { clicked.parentNode.parentNode.className=""; return false; } for (i=0; i