// show a warning message to users of unsupported browsers

	function check_browser_support() {
		//alert(navigator.appVersion); return; // test user agent strings
		unsupported = new Array("MSIE 6");
		supported = 1;
		warned = 1;
		for (var i=0; i<unsupported.length; i++) {
			if (navigator.appVersion.indexOf(unsupported[i]) != -1) {
				supported = 0;
			}
		}
		if (!supported) {
			warned = get_cookie("browser_support", "warned");
		}
		if ((!supported)&&(!warned)) {
			alert("Your browser is not supported by this website. Please consider upgrading to a newer browser. Otherwise, portions of this site may not display or function correctly.");
			set_cookie("browser_support", "warned", 1);
		}
	}


// 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>");
	}

// show either the Command or Control text depending on the platform

	function show_command_key() {
		key = (navigator.platform.indexOf("Win") != -1) ? "Control" : "Command" ;
		document.write(key);
	}


// the simplest possible rollover function

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

// a rollover function that supports multiple instances of each image on the same page

	function multiswap(image_name, instance_ID, state) {
		instance_name = (instance_ID) ? image_name + "_" + instance_ID : image_name ;
		eval("document.images." + instance_name + ".src = " + image_name + "_" + String(state) + ".src");
	}
	

// write a block of code that preloads a list of graphics

// names - a comma-delimited list of button names (e.g. "home,about,contact")
// path - the path to the graphics; defaults to "../graphics" if not set (e.g. "../graphics/menus/home")
// extension - the file extension of the graphics files; defaults to "gif" if not set (e.g. "jpg")

	function preload_buttons(names, path, extension) {
		names = names.split(",");
		path = (path) ? path : "../graphics" ;
		extension = (extension) ? extension : "gif" ;
		for (var i=0; i<names.length; i++) {
			this_name = names[i];
			this_path = path + "/" + this_name;
			eval(this_name + "_0 = new Image()");
			eval(this_name + "_0.src = '" + this_path + "_0." + extension + "'");
			eval(this_name + "_1 = new Image()");
			eval(this_name + "_1.src = '" + this_path + "_1." + extension + "'");
			eval(this_name + "_2 = new Image()");
			eval(this_name + "_2.src = '" + this_path + "_2." + extension + "'");
		}
	}
	

// add the onmouseover and onmouseout events to images to enable their rollover behavior

// names - a comma-delimited list of button names (e.g. "home,about,contact")
// IDs - a comma-delimited list of record IDs used to distinguish different instances of the same button

	function add_rollover_events(names, IDs) {
		names = names.split(",");
		IDs = (IDs) ? IDs.split(",") : "" ;
		sets = (IDs) ? IDs.length : 1 ;
		for (var j=0; j<sets; j++) {
			for (var i=0; i<names.length; i++) {
				instance_name = (IDs) ? names[i] + "_" + IDs[j] : names[i] ;
				instance_ID = (IDs) ? IDs[j] : "" ;
				source_name = names[i];
				if (isset("document.images." + instance_name)) {
					eval("document.images." + instance_name + ".onmouseover = function() { multiswap('" + source_name + "', '" + instance_ID + "', 1); } ;");
					eval("document.images." + instance_name + ".onmouseout = function() { multiswap('" + source_name + "', '" + instance_ID + "', 0); } ;");
				}
			}
		}
	}


// search some menu code for a page or section name and set its link ID to "active"
// it would be better to scan the objects within the given div, look for the object whose href matches the page, and change that object's class, but this seems to work fine for now

	function set_active_item(menu_name, page) {
		//if (document.getElementById(menu_name)) {
			if (page) {
			
				image_name = menu_name + "_" + page;
		
				// see if we have a menu image name that matches this page
				eval("match = document.images." + image_name + ";");
				
				// if so, change its source and remove its mouseover behaviors
				if (match) {
					eval("document.images." + image_name + ".src = " + image_name + "_2.src");
					eval("document.images." + image_name + ".onmouseover = function() {} ;");
					eval("document.images." + image_name + ".onmouseout = function() {} ;");
				}

			}
		//}
	}
	

// figure out whether a variable has been set or not without generating an undefined error if it hasn't
// possible types are "undefined", "object", "boolean", "number", "string" or "function", with everything else being "object"
// this does not work on function arguments inside a function; even if the argument is set, this still returns false
// but in that case we can just check for a value without getting an error

	function isset(variable, type) {
		if (type) {
			eval("result = (typeof(" + variable + ") == type)");
		} else {
			eval("result = (typeof(" + variable + ") != 'undefined')");
		}
		return result;
	}


