    // ******************************************
    // set mouse over and mouse out colors to use
    var onMouseOverColor = "#E9E9E9";
    var onMouseOutColor = "#FFFFFF";

    // ******************************************
    // set background color using the mouse over color
    function setRowOn (theRow) {
        setBackgroundColor(theRow, onMouseOverColor);
    }

    // ******************************************
    // set background color using the mouse out color
    function setRowOff (theRow) {
        setBackgroundColor(theRow, onMouseOutColor);
    }

    // ******************************************
    // set the background color for each cell in a row to the color passed in.
    function setBackgroundColor (theRow, newColor) {
        var theCells = null;
        var domDetect = null;
        if (typeof(document.getElementsByTagName) != 'undefined') {
            theCells = theRow.getElementsByTagName('td');
        }
        else if (typeof(theRow.cells) != 'undefined') {
            theCells = theRow.cells;
        }
        else {
            return false;
        }

        var rowCellsCnt = theCells.length;

        // DOM compatible browsers except Opera that does not return valid values with "getAttribute"
        if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
            domDetect = true;
        } else {
            // other browsers
            domDetect = false;
        }

        var c = null;
        if (domDetect) {
            // DOM compatible browsers except Opera
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            }
        } else {
            // other browsers
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    }

    // ******************************************
    function selectAll (selectList) {
         for (x=0; x<selectList.length; x++) {
              selectList.options[x].selected = true;
         }
    }

    // ******************************************
    function clearAll (selectList) {
         for (x=0; x<selectList.length; x++) {
              selectList.options[x].selected = false;
         }
    }

    // ******************************************
    // open a window to the url passed in.
    function viewImage (imgUrl) {
         window.open(imgUrl, 'imgView', 'width=150,height=150, resizable=yes, scrollbars=yes, directories=no, location=no');
    }
    
    // ******************************************
    // open a window to the url passed in.
    function fieldWindow(scriptUrl, height, width) {
        if(!height)
            height = 340;
        if(!width)
            width = 380;
        var fieldWin = window.open(scriptUrl,'fields','width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,taskbar=no, resizable=1, history=no');
    }

    // ******************************************
    // color picker.
    function colorPicker (colorField) {
        var oldcolor = colorField.value;
        var newcolor = showModalDialog("popups/select_color.html", oldcolor, "resizable: no; help: no; status: no; scroll: no;");
        if(newcolor) {
            colorField.value = "#"+newcolor;
        }
        return true;
    }
    
    // ******************************************
    // Event Participant functions.
    function addParticipant () {
        if (this.participantForm.contacts.selectedIndex >= 0) {
            // find contacts to add by traversing the contacts list
            for (x=0; x<this.participantForm.contacts.length; x++) {
                if (this.participantForm.contacts.options[x].selected == 1) {
                    // is this contact already added to the participant list?
                    var found = false;
                    for (y=0; y<this.participantForm.participants.length; y++) {
                        if (this.participantForm.contacts.options[x].value == this.participantForm.participants.options[y].value) {
                            found = true;
                        }
                    }
                    if (!found) {
                        // not on list yet, so add to list now
                        var newOption = new Option(this.participantForm.contacts.options[x].text, this.participantForm.contacts.options[x].value);
                        this.participantForm.participants.options[this.participantForm.participants.length] = newOption;
                    }
                }
            }
            // reset selected options
            this.participantForm.contacts.selectedIndex = -1;
            this.participantForm.participants.selectedIndex = -1;
        } else alert ("You must first select a name from the Contact List on the left.");
    }
    
    function removeParticipant() {
        if (this.participantForm.participants.selectedIndex >= 0) {
            // get list of all options to remove
            optionsToRemove = new Array();
            for (x=0; x<this.participantForm.participants.length; x++) {
                if (this.participantForm.participants.options[x].selected == 1) {
                    optionsToRemove[optionsToRemove.length] = this.participantForm.participants.options[x].value;
                }
            }
            // traverse through list and remove each option one-by-one
            for (x=0; x<optionsToRemove.length; x++) {
                for (y=0; y<this.participantForm.participants.length; y++) {
                    if (this.participantForm.participants.options[y].value == optionsToRemove[x]) {
                        this.participantForm.participants.options[y] = null;
                    }
                }
            }
            // reset selected options
            this.participantForm.participants.selectedIndex = -1;
            this.participantForm.contacts.selectedIndex = -1;
        } else alert ("You must first select a name from the Participant List on the right.");
    }
    
    function verifyParticipants() {
        if (this.participantForm.participants.options.length == 0) {
            alert ("You haven't added any participants yet.");
        } else {
            var pptsToSave = new Array();
            for (y=0; y<this.participantForm.participants.length; y++) {
                pptsToSave[pptsToSave.length] = this.participantForm.participants.options[y].value;
            }
            // join them into a string and write them to a hidden variable
            var ppt_str = pptsToSave.join("::");
            this.participantForm.ppt_list.value = ppt_str;
            this.participantForm.submit();
        }
    }
    
    // ******************************************
    // Formatting functions.
    function phoneFormat(field) {
        var m_value = field.value;
		var formatted_value = "";
		var international = false;
		if(m_value.match(/^\+/)) {
			international = true;
		}
		m_value = m_value.replace(/\D/g, "");
		var valueArr = m_value.split("");
		if(international) {
			for(var c=0; c < valueArr.length; c++) {
				if(c == 0) {
					formatted_value += "+";
				} else if(c == 2) {
					formatted_value += " (";
				} else if(c == 6) {
					formatted_value += ") ";
				}
				formatted_value += valueArr[c];
			}
		} else if(valueArr.length == 7) {
			for(var c=0; c < valueArr.length; c++) {
				if(c == 3) {
					formatted_value += "-";
				}
				formatted_value += valueArr[c];
			}
		} else if(valueArr.length == 10) {
			for(var c=0; c < valueArr.length; c++) {
				if(c == 0) {
					formatted_value += "(";
				} else if(c == 3) {
					formatted_value += ") ";
				} else if(c == 6) {
					formatted_value += "-";
				}
				formatted_value += valueArr[c];
			}
		} else if(valueArr.length == 11) {
			for(var c=0; c < valueArr.length; c++) {
				if(c == 1) {
					formatted_value += "(";
				} else if(c == 3) {
					formatted_value += ") ";
				} else if(c == 6) {
					formatted_value += "-";
				}
				formatted_value += valueArr[c];
			}
		} else {
			for(var c=0; c < valueArr.length; c++) {
				formatted_value += valueArr[c];
			}
		}
		field.value = formatted_value;
        
		return true;
    }
    
    function moneyFormat(field) {
        var m_value = field.value;
		var formatted_value = "";
		if(m_value.match(/\./)) {
			multiplier = 1;
		} else {
			multiplier = 100;
		}
		m_value = m_value.replace(/\D/g, "");
		m_value = parseInt(m_value) * multiplier;
		m_value = m_value.toString();
		var valueArr = m_value.split("");
		valueArr.reverse();
		var digits = 0;
		for(var c=0; c < valueArr.length; c++) {
			if(c == 2) {
				formatted_value += ".";
			} else if(c > 2) {
				digits++;
				if((digits % 3) == 0) {
					formatted_value += ",";
				}
			}
			formatted_value += valueArr[c];
		}
		formatted_value += "$";
		valueArr = formatted_value.split("");
		valueArr.reverse();
		formatted_value = valueArr.join("");
		field.value = formatted_value;
        
		return true;
    }
    
    function numberFormat(field) {
        var amount = parseFloat(field.value);
        amount += .5;
        amount = parseInt(amount);
		var formatted_amount = "";
		amountArr = amount.toString().split("");
		amountArr.reverse();
		for(c = 0; c < amountArr.length; c++) {
			if(((c + 1) % 3) == 0 && (c + 1) < amountArr.length) {
				formatted_amount += amountArr[c] + ",";
			} else {
				formatted_amount += amountArr[c];
			}
		}
		amountArr = formatted_amount.split("");
		amountArr.reverse();
		formatted_amount = amountArr.join("");
		field.value = formatted_amount;
		return true;
    }