function wOpen(url, popW, popH, isCentered, scrollbars  ){
	if (!popW) {
		popW = 400;
	}
	if (!popH) {
		popH = 300;
	}
	if (!isCentered) {
		isCentered = 0;
	}
        if(!scrollbars ){
          scrollbars  = 1;
        }  
	if (isCentered == 1){
		if (document.all || document.layers) {
			w = screen.availWidth;
			h = screen.availHeight;
		}
		var leftPos = (w-popW)/2, topPos = (h-popH)/2;
		window.open(url, 'window', 'scrollbars='+ scrollbars +  ', width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
	}else if (isCentered == 2) {
		if (document.all) {
			/* the following is only available after onLoad */
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
		else if (document.layers) {
			w = window.innerWidth;
			h = window.innerHeight;
		}

		var leftPos = (w-popW)/2, topPos = (h-popH)/2;
		window.open(url, 'window', 'width=' + popW + ',height=' + popH );
	}else{
		window.open(url, 'window', 'width=' + popW + ',height=' + popH );
	}
}

/*  JS Menu  */

var TimeOut         = 300;
var currentLayer	= null;
var currentitem		= null;
var currentLayerNum = 0;
var noClose			= 0;
var closeTimer		= null;

function getBounds(element)
{
  var left = element.offsetLeft;
  var top = element.offsetTop;
  for (var parent = element.offsetParent; parent; parent = parent.offsetParent)
  {
    left += parent.offsetLeft;
    top += parent.offsetTop;
  }
  return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight};
}

function mopen(n, type)
{
	var xOffset = 0;
	var yOffset = 0;
	var mod;
	switch (type){
		case "h": //horisontal menu
			xOffset = 0;
			yOffset = 19;
			mod = "h";
			break;
		case "v": //vertical menu
			xOffset = 208;
			yOffset =  0;
			mod = "v";
			break;
		case "t": // title menu
			xOffset = -15;
			yOffset = 16;
			mod = "t";
			break;
	}
	var l	= document.getElementById(mod + "Menu" + n);
	var mm	= document.getElementById(mod + "MMenu"+n);
	var bounds = getBounds( mm );
	
	if(l)
	{
		mcancelclosetime();
		if ( type == "t" ) xOffset += bounds.width;
		l.style.top =  bounds.top + yOffset + 'px';
		//alert(l.style.top);
		l.style.left = bounds.left + xOffset + 'px';
		l.style.display='block';//visibility='visible';

		if(currentLayer && (currentLayerNum != mod+n))
			currentLayer.style.display='none';//visibility='hidden';

		currentLayer = l;
		currentitem = mm;
		currentLayerNum = mod+n;			
	}
	else if(currentLayer)
	{     
		currentLayer.style.display='none';//visibility='hidden';
		currentLayerNum = 0;
		currentitem = null;
		currentLayer = null;
	}
}

function mclosetime()
{
	closeTimer = window.setTimeout(mclose, TimeOut);
}

function mcancelclosetime()
{
	if(closeTimer)
	{
		window.clearTimeout(closeTimer);
		closeTimer = null;
	}
}

function mclose()
{
	if(currentLayer && noClose!=1)
	{
		currentLayer.style.display='none';//visibility='hidden';
		currentLayerNum = 0;
		currentLayer = null;
		currentitem = null;
	}
	else
	{
		noClose = 0;
	}

	currentLayer = null;
	currentitem = null;
}

document.onclick = mclose; 

/*  //JS Menu  */


