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.winsafari=this.agent.indexOf("KHTML")>-1	
	this.opera=this.agent.indexOf("Opera")>-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
}

var popUpHandlerNew = {
	
	popUpWin:		null,
	objOverlayWin: 	null,
	title: 		null,
getPageScroll: function(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
},
getPageSize:function(){
	
	var xScroll, yScroll , yPos;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
		yPos = document.body.scrollHeight;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
		yPos = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
		yPos = document.body.scrollHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,yPos) 
	return arrayPageSize;
},

	create:	function () {
		var objBody = document.getElementsByTagName("body").item(0);

		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.display = 'none';
		objBody.appendChild(objOverlay);
		this.objOverlayWin = objOverlay; 
		
		var popUp = document.createElement("DIV");
		popUp.className = "popUp";
		popUp.style.display = 'none';
		objBody.appendChild(popUp);
		this.popUpWin = popUp; 
	},	
	createHelpTip:	function (curName) {
		if (this.popUpWin == null) {
			this.create();
		}
		var popUp = this.popUpWin;
		var content = '';
		content += '<div class="popUp-out" align=center><div  id="popUp_w">';
		content += '<table id="popUp-table" border="0" cellspacing="0" cellpadding="5" style="border:1px solid #666;"  >';
		content += 		'<tr bgcolor="#7BC313">';
		content += 			'<td width="10" style="padding:3px;" >&nbsp;</td>';
		content += 			'<td  style="color:#fff" >' + curName + '</td>';
		content += 			'<td width="10" ><a href="javascript:void(0)" style="color:#fff; font-weight:bold; text-decoration:none;" onClick="popUpHandlerNew.popHide()"  >&nbsp;&nbsp;&nbsp;X&nbsp;&nbsp;&nbsp;</a></td>';
		content += 		'</tr>';
		content += 		'<tr  bgcolor="#ffffff">';
		content += 			'<td width="10" >&nbsp;</td>';
		content += 			'<td style="padding:10px;" ><div style="margin-right:6px;" id="inpopUp" name="inpopUp">Загрузка</td>';
		content += 			'<td width="10" >&nbsp;</td>';
		content += 		'</tr>';
		
		content += '</table>';
		content += '</div></div>';
		
		popUp.innerHTML = content;

		return popUp;
	},
	
	popHide: function () {
		// покажем селекты (вообще надо и ифреймы , но их тут нет)
		if (navigator.appName!="Netscape") {
			for (i = 0; i < document.all.tags("SELECT").length; ++i){
				document.all.tags("SELECT")[i].style.visibility = 'visible';
				}
			}
		var popUp = this.popUpWin;
		var objOverlay = this.objOverlayWin;
		if (popUp)	 {
			var bw=new lib_bwcheck();
			new Effect.DropOut('popUp-table'); 
			objOverlay.style.display = "none";
			if (bw.opera && document.body.scrollTop !=  0) {  // глюк оперы
				popUp.style.display = "none";
			}
			
		}
		popUp = null;	
	},
	
	view: function (main_contex) { 
		// скроем селекты (вообще надо и ифреймы , но их тут нет)
		if (navigator.appName!="Netscape") {
			for (i = 0; i < document.all.tags("SELECT").length; ++i){
				document.all.tags("SELECT")[i].style.visibility = 'hidden';
				}
			}
		var popUp = this.popUpWin;
		var objOverlay = this.objOverlayWin;
		var arrayPageSize = this.getPageSize();
		objOverlay.style.height = arrayPageSize[1] + 'px';
		yPos = (window.scrollY) ? window.scrollY : document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
		document.getElementById("inpopUp").innerHTML = main_contex; 
		var bw=new lib_bwcheck();
		if (bw.ie || bw.opera5)
		popUp.style.top = Math.floor(yPos+arrayPageSize[3]/2 -100)+'px';	
		
		if(bw.winsafari) 
				popUp.style.top = Math.floor(yPos+arrayPageSize[3]/2 -250)+'px';;	
		
		new Effect.Appear('overlay', { duration: 1, from: 0.0, to: 0.7 }); 
			var direction = 0;
			
			/*
			var client_w = (document.documentElement.clientWidth || document.body.clientWidth)
			
			document.getElementById("popUp_w").style.top = document.body.clientHeight/2 - ( document.getElementById("popUp_w").offsetHeight )/2 + document.body.scrollTop;
			document.getElementById("popUp_w").style.left =(client_w -  document.getElementById("popUp_w").offsetWidth)/2 + direction/2 + 'px';	
			*/
		//document.getElementById("popUp_w").style.top = '300px';
		//document.getElementById("popUp_w").style.left = '300px';
		popUp.style.display = 'block'; 
		
		}

};
