// global variables
var activeitems = new Array();
var suppressclick = false;

// ... and images
var img_arrow_0 = new Image(6, 9);
img_arrow_0.src = '/images/misc/arrow_0.gif';
var img_arrow_1 = new Image(6, 9);
img_arrow_1.src = '/images/misc/arrow_1.gif';

// menu functions
function mi_mouseover(p) {
	var f = get_me(event.fromElement);
	var t = get_me(event.toElement);
	if (f != t) {
		if (t && t.tagName != 'DIV') {
			var lt = get_level(t);
			mi_highlight(t);
			activeitems[lt] = t;
		}
	}
}
function mi_mouseout() {
	var f = get_me(event.fromElement);
	var t = get_me(event.toElement);
	if (f != t) {
		if (f) {
			var lf = get_level(f);
			if (f.tagName == 'DIV') lf--;
			var lt = 0;
			if (t) lt = get_level(t);
			while (lf >= lt) {
				if (activeitems[lf]) mi_normal(activeitems[lf]);
				lf--;
			}
		}
	}
}
function mi_click() {
	var e = event.srcElement;
	if (e.tagName != 'A') {
		var c = get_me(e);
		if (c) {
		  var a = c.getElementsByTagName('A')[0];
			if (a) window.location.href = a.href;
		}
	}
}
function mi_highlight(r) {
  var a = r.getElementsByTagName('TD');
  for (var j = 0; j < a.length; j++) a[j].style.backgroundColor = '#706960';
  var a = r.getElementsByTagName('A');
	for (var j = 0; j < a.length; j++) a[j].style.color = '#ffffff';
	window.status = a[0].href;
	var a = r.getElementsByTagName('IMG');
	for (var j = 0; j < a.length; j++) if (a[j].src == img_arrow_0.src) a[j].src = img_arrow_1.src;
}
function mi_normal(r) {
  var a = r.getElementsByTagName('TD');
	for (var j = 0; j < a.length; j++) a[j].style.backgroundColor = '';
	var a = r.getElementsByTagName('A');
	for (var j = 0; j < a.length; j++) a[j].style.color = '';
	window.status = '';
	var a = r.getElementsByTagName('IMG');
	for (var j = 0; j < a.length; j++) if (a[j].src == img_arrow_1.src) a[j].src = img_arrow_0.src;
}
function get_me(start) {
	var e = start;
	while (e) {
		if ((e.tagName == 'DIV' || e.tagName == 'TR') && e.className.substring(0, 1) == 'z') break;
		e = e.parentElement;
	}
	return e;
}
function get_level(e) {
	var l = 0;
	if (e) l = parseInt(e.id.substring(1,2));
	if (isNaN(l)) l = 0;
	return l;
}

// misc functions
function set_focus(id) {
  if (document.getElementById) {
    var f = document.getElementById(id);
    if (f) f.focus();
    window.scrollTo(0, 0);
  }
}
function info_window(ref, winW, winH) {
  var infowin = window.open('/misc/infowindow.aspx?ref=' + ref, 'ac_infowindow', config = 'height=' + winH + ',width=' + winW + ',top=' + ((screen.availHeight - winH) / 2) + ',left=' + ((screen.availWidth - winW) / 2) + ',toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=yes');
  infowin.focus();
}

// miscellaneous
function scrollToTop() {window.scrollTo(0,0)}

// activate menus
menuitem_mouseover = mi_mouseover;
menuitem_mouseout = mi_mouseout;
menuitem_click = mi_click;
give_focus = set_focus;

