function popup(theURL, winName, winWidth, winHeight, features) 
{
	if (winWidth > (screen.width-100))
	{
		winWidth = screen.width-100;
	}
	
	if (winHeight > (screen.height-100))
	{
		winHeight = screen.height-100;
	}
	
	var w = (screen.width - winWidth)/2;
	var h = (screen.height - winHeight)/2 - 100;
	var features = features+',width='+winWidth+',height='+winHeight+',top='+h+',left='+w;
	
	_popup = window.open(theURL, winName, features);
	_popup.focus();
	return false;
}

function item_popup(pageID, itemID)
{
	var winName = '';
	var winWidth = 650;
	var winHeight = 370;
	var features = '';
	return popup('/content/cat/item_popup.php?pid='+pageID+'&iid='+itemID, winName, winWidth, winHeight, features);
}
// Функция открытия окон с большими фотографиями
function bigFotoWin(page_id, slide_id, width, height)
{
	window.open('/tpl/popup_foto.php?page_id='+page_id+'&slide_id='+slide_id,'screen','width='+width+' height='+height+',scrollbars=1,resizable=1');
	return false;
}
function free_areas_popup(page_id, slide_id)
{
	var winName = 'screen';
	var winWidth = 650;
	var winHeight = 370;
	var features = 'scrollbars=1,resizable=1';
	return popup('/tpl/free_areas_popup.php?page_id='+page_id+'&slide_id='+slide_id, winName, winWidth, winHeight, features);
}
//****************************************************************************
// Определение браузера
IE = (document.all); // Internet Explorer?
NC = (document.layers); // Netscape?
Opera = (document.getElementById); // Opera?

function getHeight() { // Получаем высоту рабочей области браузера
if (IE || Opera) send = document.body.clientHeight;
if (NC) send = window.innerHeight;
return send;
}

function getWidth() { // Получаем ширину рабочей области браузера
if (IE || Opera) send = document.body.clientWidth;
if (NC) send = window.innerWidth;
return send;
}


function change_image(img)
{
  
  var widthBrowser = getWidth();
  var winWidth = 540;
  var w = (widthBrowser - winWidth)/2;
  
  document.getElementById('mainimg').src = img;
  document.getElementById('image_popup').style.left=w+"px";
  document.getElementById('image_popup').style.top=150+"px";
  document.getElementById('image_popup').style.display="inline";
}
function close_image_popup()
{
  document.getElementById('image_popup').style.display="none";
}
//****************************************************************************
//размер клиентской части браузера(другой вариант)
function screenSize() {
    var w, h; // Объявляем переменные, w - длина, h - высота
    w = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
    h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
    return {w:w, h:h}; 
}
// Пример:
/*document.write(
    "Длина = " + screenSize().w + "px<br>" +
    "Высота = " + screenSize().h + "px"
);*/

