  // Создаём элементы
  function elem(name, attrs, style, text, ParentElement)
  {
    var e = document.createElement(name);

    if (attrs) for (key in attrs) e[key] = attrs[key];
    if (style) for (key in style) e.style[key] = style[key];
    if (text) e.appendChild(document.createTextNode(text));

    if (ParentElement) ParentElement.appendChild(e);

    return e;
  }

  // Получить объяет по его ID
  function ge (ItemName) {
    return(document.getElementById(ItemName));
  }

  // Убираем фото с экрана
  function ResetBox(objectId) {
    // Очищаем блок
    ge(objectId).innerHTML ='';

    // Прячем блок
    ge(objectId).style.display = 'none';
  }

  // Выводим картинку на экран
  function ShowImage(src, iFolder, width, height)
  {
	if (width > 800) var width_new = 800;
      else var width_new = width;
    var height_new = height * (width_new / width);
	
//    var img_html = '<p align="left"><a href="#" onClick="ResetBox(\'contBox\');">Закрыть</a></p><img src="img/img.php?src='+src+'&iStyle=real&iFolder='+iFolder+'" width='+width+' height='+height+'>';
    var img_html = '<p align="left"><a href="#" onClick="ResetBox(\'contBox\');">Закрыть</a></p><img src="img/img.php?src='+src+'&iStyle=real&iFolder='+iFolder+'" width='+width_new+' height='+height_new+'>';

    // Создаём элемент DIV
    if (!ge('contBox'))
      elem('div', {id: 'contBox'}, {innerHTML: '', 'position': 'absolute'}, '', document.body);

    ge('contBox').style.left = getScreenWidth()/2-width_new/2;
//    ge('contBox').style.top =  getScreenHeight()/2-height_new/2;
    ge('contBox').style.top =  '10px';
    ge('contBox').style.width= width_new;
    ge('contBox').style.height = height_new;

//    ge('contBox').style.left = window.screen.width/2-width/2;
//    ge('contBox').style.top =  window.screen.height-height+10;
//    ge('contBox').style.width= width;
//    ge('contBox').style.height = height;

    ge('contBox').innerHTML = img_html;

    ge('contBox').style.display = 'block';
  }
  
	// Получить размеры экрана
	function getScreenWidth() {
        return document.body.offsetWidth ? document.body.offsetWidth : window.innerWidth;
	}

	function getScreenHeight() {
        return document.body.offsetHeight ? document.body.offsetHeight : window.innerHeight;
    }  
  
  
