var curselb;
var curhb;
var ignore=0;

// colors
var fnCol="#000080"; // 
var bnCol="#F7FFFF";

var fhCol="#000080"; // NAVY
var bhCol="#87CEEB";

var fsCol="#FFFFFF"; // White
var bsCol="#6487dc"; // 

function gete(id) {
	var e=null;

	if (document.getElementById) {
		e= document.getElementById(id);
		} else
	if (document.all) {
		e= document.all[id];
		} else
	if (document.layers) {
		e= document.layers[id];
		}

	return e;
	}

function highlight(action,p,button) {
	if (button == curselb[p]) return;
	
	var b= gete(p+button);
	var igv = (b?1:0);
	if (!b) b= gete(p+button+"_");

	if (b) {
		if (b.style) {
			switch (action) {
				case 0:	b.style.backgroundColor= bhCol; break;
				case 1: b.style.backgroundColor= bnCol; break;
				case 2:
				case 3: b.style.backgroundColor= bsCol; break;
				}
			} else
		if (b.bgColor) {
			switch (action) {
				case 0:	b.bgColor= bhCol; break;
				case 1: b.bgColor= bnCol; break;
				case 2:
				case 3: b.bgColor= bsCol; break;
				}
			}

		if (b.childNodes) b= b.childNodes.item(0); else
		if (b.children  ) b= b.children       (0); else
		                  b= 0;
		if (b && b.style) {
			switch (action) {
				case 0:	b.style.color= fhCol; break;
				case 1: b.style.color= fnCol; break;
				case 2:
				case 3: b.style.color= fsCol; break;
				}
			}
		if ((action==2) && (window.location.href != b.href)) {
			ignore= igv;
			window.location.href= b.href;
			}
		}
	}

function selbutton(action,p,newselb) {   
	if (gete(p+newselb    )) dosel=1; else
	if (gete(p+newselb+"_")) dosel=0; else return;
	
	if (dosel==1) {
		oldselb   = curselb[p];
		curselb[p]= -1;
		}
	highlight(     1,p,oldselb);
	highlight(action,p,newselb);
	if (dosel==1) {
		curselb[p]= newselb;
		}
	}

function act(e) {
	if (ignore) return;

	if (!e) var e= window.event;

	var a;
	if (e.type == "click"    ) a= 2; else
	if (e.type == "mouseover") a= 0; else
	if (e.type == "mouseout" ) a= 1;

	var t= 0;
	if (e.target    ) t= e.target; else
	if (e.srcElement) t= e.srcElement;
	if (!t) return false;
	if (t.nodeType == 3) t= t.parentNode;
	
	while (t.tagName != "LI") t= t.parentNode;
	var o= parseInt(t.id.substr(1));
	if (!o) return false;

	var p= t.id.substr(0,1);
	if (!curhb[p]) curhb[p]= -1;
	
	var c= curhb[p];
	if (c>=0 && o<c) {
		if (o==(c-(c%  100))/  100) return false;
		if (o==(c-(c%10000))/10000) return false;
		}
	curhb[p]= a?-1:o;

	switch (a) {
		case 0: highlight(a,p,o); return false; break;
		case 1: highlight(a,p,o); return true;  break;
		case 2: selbutton(a,p,o); return false; break;
		}
	}

function ninitr(e,curselb) {
	var r;
	var id;

	while (e) {
		if (e.firstChild)                      ninitr(e.firstChild        ,curselb); else
		if (e.childNodes && e.childNodes.item) ninitr(e.childNodes.item[0],curselb); else
		if (e.children                       ) ninitr(e.children       (0),curselb);

		r= e;
		e= e.nextSibling;

		if (r.tagName == "UL") {
			id= parseInt(r.id.substr(1));
			s= 0;
			if (curselb < id) {
				if (curselb == id / 100) s= 1;
				} else
			if (curselb > id) {
				if ( curselb        - ( curselb        % 100) == id ||
					(curselb/  100) - ((curselb/  100) % 100) == id ||
					(curselb/10000) - ((curselb/10000) % 100) == id) s= 1;
				}
			if (s == 0) {
				if (r.style) r.style.display="none";
				if (r.parentNode            )
				if (r.parentNode.removeChild) r.parentNode.removeChild(r);
				}
			} else
		if (r.tagName == "LI") {
			r.onclick    = act;
			r.onmouseover= act;
			r.onmouseout = act;
			}
		}
	}

function ninit(p,id) {
	ninitr(gete(p + 0),id);
	curselb[p]= -1;
	selbutton(3,p,id);
	}

function navi(ni,li) {
	curselb= new Array;
	curhb  = new Array;
	ninit("m",ni);
	ninit("l",li);
	}
