function setupActions() {
	if (!document.getElementsByTagName)
		return;
	// image rollovers and popups
	initLinkActions();
	// rollovers for form image buttons
	initFormImageActions();
	// menu dropdowns for IE
	initMenuDropdownActions();
	// Set all forms to show the processing box when submitted. Turn off by putting _nobox in the form name.
	initProcessingBoxActions();
	// Protect people from leaving the page without saving data. Turn off by putting _nochangecheck in the form name.
	if (checkformchange == 1) {
		initCheckFormChangeActions();
	}
}

// image rollovers and popups
function initLinkActions() {
	var all_links = document.getElementsByTagName('a');
	for (var i = 0; i < all_links.length; i++) {
		var link = all_links[i];
		if (link.className && (link.className == 'rollover' || link.className == 'popup_rollover')) {
			if (link.childNodes && link.childNodes.length == 1 && link.childNodes[0].nodeName.toLowerCase() == 'img') {
				link.onmouseover = rollover;
				link.onmouseout = rollout;
			}
		}
		if (link.className && (link.className == 'popup' || link.className == 'popup_rollover')) {
			link.onclick = event_popup;
		}
		else {
			link.onclick = showFormWarning;
		}
	}
}

// rollovers for form image buttons
function initFormImageActions() {
	var all_buttons = document.getElementsByTagName('input');
	for (var i = 0; i < all_buttons.length; i++) {
		var button = all_buttons[i]; 
		if (button.type == 'image' && button.className && button.className == 'imagebutton_rollover') {
			button.onmouseover = rollover;
			button.onmouseout = rollout;
		}
	}
}

// menu dropdowns for IE
function initMenuDropdownActions() {
	if (document.getElementById("menu")) {
		var menuLIs = document.getElementById("menu").getElementsByTagName("LI");
		for (var i = 0;i < menuLIs.length; i++) {
			menuLIs[i].onmouseover=function() {
				if (document.all) this.className+=" sfhover";
			}
			menuLIs[i].onmouseout=function() {
				if (document.all) this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}

// Set all forms to show the processing box when submitted. Turn off by putting _nobox in the form name.
function initProcessingBoxActions() {
	var all_forms = document.getElementsByTagName('form');
	for (var i = 0;i < all_forms.length; i++) {
		var form = all_forms[i];
		var formsplit = form.name.split('_');
		if (formsplit[0]) {
			for (var x = 0;x < formsplit.length; x++) {
				if (formsplit[x] == 'nobox') {
					showformbox = 0;
				}
				if (formsplit[x] == 'nochangecheck') {
					checkformchange = 0;
				}
			}
		}
		if (showformbox == 1) {
			form.onsubmit = drawProcessingBox;
		}
	}
}

// Protect people from leaving the page without saving data. Turn off by putting _nochangecheck in the form name.
function initCheckFormChangeActions() {
	var all_fields = document.getElementsByTagName('input');
	for (var i = 0;i < all_fields.length; i++) {
		var field = all_fields[i];
		field.onchange = checkforchange;
	}
	var all_selects = document.getElementsByTagName('select');
	for (var i = 0;i < all_selects.length; i++) {
		var thisselect = all_selects[i];
		thisselect.onchange = checkforchange;
	}
	var all_textareas = document.getElementsByTagName('textarea');
	for (var i = 0;i < all_textareas.length; i++) {
		var thistextarea = all_textareas[i];
		thistextarea.onchange = checkforchange;
	}
}

function find_target(e) {
	var target; 
	if (window.event && window.event.srcElement) 
		target = window.event.srcElement;
	else if (e && e.target)
		target = e.target;
	if (!target)
		return null;
	while (target != document.body && (target.nodeName.toLowerCase() != 'a' && target.nodeName.toLowerCase() != 'input' && target.nodeName.toLowerCase() != 'select'))
		target = target.parentNode;
	if (target.nodeName.toLowerCase() != 'a' && target.nodeName.toLowerCase() != 'input' && target.nodeName.toLowerCase() != 'select')
		return null;
	return target;
}

function rollover(e) {
	var target = find_target(e);
	if (!target) return;
	if (target.nodeName.toLowerCase() == 'a')
		var img_tag = target.childNodes[0];
	else
		var img_tag = target;
	img_tag.src = img_tag.src.replace(/(\.[^.]+)$/, '_over$1');
}

function rollout(e) {
	var target = find_target(e);
	if (!target) return;
	if (target.nodeName.toLowerCase() == 'a')
		var img_tag = target.childNodes[0];
	else
		var img_tag = target;
	img_tag.src = img_tag.src.replace(/_over(\.[^.]+)$/, '$1');
}

function checkforchange() {
	formedited = 1;
}

function showFormWarning() {
	if (formedited == 1) {
		if (confirm('You have made unsaved changes to this page.\nClick "OK" to leave this page and erase your changes, or click "Cancel" to return.')) {
			return true;
		}
		else {
			return false;
		}
	}
	else {
		return true;
	}
}

function drawProcessingBox() {
	var myWidth = 800, myHeight = 600;
	var	thisX = 0;
	var	thisY = 0;
	var messageText = 'Processing...|Please Wait a Moment';
	//Non-IE
	if (typeof( window.innerWidth ) == 'number') {
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		thisX = window.pageXOffset;
		thisY = window.pageYOffset;
	} 
	//IE 6+ in 'standards compliant mode'
	else if (document.documentElement) {
		if (document.documentElement.clientWidth || document.documentElement.clientHeight) {
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		}
		if (document.documentElement.scrollLeft || document.documentElement.scrollTop) {
			thisX = document.documentElement.scrollLeft;
			thisY = document.documentElement.scrollTop;
		}
	}
	popX = thisX + myWidth/2 - 150;
	popY = thisY + myHeight/2 - 50;
	try {
		/* Add pop-layer elements to end of page */
		var tmp = document.createElement('div');
		tmp.setAttribute('id','popArea');
		tmp.style.left = popX + 'px';
		tmp.style.top = popY + 'px';
		popAreaObj = document.body.appendChild(tmp);
		var textsplit = messageText.split('|');
		for (var i=0;i < textsplit.length; i++) {
			var popupText = document.createTextNode(textsplit[i]);
			tmp = document.createElement('p');
			popAreaP = popAreaObj.appendChild(tmp);
			popAreaP.appendChild(popupText);
		}
	}
	catch(e) {
	}
}