var canFloat = (ie5 || ie4);


var hideLinkText = '<a href="javascript:hideFloat()" class="swb">свернуть</a>';
var showLinkText = '<a href="javascript:showFloat()" class="swb">развернуть</a>';
var floatWidth;
var floatDocked;



function do_float(isfloat)
{
  if (isfloat) {
	post.style.position="absolute"
	post.style.top=document.body.scrollTop+document.body.offsetHeight-post.offsetHeight-50;
	post.style.border="2px black solid"
	post.style.backgroundColor="white"
	if(null != select_list)
	 select_list.style.display="none"
	if(null != select_list1)
	 select_list1.style.display="none"
	float_link.innerHTML='<a href="javascript:do_float(0)">обычное окно</a>';
	hide_link.innerHTML = hideLinkText;
	float_header.style.display="";
	spacer.style.display="";
//	on_scroll();
  } else {
	post.style.position=""
	post.style.border=""
	post.style.backgroundColor="white"
	if(null != select_list)
	 select_list.style.display=""
	if(null != select_list1)
	 select_list1.style.display=""
	float_link.innerHTML='<a class=small3 href="javascript:do_float(1)">плавающее окно</a>'
	float_header.style.display="none";
	spacer.style.display="none";
  }
}

function on_scroll()
{
 if (canFloat) {
  if(null != post && post.style.position != "") {
    setTimeout('post.style.top=document.body.scrollTop+document.body.offsetHeight-post.offsetHeight-5', 300)

    // Dock post form
    if (postform.style.display == "" && document.body.scrollHeight - (document.body.scrollTop+document.body.offsetHeight) < 100) {
      floatDocked = 1;
      setTimeout("do_float(0);",300);
    }
  }
  
  // Undock
  if(floatDocked && document.body.scrollHeight - (document.body.scrollTop+document.body.offsetHeight) > 200) {
    floatDocked = 0;
    setTimeout("do_float(1);",300);
  }
 }
}

function hideFloat() {
	postform.style.display="none";
	hide_link.innerHTML=showLinkText;
	floatWidth = post.style.width;
	post.style.width = 250;
	on_scroll();
}

function showFloat() {
	postform.style.display="";
	hide_link.innerHTML=hideLinkText;
	post.style.width = floatWidth;
	on_scroll();
}