var g_aIgnore = Array(8,9,37,38,39,40,35,36,46); function GetResultingValue(ptObject, strInsert) { //IE support var strPostValue = ""; if (document.selection) { var trCaret = window.document.selection.createRange(); var trPrefix = ptObject.createTextRange(); var trSuffix = trPrefix.duplicate(); trPrefix.setEndPoint("EndToStart", trCaret); trSuffix.setEndPoint("StartToEnd", trCaret); strPostValue = trPrefix.text + strInsert + trSuffix.text; } //MOZILLA/NETSCAPE support else if (ptObject.selectionStart || ptObject.selectionStart == '0') { var startPos = ptObject.selectionStart; var endPos = ptObject.selectionEnd; strPostValue = ptObject.value.substring(0, startPos) + strInsert + ptObject.value.substring(endPos, ptObject.value.length); } //SAFARI support, //I know this isn't quite right, but if anyone can get it to work let us know!! else if (window.getSelection) { strPostValue = ptObject.value + strInsert; } return strPostValue; } function IsNotNumber(strValue) { if (strValue == ".") return false; if (isNaN(parseFloat(strValue,10))) return true; if (strValue.match(/.*[\+\-]/) != null) return true; if (strValue.match(/[^0123456789\-\+\.]/) != null) return true; if (strValue.match(/.+\..+\./) != null) return true; return false; } /* * Copyright (c) 2004-2006 OIC Group, Inc. * Written and Designed by James Hunt * * This file is part of Exponent * * Exponent is free software; you can redistribute * it and/or modify it under the terms of the GNU * General Public License as published by the Free * Software Foundation; either version 2 of the * License, or (at your option) any later version. * * GPL: http://www.gnu.org/licenses/gpl.txt * */ function money_filter_class() { this.on_key_press = function(ptObject, evt) { evt = (evt) ? evt : event; sChar = (evt.charCode) ? evt.charCode : evt.keyCode; for (var n =0; n < g_aIgnore.length; n++) { if (sChar == g_aIgnore[n]) return true; } var strOldValue = ptObject.value; var strNewValue = GetResultingValue(ptObject, String.fromCharCode(sChar)); strNewValue = this.FormatUSCurrency(strNewValue, false); if (this.isValueIllegal(strNewValue)) return false; ptObject.value = strNewValue; this.SetCaretPosition(strOldValue, strNewValue,ptObject); return false; } this.onblur = function(ptObject) { ptObject.value = this.FormatUSCurrency(ptObject.value, true); if (ptObject.value != ptObject.previousValue) ptObject.fireEvent("onchange"); } this.onfocus = function(ptObject) { this.previousValue = ptObject.value } this.onpaste = function(ptObject, evt) { var strNewVal = GetResultingValue(ptObject, String.fromCharCode(evt.charCode)); alert(strNewVal); if (this.isValueIllegal(strNewVal)) { return false; } return true; } this.isValueIllegal = function(strValue) { var bIsIllegal = false; var temp = strValue.replace(/,/g, ""); if (strValue.match(/[^s]\$/)) bIsIllegal = true; else if (strValue.match(/\..*\./) != null) bIsIllegal = true; else if (strValue.match(/\.+\d{3}/) != null) bIsIllegal = true; else if (parseInt(temp.substr(1)) > 9999999999) bIsIllegal = true; else if (IsNotNumber(strValue.replace(/\$/g, "").replace(/,/g, "")) == true) bIsIllegal = true; return bIsIllegal; } this.FormatUSCurrency = function(strValue, bIncludeDP) { strValue = strValue.replace(/,/g, ""); var iDPPosition = strValue.indexOf("."); if (iDPPosition == -1) iDPPosition = strValue.length; for (i = iDPPosition -3; i > 0; i -= 3) strValue = strValue.substr(0, i) + "," + strValue.substr(i); strValue = "$" + strValue.replace(/\$/g, ""); strValue = strValue.replace("$,","$"); if (bIncludeDP) { var iDP = strValue.length - strValue.indexOf("."); if (iDP > strValue.length) strValue += ".00"; else if (iDP == 1) strValue += "00"; else if (iDP == 2) strValue += "0"; if (strValue == "$.00") strValue = "$0.00"; } return strValue; } this.SetCaretPosition = function(strOld, strNew, ptObject) { var i = -1; strOld = strOld.replace(/,/g, ""); strOld = strOld.replace(/\$/g, ""); var strTemp = strNew.replace(/,/g, ""); strTemp = strTemp.replace(/\$/g, ""); var newCount = (((strTemp.length - strOld.length)<0)?1:(strTemp.length - strOld.length)); var iInsertPoint = strNew.length; for (var x = 0; x < strNew.length; x++) { if ((strNew.substr(x,1) != "$") && (strNew.substr(x,1) != ",")) { i++; if (strNew.substr(x,1) != strOld.substr(i,1)) { iInsertPoint = x + newCount; break; } } } if (document.selection) { trCaret = ptObject.createTextRange(); trCaret.collapse(true); trCaret.moveStart("character", iInsertPoint); trCaret.select(); } else if (ptObject.selectionStart || ptObject.selectionStart == '0') { ptObject.selectionStart = iInsertPoint; ptObject.selectionEnd = iInsertPoint; } } } var money_filter = new money_filter_class(); var perline = 9; var divSet = false; var curId; var colorLevels = Array('0', '3', '6', '9', 'C', 'F'); var colorArray = Array(); var ie = false; var nocolor = 'none'; if (document.all) { ie = true; nocolor = ''; } function getObj(id) { if (ie) { return document.all[id]; } else { return document.getElementById(id); } } function addColor(r, g, b) { var red = colorLevels[r]; var green = colorLevels[g]; var blue = colorLevels[b]; addColorValue(red, green, blue); } function addColorValue(r, g, b) { colorArray[colorArray.length] = '#' + r + r + g + g + b + b; } function setColor(color) { var link = getObj(curId); var field = getObj(curId + 'field'); var picker = getObj('colorpicker'); field.value = color; if (color == '') { link.style.background = nocolor; link.style.color = nocolor; color = nocolor; } else { link.style.background = color; link.style.color = color; } picker.style.display = 'none'; eval(getObj(curId + 'field').title); } function setDiv(id) { if (divSet) { getObj('colorpicker').parentNode = getObj(id); return; } if (!document.createElement) { return; } var elemDiv = document.createElement('div'); if (typeof(elemDiv.innerHTML) != 'string') { return; } genColors(); elemDiv.id = 'colorpicker'; elemDiv.style.position = 'absolute'; elemDiv.style.display = 'none'; elemDiv.style.border = '#000000 1px solid'; elemDiv.style.background = '#FFFFFF'; elemDiv.innerHTML = 'Pick a color: ' + '(No color)
' + getColorTable() + '
'; getObj(id).appendChild(elemDiv); divSet = true; } function pickColor(id) { setDiv(id); var picker = getObj('colorpicker'); if (id == curId && picker.style.display == 'block') { picker.style.display = 'none'; return; } curId = id; var thelink = getObj(id); picker.style.top = getAbsoluteOffsetTop(thelink) + 20; picker.style.left = getAbsoluteOffsetLeft(thelink); picker.style.display = 'block'; } function genColors() { addColorValue('0','0','0'); addColorValue('3','3','3'); addColorValue('6','6','6'); addColorValue('8','8','8'); addColorValue('9','9','9'); addColorValue('A','A','A'); addColorValue('C','C','C'); addColorValue('E','E','E'); addColorValue('F','F','F'); for (a = 1; a < colorLevels.length; a++) addColor(0,0,a); for (a = 1; a < colorLevels.length - 1; a++) addColor(a,a,5); for (a = 1; a < colorLevels.length; a++) addColor(0,a,0); for (a = 1; a < colorLevels.length - 1; a++) addColor(a,5,a); for (a = 1; a < colorLevels.length; a++) addColor(a,0,0); for (a = 1; a < colorLevels.length - 1; a++) addColor(5,a,a); for (a = 1; a < colorLevels.length; a++) addColor(a,a,0); for (a = 1; a < colorLevels.length - 1; a++) addColor(5,5,a); for (a = 1; a < colorLevels.length; a++) addColor(0,a,a); for (a = 1; a < colorLevels.length - 1; a++) addColor(a,5,5); for (a = 1; a < colorLevels.length; a++) addColor(a,0,a); for (a = 1; a < colorLevels.length - 1; a++) addColor(5,a,5); return colorArray; } function getColorTable() { var colors = colorArray; var tableCode = ''; tableCode += ''; for (i = 0; i < colors.length; i++) { if (i % perline == 0) { tableCode += ''; } tableCode += ''; if (i % perline == perline - 1) { tableCode += ''; } } if (i % perline != 0) { tableCode += ''; } tableCode += '
   
'; return tableCode; } function relateColor(id, color) { var link = getObj(id); if (color == '') { link.style.background = nocolor; link.style.color = nocolor; color = nocolor; } else { link.style.background = color; link.style.color = color; } eval(getObj(id + 'field').title); } function getAbsoluteOffsetTop(obj) { var top = obj.offsetTop; var parent = obj.offsetParent; while (parent != document.body) { top += parent.offsetTop; parent = parent.offsetParent; } return top; } function getAbsoluteOffsetLeft(obj) { var left = obj.offsetLeft; var parent = obj.offsetParent; while (parent != document.body) { left += parent.offsetLeft; parent = parent.offsetParent; } return left; } /* * Copyright (c) 2004-2006 OIC Group, Inc. * Written and Designed by James Hunt * * This file is part of Exponent * * Exponent is free software; you can redistribute * it and/or modify it under the terms of the GNU * General Public License as published by the Free * Software Foundation; either version 2 of the * License, or (at your option) any later version. * * GPL: http://www.gnu.org/licenses/gpl.txt * */ function integer_filter_class() { this.on_key_press = function(ptObject, evt) { //This will allow backspace to work. evt = (evt) ? evt : event; sChar = (evt.charCode) ? evt.charCode : evt.keyCode; for (var n =0; n < g_aIgnore.length; n++) { if (sChar == g_aIgnore[n]) return true; } var strNewVal = GetResultingValue(ptObject, String.fromCharCode(sChar)); if (this.isValueIllegal(strNewVal)) { return false; } return true; } this.onblur = function(ptObject) { //Do nothing for integer } this.onfocus = function(ptObject) { //Do nothing for integer } this.onpaste = function(ptObject, evt) { var strNewVal = GetResultingValue(ptObject, String.fromCharCode(evt.charCode)); alert(strNewVal); if (this.isValueIllegal(strNewVal)) { return false; } return true; } this.isValueIllegal = function(strValue) { var bIsIllegal = isNaN(parseInt(strValue, 10)); if (bIsIllegal == false) { bIsIllegal = (strValue.match(/[^0-9]/) != null); } return bIsIllegal; } } var integer_filter = new integer_filter_class(); /* * Copyright (c) 2004-2006 OIC Group, Inc. * Written and Designed by James Hunt * * This file is part of Exponent * * Exponent is free software; you can redistribute * it and/or modify it under the terms of the GNU * General Public License as published by the Free * Software Foundation; either version 2 of the * License, or (at your option) any later version. * * GPL: http://www.gnu.org/licenses/gpl.txt * */ function percent_filter_class() { this.on_key_press = function(ptObject, evt) { evt = (evt) ? evt : event; sChar = (evt.charCode) ? evt.charCode : evt.keyCode; //This will allow backspace to work. for (var n =0; n < g_aIgnore.length; n++) { if (sChar == g_aIgnore[n]) return true; } var strNewVal = GetResultingValue(ptObject, String.fromCharCode(sChar)); if (this.isValueIllegal(strNewVal)) { return false; } return true; } this.onblur = function(ptObject) { ptObject.value = this.FormatPercent(ptObject.value, true); if (ptObject.value != ptObject.previousValue) ptObject.fireEvent("onchange"); } this.onfocus = function(ptObject) { this.previousValue = ptObject.value } this.onpaste = function(ptObject, evt) { var strNewVal = GetResultingValue(ptObject, String.fromCharCode(evt.charCode)); alert(strNewVal); if (this.isValueIllegal(strNewVal)) { return false; } return true; } this.isValueIllegal = function(strValue) { var bIsIllegal = false; if (strValue.match(/\%.*\%/) != null) bIsIllegal = true; else if (strValue.match(/\%.+/) != null) bIsIllegal = true; else if (strValue.match(/\..*\./) != null) bIsIllegal = true; else if (parseInt(strValue) > 999) bIsIllegal = true; else if (strValue.match(/\.+\d{5}/) != null) bIsIllegal = true; else if (IsNotNumber(strValue.replace("%", "").replace(" ", "")) == true) bIsIllegal = true; return bIsIllegal; } this.FormatPercent = function(strValue, bIncludeDP) { strValue = strValue.replace(/\%/g, ""); if (strValue.length != 0) { while (strValue.charAt(0) == "0") { strValue = strValue.substr(1); } if (strValue.length == 0) strValue = "0"; var iDP = strValue.length - strValue.indexOf("."); if (iDP == strValue.length) strValue = "0" + strValue; if (iDP > strValue.length) strValue += ".00"; else if (iDP == 1) strValue += "00"; else if (iDP == 2) strValue += "0"; else if ((iDP > 2) && (iDP < strValue.length)) strValue = strValue.substr(0,strValue.length - iDP+5); // Ensure number is postfixed strValue = strValue + " %"; } return strValue; } } var percent_filter = new percent_filter_class(); /* * Copyright (c) 2004-2006 OIC Group, Inc. * Written and Designed by James Hunt * * This file is part of Exponent * * Exponent is free software; you can redistribute * it and/or modify it under the terms of the GNU * General Public License as published by the Free * Software Foundation; either version 2 of the * License, or (at your option) any later version. * * GPL: http://www.gnu.org/licenses/gpl.txt * */ g_rgName = new Array(); function trim(s) { while (s.charAt(0) == " ") { s = s.substr(1); } return s; } function registerRG(name) { g_rgName[g_rgName.length] = name; } function unregisterRG(name) { for (var x = 0; x < g_rgName.length; x++) { if (g_rgName[x] == name) { g_rgName = ""; } } } function checkRG() { for (var x = 0; x < g_rgName.length; x++) { if (g_rgName[x] != "") { alert("Missing required selection for " + unescape(g_rgName[x])); return false; } } return true; } function checkRequired(locForm) { for (field in locForm.elements) { if (locForm.elements[field]) { if (locForm.elements[field].getAttribute) { s = locForm.elements[field].getAttribute("required"); if (s != null) { val = trim(locForm.elements[field].value); s = unescape(s); //if ((s == val) || (val == "")) { //alert (locForm.elements[field].type); if (locForm.elements[field].type == 'checkbox') { if (!locForm.elements[field].checked) { locForm.elements[field].focus(); alert(unescape(locForm.elements[field].getAttribute("caption")) + " is a required field."); return false; } } else { if (val == "") { locForm.elements[field].focus(); alert(unescape(locForm.elements[field].getAttribute("caption")) + " is a required field."); return false; } } } if (locForm.elements[field].name == "checker" && locForm.elements[field].checked == true && locForm.elements[field].value != 0 ) { alert ("You must choose the correct answer in the anti-spam question to proceed"); return false; } } } } if (!checkRG()) return false; return true; } /* * Copyright (c) 2004-2006 OIC Group, Inc. * Written and Designed by James Hunt * * This file is part of Exponent * * Exponent is free software; you can redistribute * it and/or modify it under the terms of the GNU * General Public License as published by the Free * Software Foundation; either version 2 of the * License, or (at your option) any later version. * * GPL: http://www.gnu.org/licenses/gpl.txt * */ function decimal_filter_class() { this.on_key_press = function(ptObject, evt) { evt = (evt) ? evt : event; sChar = (evt.charCode) ? evt.charCode : evt.keyCode; //This will allow backspace to work. for (var n =0; n < g_aIgnore.length; n++) { if (sChar == g_aIgnore[n]) return true; } var strNewVal = GetResultingValue(ptObject, String.fromCharCode(sChar)); if (this.isValueIllegal(strNewVal)) { return false; } return true; } this.onblur = function(ptObject) { var iDPPos = ptObject.value.indexOf("."); if (iDPPos == -1) return; var bValueChanged = false; if (iDPPos == ptObject.value.length -1) { ptObject.value = ptObject.value.substr(0, ptObject.value.length -1); bValueChanged = true; } if (iDPPos == 0) { var dNewValue = "0" + ptObject.value; ptObject.value = dNewValue; bValueChanged = true; } if (bValueChanged) ptObject.fireEvent("onchange"); } this.onfocus = function(ptObject) { //Do nothing for decimal } this.onpaste = function(ptObject, evt) { var strNewVal = GetResultingValue(ptObject, String.fromCharCode(evt.charCode)); alert(strNewVal); if (this.isValueIllegal(strNewVal)) { return false; } return true; } this.isValueIllegal = function(strValue) { bIsIllegal = IsNotNumber(strValue); if (bIsIllegal == false) { if (strValue.match(/\..*\./) != null) bIsIllegal = true; } return bIsIllegal; } } var decimal_filter = new decimal_filter_class();