function imageOff(imageName) { if (document.images && doIt=="yes") { document[imageName].src = eval(imageName + '_off.src'); } } function imageOn(imageName) { if (document.images && doIt=="yes") { document[imageName].src = eval(imageName + '_on.src'); } } function changeClass(object, newClass) { objRef = document.getElementById(object); objRef.className = newClass; } function openWindow(url, windowName, width, height) { if(screen.width){ var winl = (screen.width - width) / 2; var wint = (screen.height - height) / 2; } else{ winl = 0; wint = 0; } if (winl < 0) winl = 0; if (wint < 0) wint = 0; var settings = ''; settings += 'height=' + height + ','; settings += 'width=' + width + ','; settings += 'top=200,left=200,'; settings += 'directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes'; var win = window.open(url, windowName, settings); } function trim (str) { while (str.charAt(0) == ' ') { str = str.substring(1); } while (str.charAt(str.length - 1) == ' ') { str = str.substring(0, str.length - 1); } return str; } function isEmailValid(sEmail) { if (sEmail.value == '' || sEmail.indexOf('.') == 0 || sEmail.indexOf('.') == -1 || sEmail.indexOf('@') == 0 || sEmail.indexOf('@') == -1 || sEmail.indexOf('.') == sEmail.length - 1 || sEmail.indexOf('.') == sEmail.length - 2) { return false; } else { return true; } } function FormatNumber(expr, decplaces) { var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces)); while (str.length <= decplaces) { str = "0" + str; } var decpoint = str.length - decplaces; return str.substring(0,decpoint) + "." + str.substring(decpoint, str.length); } function hideShowElement(elementId, behavior) { if (behavior == 'toggle') { //Show or hide element depending on the current state if (document.getElementById(elementId).style.display == '') { document.getElementById(elementId).style.display = 'none'; } else { document.getElementById(elementId).style.display = ''; } } else if (behavior == 'show') { //Show element document.getElementById(elementId).style.display = ''; } else if (behavior == 'hide') { //Hide element document.getElementById(elementId).style.display = 'none'; } } //NOTE: This function REQUIRES daysInMonth(), which REQUIRES isLeapYear() function isValidDate(sDate) { //Check to make sure two slashes are present in the date provided if (sDate.lastIndexOf('/') <= sDate.indexOf('/')) { return false; } //Split on slash sDateArray = sDate.split('/'); sMonth = sDateArray[0]; sDay = sDateArray[1]; sYear = sDateArray[2]; //Validate year part if (isNaN(sYear)) { return false; } if (sYear.length == 2) { sYear = parseInt('20' + sYear); } else { if (sYear.length != 4) { return false; } } if (sDay <= daysInMonth(sMonth, sYear)) { return true; } else { return false; } } function isLeapYear(yr) { if (yr % 4 != 0) return false; else if (yr % 400 == 0) return true; else if (yr % 100 == 0) return false; else return true; } function daysInMonth(mn, yr) { var mDay; if ((mn == 4) || (mn == 6) || (mn == 9) || (mn == 11)) { mDay = 30; } else if (mn == 2) { //calling leap year function mDay = isLeapYear(yr) ? 29 : 28; } else { mDay = 31; } return mDay; } function getRadioValue(objRadio) { var itemChecked = false; for (i=0; i < objRadio.length; i++) { if (objRadio[i].checked) { itemChecked = true; return objRadio[i].value; } } if (itemChecked == false) { return ''; } } function setRadioValue(objRadio, sValue) { for (i=0; i < objRadio.length; i++) { if (objRadio[i].value == sValue) { objRadio[i].checked = true; } } } function reloadCaptcha(root) { var captchaImage = document.getElementById('captcha'); var captchaInput = document.getElementById('captchaCode'); captchaImage.src = root + 'inc/securimage/show.php?t=' + Math.random(); captchaInput.value = ''; captchaInput.focus(); return false; }