/* functions / init from Milonic DHTML Menu */
_d=document;
_dB=_d.body;
_n=navigator;
_L=location;
_nv=_n.appVersion.toLowerCase();
_nu=_n.userAgent.toLowerCase();
_ps=parseInt(_n.productSub);
_f=false;
_t=true;
_n=null;
_W=window;
_wp=_W.createPopup;
ie=(_d.all)?1:0;
ie4=(!_d.getElementById&&ie)?1:0;
ie5=(!ie4&&ie&&!_wp)?1:0;
ie55=(!ie4&&ie&&_wp)?1:0;
ns6=(_nu.indexOf("gecko")!=-1)?1:0;
konq=(_nu.indexOf("konqueror")!=-1)?1:0;
sfri=(_nu.indexOf("safari")!=-1)?1:0;
if(konq||sfri){_ps=0;ns6=0}
if(konq||sfri){_ps=0;ns6=0}
ns4=(_d.layers)?1:0;
ns61=(_ps>=20010726)?1:0;
ns7=(_ps>=20020823)?1:0;
ns72=(_ps>=20040804)?1:0;
ff15=(_ps>=20060000)?1:0;
op=(_W.opera)?1:0;
if(op||konq)ie=0;
op5=(_nu.indexOf("opera 5")!=-1)?1:0;
op6=(_nu.indexOf("opera 6")!=-1||_nu.indexOf("opera/6")!=-1)?1:0;
op7=(_nu.indexOf("opera 7")!=-1||_nu.indexOf("opera/7")!=-1)?1:0;
mac=(_nv.indexOf("mac")!=-1)?1:0;
mac45=(_nv.indexOf("msie 4.5")!=-1)?1:0;
if(ns6||ns4||op||sfri)mac=0;ns60=0;
if(ns6&&!ns61)ns60=1;
if(op7)op=0;IEDtD=0;
if(!op&&((_d.all||ns7)&&_d.compatMode=="CSS1Compat")||(mac&&_d.doctype&&_d.doctype.name.indexOf(".dtd")!=-1))IEDtD=1;
if(op)ie55=0;ie5=0;

$u="undefined ";

function gmobj(_mtxt){
	if(_d.getElementById){
		return _d.getElementById(_mtxt)
	}else if(_d.all){
		return _d.all[_mtxt]
	}
}

function spos(g,t,l,h,w){
	_px="px";
	var s=g.style;
	if(w<0)w=0;if(h<0)h=0;
	if(w+" "==$u)w=_n;
	if(h+" "==$u)h=_n;
	if(op){
		_px="";
		if(w!=_n)s.pixelWidth=w;
		if(h!=_n)s.pixelHeight=h
	}else{
		if(w!=_n)s.width=w+_px;
		if(h!=_n)s.height=h+_px;
	}
	if(!isNaN(t)&&t!=_n)s.top=t+_px;
	if(!isNaN(l)&&l!=_n)s.left=l+_px
}

function $pU(v){if(v)return parseInt(v)}

function gpos(g){
	if(!g)return;
	var h=g.offsetHeight;
	var w=g.offsetWidth;
	if(op5){
		h=g.style.pixelHeight;
		w=g.style.pixelWidth
	}
	var o=g;
	var t=0;
	var l=0;
	var foundObject=0;
	while(o!=_n){
		t+=o.offsetTop;
		l+=o.offsetLeft;
		o=o.offsetParent
	}
	if(sfri){l-=0;t-=0}
	if(mac&&_dB){
		_mcdb=_dB.currentStyle;
		_mcf=_mcdb.marginTop;
		if(_mcf)t=t+$pU(_mcf);
		_mcf=_mcdb.marginLeft;
		if(_mcf)l=l+$pU(_mcf)
	}
	return(new Array(t,l,h,w))
}

/* from Brainjar port to Windows */
var activeButton=_n;
function menu_action_open(event,menuId,top,closeit){
	var button;
	if(ie) button=window.event.srcElement;
	else button=event.currentTarget;
	if(activeButton!=_n&&activeButton==button) return;
	if(button.menu==_n) button.menu=gmobj(menuId);
	if(activeButton!=_n) resetButton(activeButton);
	if(button!=activeButton){
		depressButton(button,top,closeit);
		activeButton=button;
	}else activeButton=_n;
	return _f;
}
function menu_action_close(){
	if(activeButton!=_n){
		resetButton(activeButton);
		activeButton=_n;
	}
}
function depressButton(button,top,closeit){
	var x,y,cl;
	_gp1=gpos(button);
	_gp2=gpos(button.menu);
	x=_gp1[1];
	_gp=gpos(button.menu);
	if (top) {
		y=_gp1[0]-_gp2[2];
	} else {
		y=_gp1[0]+_gp1[2];
	}
	_gp3=gpos(gmobj('lastMenu'));
	if(x+_gp2[3]>_gp3[1]+_gp3[4]) x=_gp3[1]+_gp3[4]-_gp2[4];
	cl=gmobj('menu_action_close');
	spos(button.menu,y,x)
	button.menu.style.visibility="visible";
	spos(cl,y+5,x+parseInt(_gp2[3])-15,_n,_n);
	if(closeit) cl.style.visibility="visible";
}

function resetButton(button){
	if(button.menu!=_n){
		button.menu.style.visibility="hidden";
		gmobj('menu_action_close').style.visibility="hidden";
	}
}