var dom={isReady:false};
var EventDispatcher={elements:[],eventCounter:1,stopPropagation:function(_1){
if(window.event){
window.event.cancelBubble=true;
}else{
if(_1.stopPropagation){
_1.stopPropagation();
}
}
},addEvent:function(_2,_3,_4){
EventDispatcher.callCounter++;
if(!_4.__eid){
_4.__eid=this.eventCounter++;
}
if(!_2.__events){
_2.__events={};
this.elements[this.elements.length]=_2;
}
var _5=_2.__events[_3];
if(!_5){
_5=_2.__events[_3]={};
if(_2["on"+_3]){
_5[0]=_2["on"+_3];
}
}
_2["on"+_3]=EventDispatcher.handleEvent;
_5[_4.__eid]=_4;
_2.notifyEventListenerAdded&&_2.notifyEventListenerAdded(_3);
return _4.__eid;
},removeEvent:function(_6,_7,_8){
var _9=(typeof _8=="function")?_8.__eid:_8;
if(_6.__events&&_6.__events[_7]&&_9){
delete _6.__events[_7][_9];
this.clearEventHandlerSafely(_6,_7);
return true;
}else{
return false;
}
},clearEventHandlerSafely:function(_10,_11){
var _12=false;
var _13=_10.__events[_11];
for(var ii in _13){
if(_13[ii]){
return false;
}
}
_10["on"+_11]=null;
return true;
},handleEvent:function(_15){
_15=_15||window.event;
var _16=true;
var _17=this.__events[_15.type];
for(var ii in _17){
_16=_17[ii].apply(this,[_15])!==false&&_16;
}
if(this==window&&_15.types=="unload"){
EventDispatcher.cleanupAll();
}
return _16;
},cleanupAll:function(){
for(var ii=0;ii<this.elements.length;ii++){
this.cleanupElement(this.elements[ii]);
delete this.elements[ii];
}
},cleanupElement:function(_18){
if(_18.__events){
for(type in _18.__events){
for(eid in _18.__events[type]){
delete _18.__events[type][eid];
}
_18["on"+type]=null;
}
}
},getMouseButton:function(_19){
if(_19.which==null){
return (_19.button<2)?"LEFT":((_19.button==4)?"MIDDLE":"RIGHT");
}else{
return (_19.which<2)?"LEFT":((_19.which==2)?"MIDDLE":"RIGHT");
}
}};
EventDispatcher.addEvent(window,"unload",function(){
});
function domReady(){
if(arguments.callee.done){
return;
}
arguments.callee.done=dom.isReady=true;
dom.onready&&dom.onready({type:"ready"});
dom.onafterready&&dom.onafterready({type:"afterready"});
}
if(document.addEventListener){
document.addEventListener("DOMContentLoaded",domReady,null);
}
function forceDomReady(){
if(!document.addEventListener&&!UserAgent.matches.iewin){
domReady();
}
return true;
}
EventDispatcher.addEvent(window,"load",domReady);

var $=function(id){
return document.getElementById(id);
};

var $$=function(_1){
return new ElementWrapper(_1);
};
var ElementWrapper=function(_2){
if(_2.nodeType==1){
this.id=_2.id||(_2.id=ElementWrappers.getNewId());
}else{
this.id=_2;
}
};
ElementWrapper.prototype={getElement:function(){
return $(this.id);
},getId:function(){
return this.id;
},getHeight:function(){
return this.getComputedDimension("height","offsetHeight");
},getWidth:function(){
return this.getComputedDimension("width","offsetWidth");
},getTop:function(){
return this.getOffset("offsetTop");
},getLeft:function(){
return this.getOffset("offsetLeft");
},getBottom:function(){
return this.getTop()+this.getHeight();
},getRight:function(){
return this.getLeft()+this.getWidth();
},getOffset:function(_3){
var el=this.getElement();
var x=0;
while(el.offsetParent&&el.offsetParent!=document.documentElement){
x+=el[_3];
el=el.offsetParent;
}
return x;
},getComputedStyle:function(_6){
var el=this.getElement();
if(document.defaultView&&document.defaultView.getComputedStyle){
return document.defaultView.getComputedStyle(el,null).getPropertyValue(_6);
}else{
if(el.currentStyle){
return el.currentStyle[_6];
}else{
return null;
}
}
},setStyle:function(_7,_8){
this.getElement().style[_7]=_8;
},setStyles:function(_9){
for(var _10 in _9){
if(_9[_10]!==null){
this.setStyle(_10,_9[_10]);
}
}
},setOpacity:function(_11){
var s=UserAgent.supports;
if(s.elementAlphaIEWin){
this.setStyle("filter",_11==100?"none":"alpha(opacity="+_11+")");
}else{
if(s.elementAlpha){
this.setStyle("opacity",_11/100);
}
}
},containsClass:function(_13){
return this.getElement().className.containsClass(_13);
},addClass:function(_14){
var el=this.getElement();
return el.className=el.className.addClass(_14);
},removeClass:function(_15){
var el=this.getElement();
return el.className=el.className.removeClass(_15);
},swapClass:function(_16,_17){
return this.getElement().className=this.className.swapClass(_16,_17);
},getText:function(){
var el=this.getElement();
var fc=el.firstChild;
return el.textContent||el.innerText||(fc&&fc.nodeType==3?fc.nodeValue:null);
},clearChildren:function(){
var el=this.getElement();
while(el.firstChild){
$$(el.firstChild).remove();
}
return el;
},remove:function(){
var el=this.getElement();
if(UserAgent.matches.iewin){
var _19=el.getElementsByTagName("*");
for(var i=0;i<_19.length;i++){
EventDispatcher.cleanupElement(_19[i]);
}
EventDispatcher.cleanupElement(el);
}
el.parentNode.removeChild(el);
return el;
},getAncestorWithClass:function(_21){
var el=this.getElement();
while(el&&el.parentNode&&el.parentNode.nodeType==1){
el=el.parentNode;
if(el&&$$(el).containsClass(_21)){
return el;
}
}
return null;
},isMouseOver:function(_22,_23){
if(!_23){
var _23=0;
}
var x=Position.mouseX(_22);
var y=Position.mouseY(_22);
return (x<this.getRight()+_23&&x>this.getLeft()-_23&&y<this.getBottom()+_23&&y>this.getTop()-_23);
},getComputedDimension:function(_25,_26){
return this.getElement()[_26];
}};
var ElementWrappers={idPrefix:"autoId",idCounter:0,getNewId:function(){
return this.idPrefix+this.getUniqueIdSuffix();
},getUniqueIdSuffix:function(){
return this.idCounter++;
}};

var FloatEffects = {
	// Minimum height to apply to the main-content to make it look pretty with the
	// floating sidebar. The floating sidebar is designed to work like vertical tabs
	// - the color of the selected tab matches the color of the main-content. In order
	// for the UI to look right, the main-content needs to be taller than the floating
	// sidebar.
	MIN_HEIGHT : 410,
	setPosition : function() {
		mainBody = $("main-body");
		var floatingTop = 0;
		var mbOffsetTop = $$("main-body").getTop();
		var scrollTop = document.body.scrollTop;
		var menuHeight = $("floatingSidebar").offsetHeight;
		
		if (scrollTop < mbOffsetTop){
			floatingTop = mbOffsetTop;
		} else {
			floatingTop = scrollTop;
		}

		// Sidebar should not appear to go past the main-body. Don't let it
		// creep into the footer area.
		var mainBodyBottom = $$("main-body").getBottom();
		if (floatingTop + menuHeight >= mainBodyBottom){
			floatingTop = mainBodyBottom - menuHeight;
		}
		floatingTopStr = floatingTop + "px";
		$("floatingSidebar").style.top=floatingTopStr;
		$("floatingSidebar").style.display="block";
	},
	switchBackground : function(obj, state) {
        var ele = $(obj);
		var cl = ele.className;
		if (state == "on"){
			if (cl == "fdivider"){
				ele.className= "fdivider_O";
			} else if (cl == "fdivider_bottom"){
				ele.className = "fdivider_bottom_O";
			}
		} else {
			if (cl == "fdivider_O"){
				ele.className= "fdivider";
			} else if (cl == "fdivider_bottom_O"){
				ele.className = "fdivider_bottom";
			}
		}
	},
	// Makes sure the height of the main-body element is >= the minimum height.
	// Makes the content taller than the floating sidebar. See comments above for
	// details.
	//
	// TODO: Set the min height via CSS. Doing so would require adding a new div
	// to all community pages, and requires changes to the LayoutManager - saving
	// this improvement for later when there's time to thoroughly QA all the changes
	// (e.g. wide page project?).
	applyMinHeight: function() {
		var height = $$("main-body").getHeight();
		if (height < FloatEffects.MIN_HEIGHT) {
			$("main-body").style.height = FloatEffects.MIN_HEIGHT + "px";
		}
	}
}
//EventDispatcher.addEvent(dom, "ready", FloatEffects.applyMinHeight); // commenting out for now. This is not working in IE
EventDispatcher.addEvent(window,"ready",FloatEffects.setPosition);
EventDispatcher.addEvent(window,"resize",FloatEffects.setPosition);
EventDispatcher.addEvent(window,"scroll",FloatEffects.setPosition);

function reSizeMe(){
	$("menuContainer").style.width=$("floatingSidebar").offsetWidth;
	$("menuContainer").style.height=$("floatingSidebar").offsetHeight;
	$("floatingSidebar").style.top=$$("main-body").getTop();
	FloatEffects.setPosition();
};

setInterval("FloatEffects.setPosition();",500);