/* -----------------------------------------------------------------------------
|	Функция открытия popup окон													|
|	пример использования для html страниц:										|
|	<a href="/feedback.php" onclick="return pop(this.href);">обратная связь</a>	|
| 	пример использования для картинок (gif, jpg, png)							|
|	<a href="/img/big.jpg"														|
|		onclick="return pop(this.href, '600', '400', 'название картинки');">	|
|	<img src="/img/small.jpg" width="300" height="200" /></a>					|
----------------------------------------------------------------------------- */
function pop(iUrl, winW, winH, winN) {
	var iWidth = (winW)? winW : 600;
	var iHeight = (winH)? winH : 500;
	var iTitle = (winN)? winN : 'popupWin';
	var scrollB = 'no';
	var posCode = '';

	if(screen) {
		var scrW = screen.width ? screen.width - 100 : 0;
		var scrH = screen.height ? screen.height - 100 : 0;
		if( scrW < iWidth ) { scrollB = 'yes'; iWidth = scrW; }
			else { scrW = screen.width }
		if( scrH < iHeight ) { scrollB = 'yes'; iHeight = scrH; }
			else { scrH = screen.height }
		var posX = Math.round( ( scrW - iWidth ) / 2 );
		var posY = Math.round( ( scrH - iHeight ) / 2 );
		posCode = ',left='+posX+',top='+posY;
	}

	iOptions = 'width=' + iWidth + ',height=' + iHeight + ',scrollbars=' + scrollB + ',resizable=no,toolbar=no,status=yes' + posCode;

	if(iUrl.match(/\.(gif|jpe?g|png)$/i)) {
		popWin = window.open('', '_blank', iOptions);
		popWin.document.open();
		popWin.document.write('<html><head><title>' +
			iTitle +
			'</title></head>'+
			'<meta http-equiv="content-type" content="text/html; charset=utf-8" />'+
			'<body style="background: #fff; margin: 0; padding: 0;">' +
			'<table cellpadding="0" cellspacing="0" border="0" height="100%"><tr><td>' +
			'<a href="#" onclick="self.close()"><img src="' + iUrl + '" alt="'+iTitle+' - кликните для закрытия окна" border="0" /></a></td></tr></table></body></html>'
			);
		popWin.document.close();
	} else {
		popWin = window.open(iUrl, iTitle, iOptions);
	}

	popWin.focus();
	return false;
}