/* Transformed JS from: /jslib/quote-panel.js */
jOanda.namespace("widgets").quotepanel=(function(){function a(b){this._boxes={};this.panel=document.getElementById("quote-panel");this.link=document.getElementById("toggle-link");this.helper=document.getElementById("help-bubble")}a.prototype={DEFAULT_COLOUR:"#777777",QUOTE_UPDATE_RATE:5000,ONE_SECOND:1000,FRAMERATE:200,green_pulse:function(e){var c=this.ONE_SECOND,b=this.FRAMERATE,d=this.DEFAULT_COLOUR;this.colour_box_elements(e,"#5bba00");this._timeout_colour(e,"#5aa911",c);this._timeout_colour(e,"#599922",c+b*6);this._timeout_colour(e,"#688933",c+b*8);this._timeout_colour(e,"#688844",c+b*10);this._timeout_colour(e,"#688855",c+b*12);this._timeout_reset(e,c+b*15)},red_pulse:function(e){var c=this.ONE_SECOND,b=this.FRAMERATE,d=this.DEFAULT_COLOUR;this.colour_box_elements(e,"#e81515");this._timeout_colour(e,"#d82525",c);this._timeout_colour(e,"#c83535",c+b*6);this._timeout_colour(e,"#b84545",c+b*8);this._timeout_colour(e,"#a85555",c+b*10);this._timeout_colour(e,"#986666",c+b*12);this._timeout_reset(e,c+b*15)},_timeout_colour:function(b,d,c){window.setTimeout((function(e){return function(){e.colour_box_elements(b,d)}})(this),c)},_timeout_reset:function(b,c){window.setTimeout((function(d){return function(){d._toggle_img(b,"");d.colour_box_elements(b,d.DEFAULT_COLOUR);b=null}})(this),c)},colour_box_elements:function(e,d){var c=this._quote_box(e),b=this.colour_element;b(c.buy_pip,d);b(c.buy_ette,d);b(c.ask_pip,d);b(c.ask_ette,d);c.imgbg.style.background=d},colour_element:function(b,c){b.style.color=c},start:function(){this.timer=window.setInterval((function(b){return function(){b.refresh()}})(this),5000);this.refresh()},stop:function(){window.clearInterval(this.timer);if(this.request){this.request.abort()}this.request=null},_quote_box:function(b){if(!this._boxes[b]){this._boxes[b]={buy_int:document.getElementById(b+"-b-int"),buy_pip:document.getElementById(b+"-b-pip"),buy_ette:document.getElementById(b+"-b-ette"),ask_int:document.getElementById(b+"-a-int"),ask_pip:document.getElementById(b+"-a-pip"),ask_ette:document.getElementById(b+"-a-ette"),spread:document.getElementById(b+"-spread"),news:document.getElementById(b+"-news"),imgbg:document.getElementById(b+"-img-div"),imgup:document.getElementById(b+"-img-up"),imgdash:document.getElementById(b+"-img-dash"),imgdown:document.getElementById(b+"-img-down")}}return this._boxes[b]},_toggle_img:function(b,d){var c=this._boxes[b];c.imgup.className="img-up hidden";c.imgdash.className="img-dash hidden";c.imgdown.className="img-down hidden";if(d=="up"){c.imgup.className="img-up"}else{if(d=="down"){c.imgdown.className="img-down"}else{c.imgdash.className="img-dash"}}},update:function(j){var i="",h=0,n=1,d=2,k=4,f=5,g=j.split(/\r\n|\r|\n/);for(var m=0;m<g.length;m++){var c=g[m].split("="),q=c[h].replace("/","").toUpperCase(),o="none",e=this._quote_box(q);if(!qp_data[q]||!c[k]===0){continue}e.spread.innerHTML=c[k];if(c[f]==1){o="inline"}e.news.style.display=o;var b=this.parser(c[n]);e.buy_pip.innerHTML=b.pip;e.buy_ette.innerHTML=b.pippette;e.buy_int.innerHTML=b["int"];var l=this.parser(c[d]);e.ask_pip.innerHTML=l.pip;e.ask_ette.innerHTML=l.pippette;e.ask_int.innerHTML=l["int"];if(qp_data[q]["ask"]<c[d]){this.green_pulse(q);this._toggle_img(q,"up")}else{if(qp_data[q]["ask"]>c[d]){this.red_pulse(q);this._toggle_img(q,"down")}else{this._toggle_img(q,"")}}qp_data[q]["ask"]=c[d];qp_data[q]["bid"]=c[n];qp_data[q]["spread"]=c[k]}},parser:function(d){var c={};var b=d.length;c.pippette=d.substring(b-1);c.pip=d.substring(b-3,b-1);c["int"]=d.substring(0,b-3);return c},XHR:function(){var b;if(window.XMLHttpRequest){b=new XMLHttpRequest()}else{b=new ActiveXObject("Microsoft.XMLHTTP")}return b},refresh:function(){var b=new Date().getTime(),c=this.request;if(c&&c.readyState!==4&&c.readyState!==0){return}c=new this.XHR();this.request=c;c.onreadystatechange=(function(d){return function(){var f=d.request;if(f.readyState==4&&f.status==200){try{d.update(rc4decrypt(f.responseText))}catch(e){d.stop();if(typeof(console)!="undefined"){console.log("Quote-Panel stopped: "+e.message)}}if(f.async){d.request=null}}}})(this);c.open("GET","/lfr/rates_fxtrade-common?tstamp="+b,true);c.send("")},ie_show:function(g){var d=this.helper,b,i;d.style.display="block";if(!this.helperX||!this.helperY){this.helperX=this.helperY=0;if(d.offsetParent){var f=d;while(f){this.helperX+=f.offsetLeft;this.helperY+=f.offsetTop;f=f.offsetParent}}}if(!g){g=window.event}if(g.pageX||g.pageY){b=g.pageX+30;i=g.pageY+10}else{if(g.clientX||g.clientY){var h=48;if(navigator.appVersion.indexOf("MSIE")!=-1){var c=parseFloat(navigator.appVersion.split("MSIE")[1]);if(c>=8){h=30}}b=g.clientX+document.body.scrollLeft+document.documentElement.scrollLeft+h;i=g.clientY+document.body.scrollTop+document.documentElement.scrollTop+7}}b=b-this.helperX;i=i-this.helperY;d.style.left=b+"px";d.style.top=i+"px"},ie_hide:function(){this.helper.style.display="none"},showMoreInfo:function(){document.location="/why/spreads/live"},showMore:function(){var c=this.panel,g=this.link;var e="";if(c.style.height=="100%"){c.style.height="130px";e="more"}else{if(c.style.height=="130px"||c.style.height===""){c.style.height="100%";e="less"}}var f=g.getElementsByTagName("span");for(var b=0,d=f.length;b<d;++b){if(f[b].id==e){f[b].style.display="inline"}else{f[b].style.display="none"}}}};return a})();
