
var NS6plus = (parseFloat(navigator.appVersion) >= 5 && navigator.appName.indexOf("Netscape")>=0 )? true: false;
var Mozilla = (NS6plus && (navigator.userAgent.indexOf("Netscape") < 0));

function showtm() {
    if (document.body.clientWidth && !isNaN(document.body.clientWidth) && !Mozilla) {
	    nW = document.body.clientWidth;
	    nH = document.body.clientHeight;
    } else {
	    nW = window.innerWidth - 18;
	    nH = window.innerHeight;
    }

    var x = (nW - 994) / 2 + 347;
    var e = $('toolmenu');
    e.style.left = x+"px";
    MM_showHideLayers('toolmenu', '', 'show');
}
function hidetm() {
    MM_showHideLayers('toolmenu', '', 'hide');
}

var tm_tmo = 0;
var tm_state = 0;
var tm_maybe = "";
var tm_active = "";
var tm_default = "";

// States:
// 0 - no rollever active
// 1 - rollover started, 500ms delay
// 2 - normal rollever, post delay
// 3 - left rollever, keep nav up
var state1delay = 200;  // in ms = 1/5 second
var state3delay = 1000; // in ms = 1 second

// called when the mouse moves over a primary nav button
// arg is the name of the layer this button activates
function tm_ro_enter(tag) {
//  debug("tm_ro_enter("+tag+") "+tm_state);
  if (tm_state == 0) {
    tm_state = 1;
    tm_maybe = tag;
    tm_tmo = setTimeout("state1tmo()", state1delay);
  } else if (tm_state == 1) {
    tm_maybe = tag;
    clearTimeout(tm_tmo);
    tm_tmo = setTimeout("state1tmo()", state1delay);
  } else if (tm_state == 2) {
    tm_state = 1;
    tm_maybe = tag;
    tm_tmo = setTimeout("state1tmo()", state1delay);
  } else if (tm_state == 3) {
    tm_state = 1;
    tm_maybe = tag;
    clearTimeout(tm_tmo);
    tm_tmo = setTimeout("state1tmo()", state1delay);
  }
}

// called when the mouse leaves a primary nav button
// arg is the name of the layer this button activates
function tm_ro_leave(tag) {
//  debug("tm_ro_leave("+tag+") "+tm_state);
//  MM_swapImgRestore();
  if (tm_state == 0) {
  } else if (tm_state == 1) {
    tm_state = 0;
    clearTimeout(tm_tmo);
  } else if (tm_state == 2) {
    tm_state = 3;
    tm_tmo = setTimeout("state3tmo()", state3delay);
  } else if (tm_state == 3) {
  }
}

// called early in page to set the default sub-nav for this page
function tm_ro_setdefault(tag) {
  tm_default = tag;
  tm_resetnav();
}

// called when the timer for state 1 goes off
function state1tmo() {
//  debug("state1tmo() "+tm_state);
  tm_state = 2;
  activate(tm_maybe);
}

// called when the timer for state 3 goes off
function state3tmo() {
//  debug("state3tmo() "+tm_state);
  tm_state = 0;
  activate('');
}

// change which subnav is visible
function activate(tag) {
  if (tag == tm_active) {
    return;
  }
  if (tag == 'tool' || tag == 'x') {
    MM_swapImage('toolsarrow', '', '/images/smarrowdn.gif');
    MM_showHideLayers('toolmenu', '', 'show', 'summitmenu','','hide');
  } else if (tag == 'summit') {
    MM_showHideLayers('toolmenu','','hide','summitmenu', '', 'show');
  } else {
    tm_resetnav();
  }
  tm_active = tag;
}

function tm_resetnav() {
  MM_swapImage('toolsarrow', '', '/images/smarrowrt.gif');
  MM_showHideLayers('toolmenu', '', 'hide');
  MM_showHideLayers('summitmenu', '', 'hide');
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

var _console = null;
function debug(msg) {
  if ((_console == null) || (_console.closed)) {
    _console = window.open("", "console", "width=600,height=300,resizable");
    _console.document.open("text/plain");
  }
  _console.focus();
  _console.document.writeln(msg);
}

function treeToggle(eltname, w) {
    var telt = document.getElementById(eltname+"-body");
    var ielt = document.getElementById(eltname+"-icon");
    if (telt.style.display == 'none') {
        telt.style.display = 'block';
	if (w) {
	    ielt.src="images/listopen.gif";
	} else {
	    ielt.src="images/smarrowdn.gif";
	}
	document.cookie = eltname+"=1; expires=Thu, 12 Dec 2020 12:00:00";
    } else {
        telt.style.display = 'none';
	if (w) {
	    ielt.src="images/listclosed.gif";
	} else {
	    ielt.src="images/smarrowrt.gif";
	}
	document.cookie = eltname+"=0; expires=Thu, 12 Dec 2020 12:00:00";
    }
}

function help(tag) {
  win = window.open("/help/"+tag+".php", "portalhelp", "height=450,width=400,resizable,scrollbars");
  win.focus();
}

function openwin(url) {
  win = window.open(url);
}

function doselection(ecode) {
    var e = $('selmu');
    window.location = "/sessions.php/"+ecode+"/"+e.value;
}

function changemulti() {
    var m = $('multi').value;
    if (m == 'any') {
	elt = $('erow1');
	elt.style.display = 'none';
	elt = $('erow2');
	elt.style.display = 'none';
	elt = $('erow3');
	elt.style.display = 'none';
    } else if (m == 'one') {
	elt = $('erow1');
	elt.style.display = 'block';
	elt = $('erow2');
	elt.style.display = 'none';
	elt = $('erow3');
	elt.style.display = 'none';
    } else {
	elt = $('erow1');
	elt.style.display = 'block';
	elt = $('erow2');
	elt.style.display = 'block';
	elt = $('erow3');
	elt.style.display = 'block';
    }
}
