function tag(name) {
	return document.getElementById(name);
}

var logging = false;

function log(msg) {
	if(logging) {
		tag('log').innerHTML += msg + '<br />';
	}
}

function in_array(val, arr) {
	for(var i in arr) {
		if(arr[i] == val) {
			return true;
		}
	}
	return false;
}

// the usual way to show/hide something is to switch from static to absolute
// positioning (a significantly negative "top" is set in the style sheet. If
// you need to show/hide something that is absolutely positioned, see
// show_abs()
function show_only(show, all) {
	for(var i in all) { var field = all[i];
		tag(field).style.position = ((field == show) ? 'static' : 'absolute');
	}
}

// this will set the class all passed to (className) or ("on" + className)
function on_only(chosen, all, className) {
	for(var i in all) { var sub = all[i];
		tag(sub).className = ((sub == chosen) ? ('on' + className) : className);
	}
}

function strip2(str) {
	return str.substring(0, str.length - 2);
}



// pass name(s) of tags which are absolutely positioned
//
// NOTE: for compatibility (only way it can work in Safari) you MUST specify
// the "top" for the absolute position of these elements INLINE (ie in the html
// document).
function hide_abs(all) {
	if(!all instanceof Array) {
		all = [all];
	}

	for(var i in all) { var field = all[i];
		mtop = strip2(tag(field).style.top);
		if(mtop >= 0) {
			mtop = mtop * -1 - 1000;
			tag(field).style.top = mtop + 'px';
		}
	}
}

// pass name(s) of tags which are absolutely positioned
//
// NOTE: for compatibility (only way it can work in Safari) you MUST specify
// the "top" for the absolute position of these elements INLINE (ie in the html
// document).
function show_abs(all) {
	//if(!(all instanceof Array)) {
	//	all = [all];
	//}

	for(var i in all) { var field = all[i];
		mtop = strip2(tag(field).style.top);
		if(mtop < 0) {
			mtop = mtop * -1 - 1000;
			tag(field).style.top = mtop + 'px';
		}
	}
}
