
var scWindowX;
var scWindowY;
var scColorDepth;
var scLegacy = false;

function getResolution() {

	if (document.all) {
		scColorDepth=screen.colorDepth
		if (navigator.userAgent.indexOf("MSIE")!=-1) {
			if(navigator.userAgent.indexOf("MSIE 6")!=-1 && document.compatMode=="CSS1Compat") {
				scWindowX=document.documentElement.clientWidth;
				scWindowY=document.documentElement.clientHeight;
			} else {
				scWindowX=document.body.offsetWidth-20;			// IE5.00 correction
				scWindowY=document.body.offsetHeight-4;
				scLegacy=true;
			}
		}
 		if ((navigator.userAgent.indexOf("Konqueror")!=-1)  || (navigator.userAgent.indexOf("Opera")!=-1)) {
			scWindowX=window.innerWidth;
			scWindowY=window.innerHeight;
		}
	} else if (document.layers || !document.all) {
		scWindowX=window.innerWidth;
		scWindowY=window.innerHeight;
		scColorDepth=screen.pixelDepth		
	}
//alert("size: "+scWindowX+"x"+scWindowY+"x"+scColorDepth);
}

//-------------------------------------------------------------

function stripPx(v) {
   if (v!="") {
	return parseInt(v.substr(0,v.length-2));
   } else { 
        return 0;
   }
}

function fixBlock(id,iTop,iLeft,iBottom,iRight,sKind,sBottom,sRight) {
	iTop=parseInt(iTop);
	iLeft=parseInt(iLeft);
	iBottom=parseInt(iBottom);
	iRight=parseInt(iRight);

	getResolution();
	if (x=document.getElementById(id)) {
		win=x.style; 
		if (!scLegacy) {
			hExtra=  stripPx(win.borderLeftWidth) +
 				stripPx(win.borderRightWidth)+
 			 	stripPx(win.paddingLeft)+
 			 	stripPx(win.paddingRight)+
 			 	stripPx(win.marginLeft)+
 			 	stripPx(win.marginRight);

			vExtra= stripPx(win.borderTopWidth) +
			 	stripPx(win.borderBottomWidth)+
 			 	stripPx(win.paddingTop)+
 			 	stripPx(win.paddingBottom)+
 			 	stripPx(win.marginTop)+
 			 	stripPx(win.marginBottom);
		} else {
			hExtra= stripPx(win.marginLeft)+
 				stripPx(win.marginRight);
			vExtra=  stripPx(win.marginTop)+
 				stripPx(win.marginBottom);
		}

		win.top=iTop+sKind;
		win.left=iLeft+sKind;

		if (sRight=='width') {
			if ((iRight-hExtra)>(scWindowX-iLeft)) {
				iRight=scWindowX-iLeft;
			}
			win.width=(iRight-hExtra)+sKind;
		} else {
			win.width=((scWindowX-(iLeft-iRight))-hExtra)+sKind;
		}
		
		if (sBottom=='width') {
			if ((iBottom-vExtra)>scWindowY-iTop) {
				iBottom=scWindowY-iTop;
			}
			win.height=(iBottom-vExtra)+sKind;
		} else {
			win.height=((scWindowY-(iTop-iBottom))-vExtra)+sKind;
		}
	win.visibility="Visible";
	}
//	alert(id+" "+win.top+" "+win.left+" "+win.width+" "+win.height+" ");

}

function fixSideMenu(id,top) {
	top=parseInt(top);
	if (x=document.getElementById(id)) {

	if (!scLegacy) {
		vExtra=  stripPx(x.style.borderTopWidth) +
			 stripPx(x.style.borderBottomWidth)+
 			 stripPx(x.style.paddingTop)+
 			 stripPx(x.style.paddingBottom)+
 			 stripPx(x.style.marginTop)+
 			 stripPx(x.style.marginBottom);
		} else {
		vExtra=  stripPx(x.style.marginTop)+
 			 stripPx(x.style.marginBottom);
		}

		x.style.height=(scWindowY-top)-vExtra+"px";
	}
}


// -----------------------------------------------------------------
// menu basic functions 

var remember = new Array();
var remember2 = new Array();
var checkIt;

var DHTML = (document.getElementById || document.all || document.layers);

function show(name,lvl,obj)
{
	if (!DHTML) return;
	checkUserInput();
	if (remember[lvl] && remember[lvl] == name) return;
	if (remember[lvl])
	{
		closeAll(lvl);
	}
	if (name)
	{
		var x = getObj(name);
		x.visibility = 'visible';
	}
	remember[lvl] = name;
	if (obj.parentNode) y = obj.parentNode;
	else if (obj.parentElement) y = obj.parentElement;
	else return;
	if (y.className) return;
	y.className = 'over';
	if (remember2[lvl]) remember2[lvl].className = '';
	remember2[lvl] = y;
}

function closeAll(lvl)
{
	for (i=remember.length - 1;i>=lvl;i--)
	{
		if (remember[i]) //IE4 Mac
		{
			var x = getObj(remember[i]);
			x.visibility = 'hidden';
		}
		remember[i] = null;
		if (remember2[i])
		{
			remember2[i].className = '';
			remember2[i] = null;
		}
	}

}

function checkUserInput()
{
	if (checkIt) clearTimeout(checkIt);
	checkIt = setTimeout('closeAll(1)',10000);
}

function getObj(name)
{
  return document.getElementById(name).style;
  
 /* 
  if (document.getElementById(name))
  {
    return document.getElementById(name).style;
  }
  else if (document.all)
  {
    return document.all[name].style;
  }
  else if (document.layers)
  {
    return document.layers[name];
  }
  else return false;
 */
}


