// this doesn't really need to be a separate function, but it avoids the need to put quote marks into the JavaScript-based menus

	function tell_a_friend() {
		popup('../assembled/tell_a_friend.html',350,520);
	}


// see if we need to load an additional CSS file to tweak the default styles

	function check_CSS_tweaks() {
		tweaks = "";
		if ((navigator.appVersion.indexOf("Win") != -1)&&(navigator.appVersion.indexOf("MSIE") != -1)) {
			tweaks = "IE";
		}
		return tweaks;
	}


// open a popup window, specifying source, width, and height, and optionally a name; if no name, choose a random one

	function popup(source,width,height,window_name) {
		if (! window_name) { 
			now = new Date()
			window_name = now.getTime()
		} else {
			window_name = window_name.replace(/ /g, "_");
		}
		popup_window = window.open(source,window_name,"width="+String(width)+",height="+String(height)+",location=no,menubar=no,directories=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes");
		popup_window.focus()
	}


// show an email link on a page in a way that spam harvesters can't see

	function show_email(user, domain, tld, label) {
		if (!label) { label = user + "@" + domain + "." + tld; }
		document.write("<a href='mailto:" + user + "@" + domain + "." + tld + "'>" + label + "<\/a>");
	}


// the simplest possible rollover function

	function swap(name,state) {
		eval('document.images.' + name + '.src = ' + name + '_' + String(state) + '.src')
	}
	

// rollovers with sticky highlights
// - used in navigation frames where the buttons persist but other pages are changing

	var previous = null
	var current = null

	function stickySwap(name,state,hold) {
		if (hold == 1) {
			// set previously lit button to normal
			previous = current
			if (previous != null) {
				eval('document.images.' + previous + '.src = ' + previous + '_0.src')
			}
		}
		if ((name != null) && (name != current)) {
			// set new button state
			eval('document.images.' + name + '.src = ' + name + '_' + String(state) + '.src')
			if (hold == 1) {current = name}
		}
	}
	

// rollovers with separate but linked button and label graphics
// - highlights both the button and label if you mouse over either one 
// - requires graphics to be named like "button_0.gif" and "button_label_0.gif"

	function labelSwap(name,state) {
		eval('document.images.' + name + '.src = ' + name + '_' + String(state) + '.src')
		
		// change the label if one exists
		if (eval('document.images.' + name + '_label')) {
			eval('document.images.' + name + '_label.src = ' + name + '_label_' + String(state) + '.src')
		}
		
		// change the button if this is a label
		if (name.indexOf("_label") != -1) {
			name = name.substr(0,(name.length - 6))
			if (eval('document.images.' + name)) {
				eval('document.images.' + name + '.src = ' + name + '_' + String(state) + '.src')
			}
		}
	}
	

// write a block of code that preloads a list of graphics
// - used at the top of any page that contains rollovers

	function makePreloads(names) {
		names = names.split(",")
		for (i=0; i < names.length; i++) {
			thisName = names[i]
			eval(thisName+"_0 = new Image()")
			eval(thisName+"_0.src = '../graphics/"+thisName+"_0.gif'")
			eval(thisName+"_1 = new Image()")
			eval(thisName+"_1.src = '../graphics/"+thisName+"_1.gif'")
		}
	}
	

// returns the index of an array element, something that ought to be built into JavaScript but isn't!
// returns "" if not present

	function get_position(string, array) {
		return getPosition(string, array);
	}

	function getPosition(string, array) {
		for (i=0; i < array.length; i++) {
			if (array[i] == string) {
				return i
				break
			}
		}
		return ""
	}


// set date menus to a new SQL-standard date
// leave date blank to select today's date

	function selectDate(menu_name,new_date) {
		if (new_date == "") {
			date = new Date()
			
			day = date.getDate()
			month = date.getMonth() + 1
			year = date.getFullYear()
			
		} else {
			date = new_date
			
			year = date.substring(0,date.indexOf("-"))
			month = date.substring(date.indexOf("-")+1,date.lastIndexOf("-"))
			day = date.substring(date.lastIndexOf("-")+1)
			
		}
				
		eval("document." + menu_name + "_month.selectedIndex = month")
		eval("document." + menu_name + "_day.selectedIndex = day")
		eval("document." + menu_name + "_year.selectedIndex = year - document." + menu_name + "_year.options[1].value + 1")
	}


// set a cookie
	
	// 02/15/03 - initial development
	// 05/14/04 - expanded to allow saving multiple values within a single cookie

	function set_cookie_OLD(name, value) {
		// specify a default key-name prefix for this project
		name_prefix = "projectname_";
		
		// the following are cookie parameters are optional ... change values to null if you don't need them
		hours = 43800;
		path = "/";						
		domain = null;
		
		key = name_prefix + name;		
		(hours) ? expiration_date = new Date((new Date()).getTime() + hours*3600000).toGMTString() : expiration_date = false;
		cookie_string = key + '=' + escape(value) + ((expiration_date)?(';expires=' +expiration_date):'') + ((path)?(';path='+path):'') + ((domain)?(';domain='+domain):'');
		document.cookie = cookie_string;
	}
	
	function set_cookie(name, key, value) {

		// specify a default cookie name prefix for this project, to group cookies together
		name_prefix = "project_";
		value_exists = 0;
		
		// the following cookie parameters are optional ... change values to null if you don't need them
		hours = 43800;
		path = "/";						
		domain = null;
		
		cookie_value = get_cookie(name, "all"); // get the entire cookie string so we can update the values
		key_value_array = cookie_value.split("&"); // split the cookie string into an array of key=value strings
		
		// search through the list of key=value strings for the presence of the specified key
		for (key_value=0; key_value<key_value_array.length; key_value++) {
			if (key_value_array[key_value].indexOf(key + "=") == 0) {
			
				// when we find it, overwrite the value of that array element
				key_value_pair = key_value_array[key_value].split("=");
				key_value_key = key_value_pair[0];
				key_value_array[key_value] = key_value_key + "=" + escape(value);
				
				// then combine the key=value strings back into a single string
				cookie_value = key_value_array.join('&');
				value_exists = 1; // flag this key as already being in the cookie string so that you don't add it to the cookie string again
				break;

			}
		}
		
		// if the cookie string doesn't already contain this key, add the key=value string
		if (value_exists == 0) {
			ampersand = (cookie_value != "") ? "&" : "" ;
			cookie_value += ampersand + key + "=" + escape(value);
		}
		
		expiration_date = (hours) ? new Date((new Date()).getTime() + hours*3600000).toGMTString() : false ;
		cookie_string = name_prefix + name + "=" + escape(cookie_value) + ((expiration_date)?(';expires=' +expiration_date):'') + ((path)?(';path='+path):'') + ((domain)?(';domain='+domain):'');
		document.cookie = cookie_string;
	
	}


// get values from a cookie

	// 02/15/03 - initial development
	// 05/14/04 - expanded to allow saving multiple values within a single cookie

	function get_cookie_OLD(name) {
		var output_value;
		if (document.cookie != "") {
			// specify a default key-name prefix for this project
			name_prefix = "projectname_";
			cookie_array = document.cookie.split("; ");
			for (i = 0; i < cookie_array.length; i++) {
				cookie_pair = cookie_array[i].split("=");
				key = cookie_pair[0];
				value = cookie_pair[1];
						
				if (key == (name_prefix + name)) {
					output_value = unescape(value);
					break;
				} else {
					output_value = "";
				}
			}
		} else {
			output_value = "";
		}
		return output_value;
	}
	
	function get_cookie(name, key) {
	
		name_prefix = "project_"; // specify a default cookie name prefix for this project, to group cookies together
		output_value = "";
		
		if (document.cookie != "") {
			cookie_array = document.cookie.split("; ");

			// search for the cookie with this name
			for (cookie=0; cookie < cookie_array.length; cookie++) {
				if (cookie_array[cookie].indexOf(name_prefix + name + "=") == 0) {

					cookie_pair = cookie_array[cookie].split("=");
					cookie_value = unescape(cookie_pair[1]); // the value is the list of key=value strings that we saved into this cookie
	
					if (key == "all") {
						output_value = cookie_value;
						break;
					} else {
						key_value_array = cookie_value.split("&");
					
						// search through the list of key=value strings for the value of the requested key
						for (key_value=0; key_value<key_value_array.length; key_value++) {
							if (key_value_array[key_value].indexOf(key + "=") == 0) {
							
								key_value_pair = key_value_array[key_value].split("=");
								output_value = unescape(key_value_pair[1]);
								break;
										
							}	
						}
						
					}
					
				}
			}
			
		}
		
		return output_value;
		
	}
	
	
