
	
	/*
	 * function rolloverImage(int width, int height, String on, String off)
	 * object constructor: creates an object with two properties
	 * 	Image on - an image object to use when the button is "on"
	 *	Image off - an image object to use when the button is "off"
	 */
	function rolloverImage ( width, height, on, off ) {
	
		this.on = new Image(width, height);
		this.on.src=on;
		
		this.off = new Image(width, height);
		this.off.src=off;
		
	} 
	
	/*
	 * function rollover(Image image, String toggle, Object resource)
	 * 	Image image - the image in document.images[] to modify
	 *  String toggle - possible values are "over" and "out" -- loads appropriate SRC
	 *  When toggle is "over," existing src is stored in a temporary Image object in resource.temp array
	 *  	new image is loaded from resource.list array
	 * 		Both arrays are keyed by image.name
	 *  When toggle is "out," image is reloaded from temporary image object in temp array
	 */
	function rollover ( image, toggle, resource ) {
		if (!resource.list) {
			alert("Resource array specified does not exist.");
			return;
		}
		
		if (!resource.temp) {
			alert("Temp array specified does not exist.");
			return;
		}
		
		if (!document.images[image.name]) {
			alert(image.name + " does not exist in document.images[].");
			return;
		}
		
		if (toggle == "over") {
			resource.temp[image.name] = new Image(image.width, image.height);
			resource.temp[image.name].src = image.src;
			image.src = resource.list[image.name].src;
		}
		else if (toggle == "out") {
			if (!resource.temp[image.name]) {
				// this catches an interesting bug that occurs when the mouse 
				// is dragged over a rollover-enabled image and then released
				return;
			}
			image.src = resource.temp[image.name].src;
		}
	}
	
	/* 
	 * function activelyFormatZipPlus4 ( Form.field )
	 * actively formats a zip plus 4 field while content is typed into the field
	 */
	function activelyFormatZipPlus4 ( field ) {
		if (!field) {
			return; 
		}
	 	
	 	var clean = field.value;
		clean = clean.replace(new RegExp("[^0-9]", "gi"), "");
		if (clean.length <= 5) {
			field.value = clean;
			return;
		}
		else {
			field.value = clean.substring(0,5) + "-" + clean.substring(5,clean.length);
		}
	}
	 
	/*
	 * function activeFormatPhone ( Form.field )
	 * actively formats a phone plus area code (and optionally, and extensions)
	 */
	function activelyFormatPhone ( field ) {
	 	if (!field) {
			return;
		}
			
		var clean = field.value;
		clean = clean.replace(new RegExp("[^0-9]", "gi"), "");
		
		field.value = "(" + clean.substring(0,3) + ") " + clean.substring(3,6) + "-" + clean.substring(6,10);
		if (clean.length > 10) {
			field.value += " x" + clean.substring(10,clean.length);
		}
	}
	
	/*
	 * function jumpToOption ( Form.select, value )
	 * looks for the first instance of [value] in Form.select.options
	 */
	function jumpToOption ( s, value ) {
		if (!s) {
			return;
		}
		
		var blankAt=null;
		var goToIndex=null;
		
		if (document.all) {
			re = new RegExp("^" + value, "i");
			for (var i=0; i<s.length; i++) {
				if (s.options[i].value == '') {
					blankAt=i;
				}
			
				if (re.test(s.options[i].value)) {
					goToIndex=i;
					break;
				}
			}
		} 
		
		else { 
			for (var i=0; i<s.length; i++) {
				if (s.options[i].value == '') {
					blankAt=i;
				}
				
				if (s.options[i].value == value) {
					goToIndex=i;
					break;
				}
			}
		}
		
		if (goToIndex) {
			s.selectedIndex=goToIndex;
		} else if (blankAt != null) {
			s.selectedIndex=blankAt;
		}
			
	}
	