function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.opera6=this.agent.indexOf("Opera 6")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}


//Minimal Width and height of the button "Close this Window"
var btnCloseHeight=22;
var btnCloseWidth=103;
var vertSpace=15;
var horizMargin=16;
var coeff=1.1;

function getStringWinParam(mandParam,optParam) {
//function to merge mandatory and optional parameters to open window
strParam=mandParam+','+optParam;
return strParam;
}

function brPopupWindowPicOpen(url,picWidth,picHeight,averHeightAdjust,number) {
// function to open new window with HTML file containing a template for picture enlarged view
width=parseInt(picWidth*coeff) + 2*horizMargin;

height=picHeight+btnCloseHeight+4*vertSpace+16+averHeightAdjust;
winWidth=width.toString(10);
winHeight=height.toString(10);
strWinMandatoryParam='width=' + winWidth+',height='+winHeight;
strWinOptionalParam='rezizable=no,scrollbars=no,menubar=no,status=no,location=no,dependent=yes';
strParameters=getStringWinParam(strWinMandatoryParam,strWinOptionalParam);
//alert(strParameters);
strUniqPopupWinName=winWidth+winHeight+number.toString(10);
popupWin=window.open(url,strUniqPopupWinName,strParameters);
popupWin.focus();
}

function brPopUpWindowClose() {
window.close();
if (window.opener) {
 opener.focus();
}

}

function openNewWindow(src,w,h) {
	strParam= 'width=' + w+',height='+h+';'+'rezizable=no,scrollbars=no,menubar=no,status=no,location=no,dependent=yes';
	popupWin=window.open(src,'a'+w+h,strParam);
	popupWin.focus();
}

function openNewWindowScroll(src,w,h) {

	var strParam= 'width=' + w + ',height='+h+';'+'rezizable=no,scrollbars=yes,menubar=no,status=no,location=no,dependent=yes';
	var popupWin=window.open(src,'a'+w+h,strParam);
	popupWin.focus();
}

function openWindow(src,w,h) {
	var winHeight = h;
	var scrHeight = screen.availHeight-60;
	alert(screen.availHeight);
	if(h > scrHeight) {
		winHeight = scrHeight

		openNewWindowScroll(src,w+20,winHeight)
	} else {
		openNewWindow(src,w,winHeight)
	}

}