function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function getBodyScrollTop()
{
	return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getBodyScrollLeft()
{
	return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

function getClientCenterX()
{
	return parseInt(getClientWidth()/2)+getBodyScrollLeft();
}

function getClientCenterY()
{
	return parseInt(getClientHeight()/2)+getBodyScrollTop();
}

// Открытие всплывающего окна
function up_window(img,width,height)
{
  var left = getClientCenterX();
  var top = getClientCenterY()-80;

  document.getElementById('up_window').style.left = (left-(width/2))+"px";
  document.getElementById('up_window').style.top = (top-(height/2))+"px";
  document.getElementById('up_window').style.display = 'block';

  document.getElementById('up_img').src = img;
  document.getElementById('up_img').width = width;
  document.getElementById('up_img').height = height;
}

// Закрытие всплывающего окна
function close_window()
{
  document.getElementById('up_window').style.display = 'none';
}

function getElemPosition(elemId)
{
    var elem = document.getElementById(elemId);
	
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
	
    var l = 0;
    var t = 0;
	
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}

var lastOpen = 'conditioners';

function displayMenu(elemId)
{
  pos = getElemPosition(elemId);

  document.getElementById('block_'+elemId).style.top = (parseInt(pos.top)+parseInt(pos.height))+'px';
  document.getElementById('block_'+elemId).style.left = (pos.left)+'px';
  document.getElementById('block_'+elemId).style.display = 'block';
  
  lastOpen = elemId;
}

function hiddenMenu(elemId)
{
  document.getElementById('block_'+elemId).style.display = 'none';
}

function hiddenAllBlock()
{
  document.getElementById('block_'+lastOpen).style.display = 'none';  
}

// Отобразим всплывающее окно по центру пользовательского экрана
function openWindows(elem)
{
  var centerX = getClientCenterX();
  var centerY = getClientCenterY();

  document.getElementById(elem).style.display='block';
  
  var elementPos = getElemPosition(elem);

  document.getElementById(elem).style.top = centerY - Math.round(elementPos.height/2);
  document.getElementById(elem).style.left = centerX - 250;
}