/* Transformed JS from: /jslib/orderbook-panel.js */
jOanda.namespace("widgets").orderbook=(function(){function a(c,b,e,d){this.container=c;this.selector=c.getElementsByTagName("select")[0];this.position=e;this.order=d;this.spritepath=b;this.anchor=c.getElementsByTagName("a")[0];this.timestamp=new Date().getTime();this._init()}a.prototype={_init:function(){this.tooltip=document.getElementById("orderbook-help-bubble");this.tooltip_msg=this.tooltip.getElementsByTagName("p")[0];this.tooltip.style.position="absolute";this.tooltip.style.display="none";this.selector.onchange=(function(b){return function(c){b.load()}})(this);this.position.onmousemove=(function(b){return function(c){b.hover(c,b.position,"positions")}})(this);this.order.onmousemove=(function(b){return function(c){b.hover(c,b.order,"orders")}})(this);this.position.onmouseout=(function(b){return function(c){b._hide_tooltip()}})(this);this.order.onmouseout=(function(b){return function(c){b._hide_tooltip()}})(this)},load:function(){instrument=this.selector.options[this.selector.selectedIndex].value.replace("/","_");sprite=new Image();sprite.src=this.spritepath+instrument+"noncumulsmall.png?"+this.timestamp;this.order.style.background="transparent url("+sprite.src+") no-repeat 0 0";this.position.style.background="transparent url("+sprite.src+") no-repeat -262px 0";if(this.anchor){var b=this.anchor.href;if(b.lastIndexOf("#")>=0){b=b.substring(0,b.lastIndexOf("#"))}this.anchor.href=b+"#"+instrument}},hover:function(i,g,f){var c,j,h,d,b;if(!i){i=window.event}c=i.offsetX||i.layerX;j=i.offsetY||i.layerY;d=g.offsetParent.offsetLeft+g.offsetLeft;b=g.offsetParent.offsetTop+g.offsetTop;if(j>154){b+=g.offsetHeight;if(c>50&&c<110){this._show_tooltip(d,b,"short",f,"below")}else{if(c>155&&c<215){d+=g.offsetWidth/2;this._show_tooltip(d,b,"long",f,"below")}}}else{if(c>50&&c<110){this._show_tooltip(d,b,"short",f,"above",true)}else{if(c>155&&c<215){d+=g.offsetWidth/2;this._show_tooltip(d,b,"long",f,"above",true)}}}},_show_tooltip:function(c,i,f,e,b,g){var d="tooltip_"+e+"_"+f+"_"+b;var h=document.getElementById(d).innerHTML;if(this.tooltip.style.display=="block"&&this.tooltip_msg.innerHTML==h){return}this.tooltip_msg.innerHTML=h;this.tooltip.style.display="block";if(g){i-=this.tooltip.offsetHeight}this.tooltip.style.top=i+"px";this.tooltip.style.left=c+"px"},_hide_tooltip:function(){this.tooltip.style.display="none"}};return a})();
