// This script places floating block on page
// there three places "fromcenter", "fromtop", "frombottom"
var persistclose1=0; //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var persistclose2=0; //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function closebar1(){
persistclose1=1;
document.getElementById("floatbar1").style.visibility="hidden";
res=AJAXrequest("../inc/setsessiondata.php?pers1="+persistclose1+"&pers2="+persistclose2);
}

function closebar2(){
persistclose2=1;
document.getElementById("floatbar2").style.visibility="hidden";
res=AJAXrequest("../inc/setsessiondata.php?pers1="+persistclose1+"&pers2="+persistclose2);
}

function initstaticbar(){
if (!persistclose1)
	{
	staticbar("floatbar1", "fromcenter");
	}
if (!persistclose2)
	{
	staticbar("floatbar2", "frombottom");
	}
}                  

function staticbar(barId, verticalpos){
	barheight=document.getElementById(barId).offsetHeight;
	barwidth=document.getElementById(barId).offsetWidth;
	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
	function ml(id){
		var el=document.getElementById(id);
		el.style.visibility="visible";  // проверяем не закрыл ли человек уже окно
		if(document.layers)el.style=el;
		el.setpos=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
		el.x = ns ? (pageXOffset + (innerWidth-barwidth)/2)-8 : (iecompattest().scrollLeft + (iecompattest().clientWidth-barwidth)/2);
		if (verticalpos=="fromcenter")el.y = ns ? (pageYOffset + innerHeight) : (iecompattest().scrollTop + iecompattest().clientHeight);
		else	
			{
			el.y = ns ? (pageYOffset + innerHeight) : (iecompattest().scrollTop + iecompattest().clientHeight);
			}
		return el;
	}
	window.stayTop=function(barId, stayverticalpos, staybarheight){
		var stayObj=document.getElementById(barId);
		if (stayverticalpos=="fromcenter")
			{
			var pageY = ns ? (pageYOffset + (innerHeight-staybarheight)/2) : (iecompattest().scrollTop + (iecompattest().clientHeight-staybarheight)/2);
			stayObj.y += (pageY - stayObj.y)/8;  // Delenie - 4toby sdelat plavnuju prokrutku
			}
		else
			{
			var pageY = ns ? pageYOffset + innerHeight - staybarheight-26: iecompattest().scrollTop + iecompattest().clientHeight-staybarheight;
			stayObj.y += (pageY - stayObj.y+4)/8;
			}
		stayObj.setpos(stayObj.x, stayObj.y);
		setTimeout("stayTop('"+barId+"','"+stayverticalpos+"',"+staybarheight+")", 7);
	}
	ftlObj = ml(barId);
	stayTop(barId, verticalpos, barheight);
}
