function Flyout(a,c,d){this.id=a;this.elem=null;this.top=0;this.left=0;this.width=0;this.height=0;this.parent=c;this.dir=d;this.mouseIsOver=false;this.setElement=function(k){var j=document.getElementById(k);if(j!=null&&this.parent!=null){this.elem=j;var m=e(j);var l=f(this.parent);var i=e(this.parent);this.width=$("#"+k).outerWidth();this.height=m.height;if(this.dir=="right"){this.top=l.top;this.left=l.left+i.width}else{if(this.dir=="down"){this.top=l.top+i.height;if((l.left+this.width)>=document.documentElement.clientWidth){this.left=(l.left+i.width-this.width)}else{this.left=l.left}}}var h=new EventAdder();h.addEvent(this.elem,"mouseover",this.mouseOver);h.addEvent(this.elem,"mouseout",this.mouseOut);h.addChildNodesListener(this.elem,this.mouseOut,"mouseout");registerGlobal(this)}};this.show=function(){if(this.parent!=null&&this.elem!=null){this.elem.style.top=this.top+"px";this.elem.style.left=this.left+"px";this.elem.style.position="absolute";this.elem.style.display="block";this.elem.style.visibility="visible";
this.mouseIsOver=true}};this.close=function(){if(this.elem!=null){this.elem.style.display="none";this.elem.style.visibility="hidden"}};this.mouseOver=function(h){if(!h){h=window.event}el=h.target?h.target:h.srcElement;flyout=getRegisteredFlyout(el.id);if(flyout!=null){if(el.id==flyout.id){flyout.mouseIsOver=true}}};this.mouseOut=function(h){if(!h){h=window.event}elRel=h.relatedTarget?h.relatedTarget:h.toElement;el=h.target?h.target:h.srcElement;var j=elRel;var i="";while(j){flyout=getRegisteredFlyout(j.id);if(flyout!=null){flyout.mouseIsOver=true;i=flyout.id;break}j=j.parentNode}if(i==""){markClearing=true}j=el;while(j){flyout=getRegisteredFlyout(j.id);if(flyout!=null){if(flyout.id==i){return}flyout.mouseIsOver=false;return}j=j.parentNode}};function e(i){if(i!=null){var h=new Object();h.width=i.offsetWidth;h.height=i.offsetHeight;return h}return null}function f(i){if(i!=null){var h=new Object();h.top=g(i);h.left=b(i);return h}return null}function b(i){var h=0;if(i.offsetParent){while(i.offsetParent){h+=i.offsetLeft;
i=i.offsetParent}}else{if(i.x){h+=i.x}}return h}function g(i){var h=0;if(i.offsetParent){while(i.offsetParent){h+=i.offsetTop;i=i.offsetParent}}else{if(i.y){h+=i.y}}return h}this.setElement(a)}function registerGlobal(a){if(a!=null){if(window.flyouts==null){window.flyouts=new Array()}window.flyouts[a.id]=a}}function getRegisteredFlyout(b){var a=null;if(b){a=window.flyouts[b]}return a}function FlyoutMenu(){this.flyoutStack=new FlyoutStack();this.open=function(a,b,c){var g=document.getElementById(a);var e=this.getParentFlyout(b);if(g!=null){var h=this.flyoutStack.getFlyout(a);if(h==null){if(e!=null){this.closeUntilMe(e.id)}else{this.closeAll()}h=new Flyout(a,b,c);this.flyoutStack.pushFlyout(h);h.show()}else{h.mouseIsOver=true}}else{if(b!=null){if(e!=null){this.closeUntilMe(e.id)}else{this.closeAll()}}}if(b!=null&&e==null){var d=new EventAdder();d.addEvent(b,"mouseout",this.parentMouseOut);d.addChildNodesListener(b,this.parentMouseOut,"mouseout")}};this.getParentFlyout=function(b){var a=null;
var d=b;var c=null;while(d!=null){c=this.flyoutStack.getFlyout(d.id);if(c!=null){a=c;break}d=d.parentNode}return a};this.closeUntilMe=function(a){var b=this.flyoutStack.popFlyout();while(b!=null){if(a!=null){if(a==b.id){this.flyoutStack.pushFlyout(b);return}}b.close();b=this.flyoutStack.popFlyout()}};this.closeAll=function(){this.closeUntilMe(null)};this.isOpened=function(b){var a=this.flyoutStack.getFlyout(b);return(a!=null)};this.mouseIsOverFlyout=function(a){if(a!=null){return(a.mouseIsOver==true)}return false};this.garbageCollection=function(a){var b=this.flyoutStack.getLastFlyoutWithCriterion(this.mouseIsOverFlyout);if(b!=null&&!a){this.closeUntilMe(b.id)}else{this.closeAll()}};this.parentMouseOut=function(b){if(!b){b=window.event}elRel=b.relatedTarget?b.relatedTarget:b.toElement;el=b.target?b.target:b.srcElement;var a=elRel;while(a){flyout=getRegisteredFlyout(a.id);if(flyout!=null){return}a=a.parentNode}markClearing=true}}function FlyoutStack(){this.flyouts=new Array();this.pushFlyout=function(a){this.flyouts.push(a)
};this.popFlyout=function(){var a=null;if(this.flyouts!=null){a=this.flyouts.pop()}return a};this.getFlyout=function(b){if(this.flyouts!=null){for(var a=0;a<this.flyouts.length;a++){if(this.flyouts[a].id==b){return this.flyouts[a]}}}return null};this.getLastFlyoutWithCriterion=function(b){if(b!=null){for(var a=(this.flyouts.length-1);a>=0;a--){if(b(this.flyouts[a])){return this.flyouts[a]}}}return null}}function EventAdder(){this.addEvent=function(b,a,c){if(b.addEventListener){b.addEventListener(a,c,false)}else{if(b.attachEvent){b["e"+a+c]=c;b[a+c]=function(){b["e"+a+c](window.event)};b.attachEvent("on"+a,b[a+c])}}};this.removeEvent=function(b,a,c){if(b.removeEventListener){b.removeEventListener(a,c,false)}else{if(b.detachEvent){b.detachEvent("on"+a,b[a+c]);b[a+c]=null;b["e"+a+c]=null}}};this.addChildNodesListener=function(c,d,b){if(c!=null&&c.childNodes){for(var a=0;a<c.childNodes.length;a++){this.addEvent(c.childNodes[a],b,d);this.addChildNodesListener(c.childNodes[a],d,b)}}}}function showFlyout(b,c,a){parentElement=document.getElementById(b);
if(parentElement!=null){markClearing=false;flyoutMenu.open(c,parentElement,a)}}function garbageCollection(){flyoutMenu.garbageCollection(markClearing);markClearing=false}function closeAllByClick(){var a=new EventAdder();var b=function(c){flyoutMenu.closeAll()};a.addEvent(document,"click",b)}var markClearing=false;var flyoutMenu=new FlyoutMenu();var gcCollection=window.setInterval("garbageCollection()",3000);closeAllByClick();