/* sidebar_placer.js v1.0 (March 6, 2005)

Copyright (c)2004 by Isaac Csandl
Distributed under the LGPL, see www.gnu.org for details

*/
var nav = navigator.userAgent.toLowerCase();
var ie3 = nav.indexOf('msie 3') !=-1;
var ie4 = nav.indexOf('msie 4') !=-1;
if ( document.getElementById || document.all ) {
  // bail out now with IE 3&4 to avoid error dialog
  if ( ! ie3 && ! ie4  ) {
  		  document.write("<"+"script type='text/javascript' src='../../x/x_core.js'><"+"/script>");
          document.write("<"+"script type='text/javascript' src='../../x/x_dom.js'><"+"/script>");

          if ( window.addEventListener ) {
                  window.addEventListener('load',placeTheSidebar,false);
                  window.addEventListener('resize',placeTheSidebar,false);
          } else if ( window.attachEvent ) { 
                  window.attachEvent('onload',placeTheSidebar);
                  window.attachEvent('onresize',placeTheSidebar);
          } else {
                  window.onload=placeTheSidebar;
                  window.onresize=placeTheSidebar;
          }
  }
}

function placeTheSidebar() {
	if (  document.createElement == null ) { return true; }
	
	originalSBar = document.getElementById('sidebar');
	if ( originalSBar == null ) {
		resizemode=true;
		originalSBar = document.getElementById('sbarontop');
	}
	else
	{
		resizemode=false;
	}
	// bail out now if we have a lousy DOM implementation
	if ( originalSBar.cloneNode == null ) { return true; }

	// we use tempSideBar to get position and size
	// may need to change class back to sidebar onresize
	tempSideBar    = originalSBar.cloneNode(true);
    // do this both ways to cover everybody
    tempSideBar.style.width = "43%";
    tempSideBar.style.height = "auto";
    tempSideBar.setAttribute("style","width: 43%; height:auto;");
	tempSideBar.id = 'sidebarinplace';
	tempSideBar.className = 'sidebar';
	loc = document.getElementById('sidebarhere');
	if ( resizemode==true)
	{
		e=document.getElementById('emptyinplace');
		loc.removeChild(e);
	}
	loc.appendChild(tempSideBar);
	t = xPageY(tempSideBar);
	l = xPageX(tempSideBar);
	w = xWidth(tempSideBar);
	h = xHeight(tempSideBar); 
	
	tempSideBar.id = 'noid';
	empty = document.createElement("DIV");
	empty.id= 'emptyinplace';
	empty.className='emptyinplace';
	loc.removeChild(tempSideBar);
	loc.appendChild(empty);
	originalSBar.id='sbarontop';
	xResizeTo(originalSBar,w,h);
	xTop(originalSBar,t);
	xLeft(originalSBar,l);
	xResizeTo(empty,w,h);
}


