function openPopup(url,name,width,height) {
	var popupWin = top[name];
	
	if (popupWin != null && typeof(popupWin) == 'object' && !popupWin.closed) {
		if (popupWin.document.location.href != url) {
			popupWin.document.location.href = url;
		}
	} else {
		popupWin = window.open(url, name, 'width=' + width + ',height=' + height + ',status=yes,menubar=yes,resizable=yes,scrollbars=yes,left=' + String((screen.width-width)/2) + ',top=' + String((screen.height-height)/2));
	}
	popupWin.focus();
}

function fitWinToImg() {

	var pDescr = document.getElementById('descr').offsetHeight;

	if(pDescr > 30 ) {
		pDescr = pDescr+16;
	}

	var nWidth = document.images[0].width - document.body.clientWidth;
	var nHeight = (document.images[0].height - document.body.clientHeight)+pDescr;

	window.resizeBy(nWidth, nHeight);
	
	mWidth = (screen.width - document.body.clientWidth)/2;
	mHeight = (screen.height - document.body.clientHeight)/2;

	window.moveTo(mWidth, mHeight);

}

function closePopup(url) {
	if (opener) {
		if (opener.closed) window.open(url, "");
		self.close();
		return false;
	}
	return true;
}
