var isMSIE=(navigator.userAgent.indexOf("MSIE")!=-1),isMACIE=(isMSIE&&navigator.userAgent.indexOf("Mac")!=-1),isSAFARI=(navigator.userAgent.indexOf("Safari")!=-1),objSelectToList,objLastTd=null,objSelectToListSpanPlus=null,strTImgPath="images/t_images/",strButtonHoverBgColour="#FF0008",strButtonHoverColour="#ffffff",strPlusHover="#2385AC",strTdHover="#2486AB";function addEvent(obj,strEventType,strFunction){var i,arrParams=new Array(),intInc=0;for(i=3;i<addEvent.arguments.length;++i){arrParams[intInc]=addEvent.arguments[i];strFunction=strFunction.replace(/\)/g,",arrParams["+intInc+"])");++intInc}if(document.attachEvent){strFunction=strFunction.replace(/\'evt\'/,"window.event");obj.attachEvent("on"+strEventType,function(){eval(strFunction)},true)}else{if(document.addEventListener){strFunction=strFunction.replace(/\'evt\'/,"evt");obj.addEventListener(strEventType,function(evt){eval(strFunction)},true)}else{if(isMACIE){strFunction=strFunction.replace(/\'evt\'/,"window.event")}else{strFunction=strFunction.replace(/\'evt\'/,"evt")}eval("obj.on"+strEventType+" = "+function(evt){eval(strFunction)})}}}function hover(A,C,B){B.style.color=(C)?strPlusHover:""}function selectThis(evt,strValue,objSelect,objTd){evt=(evt)?evt:window.event;if(objSelect){objSelect.value=strValue;var strOnChange=objSelect.getAttribute("onchange");if(strOnChange){if(isMSIE){strOnChange=""+strOnChange;strOnChange=strOnChange.substring(strOnChange.indexOf("{")+1,strOnChange.indexOf("}"));strOnChange=strOnChange.replace(/^[\s]*/,"")}strOnChange=strOnChange.replace(/this/,"objSelect");eval(strOnChange)}return false}}function updateSpan(B,A,E,D){B=(B)?B:window.event;objSelectToListSpanPlus=null;var C,F=D.getElementsByTagName("span");for(C=0;C<F.length;++C){if(F[C].className=="plus"){objSelectToListSpanPlus=F[C];break}}if(objSelectToListSpanPlus){if(isMSIE){A=(A!="")?A:"&nbsp;"}objSelectToListSpanPlus.innerHTML=A}}function goTo(A){location.href=A}function SelectToList(P,I,F){var H,K,Q,N,B,G,M,E,A,C,J,O,L,D;P=(P)?P:window.event;if(F){if(SelectToList.arguments.length>3){objTd=SelectToList.arguments[3];if(objLastTd){K=objLastTd.getElementsByTagName("div");for(H=0;H<K.length;++H){if(K[H].className=="selectToListLinks"){if(objSelectToList.getElementsByTagName("ul").length){objSelectToList.innerHTML=""}objLastTd.removeChild(K[H]);if(!isMSIE&&!isSAFARI){document.body=document.body}}}}Q=document.createElement("ul");N=objTd.getElementsByTagName("select")[0],B=N.options;G=(B[0].value=="")?1:0;for(H=G;H<B.length;H++){M=B[H].value;E=B[H].innerHTML;objLi=document.createElement("li");strText=""+B[H].text;objLi.innerHTML=strText;objLi.innerHTML=(strText=="")?"[unselect]":strText;addEvent(objLi,"click","selectThis('evt','"+M+"');updateSpan('evt','"+E+"')",N,objTd);addEvent(objLi,"mouseover","hover('evt',1)",objLi);addEvent(objLi,"mouseout","hover('evt',0)",objLi);Q.appendChild(objLi)}objSelectToList.appendChild(Q);A=document.createElement("div");A.setAttribute("class","endfloat");if(isMSIE){A.className="endfloat"}objSelectToList.appendChild(A);C=B.length;J=13;O=(C*J);L=parseInt(P.clientY);L=(isSAFARI)?L-document.body.scrollTop:L;D=30;isDisplayAbove=((O+L+D)>=intScreenH)?1:0;objTd.appendChild(objSelectToList)}objSelectToList.style.visibility="visible";objLastTd=objTd}else{if(!F){objSelectToList.style.visibility="hidden"}}}function onloadFunctions(){if(!isMACIE){objSelectToList=document.createElement("div");objSelectToList.setAttribute("class","selectToListLinks");if(isMSIE){objSelectToList.className="selectToListLinks"}addEvent(objSelectToList,"mouseover","SelectToList('evt',objSelectToList,1)");addEvent(objSelectToList,"mouseout","SelectToList('evt',objSelectToList,0)");addEvent(objSelectToList,"click","SelectToList('evt',objSelectToList,0)");var B,A=document.getElementsByTagName("div");for(B=0;B<A.length;++B){if(A[B].className=="selectToList"){addEvent(A[B],"click","SelectToList('evt',objSelectToList,1)",A[B].parentNode);addEvent(A[B],"mouseover","hover('evt',1)",A[B]);addEvent(A[B],"mouseout","hover('evt',0)",A[B])}}}}onload=onloadFunctions;function notice(B){var A;A=window.open(B,"vendorPopup","scrollbars=no,resizable=no,width=480,height=370,left=200,top=20");A.focus()}function legal(B){var A;A=window.open(B,"legalPopup","scrollbars=yes,resizable=no,width=500,height=600,left=200,top=20");A.focus()}jQuery.cookie=function(A,J,I){if(typeof J!="undefined"){I=I||{};if(J===null){J="";I.expires=-1}var E="";if(I.expires&&(typeof I.expires=="number"||I.expires.toUTCString)){var B;if(typeof I.expires=="number"){B=new Date();B.setTime(B.getTime()+(I.expires*24*60*60*1000))}else{B=I.expires}E="; expires="+B.toUTCString()}var L=I.path?"; path="+(I.path):"";var C=I.domain?"; domain="+(I.domain):"";var H=I.secure?"; secure":"";document.cookie=[A,"=",encodeURIComponent(J),E,L,C,H].join("")}else{var G=null;if(document.cookie&&document.cookie!=""){var K=document.cookie.split(";");for(var D=0;D<K.length;D++){var F=jQuery.trim(K[D]);if(F.substring(0,A.length+1)==(A+"=")){G=decodeURIComponent(F.substring(A.length+1));break}}}return G}};var AJAX_FAST_REFRESH=(jQuery.browser.msie?3000:2000),AJAX_SLOW_REFRESH=(jQuery.browser.msie?3000:2000),AJAX_SLOWER_REFRESH=(jQuery.browser.msie?600000:600000),AJAX_DEBUG_REFRESH=(jQuery.browser.msie?12000:12000),AJAX_TIME_REFRESH=10000,AJAX_LANGSAM_REFRESH=10000,AJAX_LONG_TIMEOUT=18000,LIVE_SITE_URL="";var MAX_VIEWERS=3,SYMBOL_LIMIT=4;function add_blank_rows(A,E,B,D){while(E<10){if(B++%2==0){A+="<tr>"}else{A+='<tr class="stripe selected">'}for(var C=1;C<D;C++){A+='<td class="'+C+'">&nbsp;</td>'}A+="</tr>";E++}return A}function add_blank_rows_array(D,E,F){var B=E%2;for(var A=0;A<E;A++){if(B++%2==0){D[D.length]="<tr>"}else{D[D.length]='<tr class="stripe selected">'}for(var C=0;C<F;C++){D[D.length]='<td class="';D[D.length]=C;D[D.length]='">&nbsp;</td>'}D[D.length]="</tr>"}}function get_orderbook_symbols(A,C,D){var B=4;$.ajax({type:"POST",url:"/cgi-bin/json_request",data:'{ "execute" : [                          { "get_orderbook_symbols" : ["'+C+'",'+B+"] } ] }",dataType:"json",contentType:"text/plain",success:function(E){_populate_orderbook_symbols(A,E.response[0].get_orderbook_symbols,D)}})}function _populate_orderbook_symbols(A,F,D){if(F==null){return }if(F.length<=0){$("div#orderbook_list_"+A).hide();return }var C,B,E;C=new Array();B="<table>";B+="<tr><th>Symbol</th><th>Name</th></tr>";for(i=0;i<F.length;i++){E="javascript:"+D+"('"+A+"','"+jQuery.map(F[i],function(H,G){return new String(H).replace(/\'/g,"\\'")}).join("','")+"')";B+='<tr><td><a href="#" onclick="'+E+'">'+F[i][1]+'</a></td><td><a href="#" onclick="'+E+'">'+F[i][3]+"</a></td></tr>"}B+="</table>";$("div#orderbook_list_"+A).html(B);$("div#orderbook_list_"+A+" td").mouseover(function(){$(this).css("color","#FF0000")});$("div#orderbook_list_"+A+" td").mouseout(function(){$(this).css("color","#000000")});$("div#orderbook_list_"+A+" td").click(function(){$("input#orderbook_list_"+A).val($(this).html())});$("div#orderbook_list_"+A).show();$("#everything").css("z-index",1);$("div#orderbook_list_"+A).css("z-index",44)}var i_refresh_orderbook_status_timeout_id=-1;function _refresh_orderbook_status(A){if(i_refresh_orderbook_status_timeout_id=-1){clearTimeout(i_refresh_orderbook_status_timeout_id)}get_orderbook_status(A);i_refresh_orderbook_status_timeout_id=setTimeout("_refresh_orderbook_status("+A+")",AJAX_TIME_REFRESH)}function get_orderbook_status(A){$.ajax({type:"POST",url:"/cgi-bin/json_request",data:'{ "execute" : [                          { "get_orderbook_status" : ['+A+"] } ] }",dataType:"json",contentType:"text/plain",success:function(B){_populate_orderbook_status(B.response[0].get_orderbook_status)}})}function _populate_orderbook_status(A){if(A!=null){$("#market_open_close_status").html(A=="open"?'<span class="colorI">Open</span>':'<span class="colorPi">Close</span>')}}function orderbook_search_selector(C,D){var E,B,A;$(C).click(function(){$(this).val("");$("div#orderbook_list_"+C).html("")});$("input#orderbook_search_"+C).keydown(function(F){if(F.keyCode==13){return false}}).keyup(function(F){E=$(this).val().toUpperCase();$(this).val(E);if(!E){$("div#orderbook_list_"+C).hide();$("div#orderbook_list_"+C).empty();return }B=$("input#current_word").val();A=E.length;if(B!=$(this).val()||$("div#orderbook_list_"+C).html()==""){$("input#current_word").val(B);get_orderbook_symbols(C,$(this).val(),D)}})}function symbol_trade_report(A,F,B,E,C,G,D){$("div#orderbook_list_"+A).hide();$("input#orderbook_search_"+A).val(B);adorn_desktop_book_viewer(A,F,B,E,C,G,D);get_trade_report_by_orderbook_id_with_refresh(F);get_top_of_orderbook_with_refresh(F);_refresh_orderbook_status(F)}function adorn_desktop_book_viewer(A,F,B,E,C,G,D){$("#hidden_orderbook_id").val(F);$("#market_open_close_status").html(G==1?'<span class="colorI">Open</span>':'<span class="colorPi">Close</span>');$("#bookviewer_group_headings").html('<div class="left"><h3 id="current_symbol" class="colorI">'+B+"        "+E+'</h3></div><div class="right">'+D+"</div>")}function popup_bookviewer(A,F,B,E,C,G,D){$("div#orderbook_list_"+A).hide();window.open("/tq_desktop_book_viewer.shtml?o="+F,"vendorPopup","scrollbars=no,resizable=no,width=420,height=560,left=100,top=100")}function go_to_instrument(A,F,B,E,C,G,D){$("div#orderbook_list_"+A).hide();self.parent.location.href=LIVE_SITE_URL+"/tq_instrument_data.shtml?o="+F}function createCookie(B,D,E){var A,C;if(E){A=new Date();A.setTime(A.getTime()+(E*24*60*60*1000));$.cookie(B,D,{path:"/",expires:A})}else{$.cookie(B,D,{path:"/"})}}function eraseCookie(A){$.cookie(A,null,{path:"/"})}function readCookie(A){return $.cookie(A)}function setToolTips(B,A){if(A!=undefined){tooltip.setmaxwidth(A)}$(B).each(function(){$(this).mouseover(function(){if($(this).attr("tip")!=""){tooltip.show($(this).attr("tip"))}});$(this).mouseout(function(){if($(this).attr("tip")!=""){tooltip.hide()}})})}function clearToolTips(A){tooltip.park();document.onmousemove=null}var tooltip=function(){var I,N,J,L,H,C,M,E,K,D,B,G,F,A;C="tt";M=1;E=1;K=400;D=5;B=10;G=75;F=0;i_max_width=0;A=document.all?true:false;return{setmaxwidth:function(O){i_max_width=O},show:function(P,O){if(I==null){I=document.createElement("div");I.setAttribute("id",C);N=document.createElement("div");N.setAttribute("id",C+"top");J=document.createElement("div");J.setAttribute("id",C+"cont");L=document.createElement("div");L.setAttribute("id",C+"bot");I.appendChild(N);I.appendChild(J);I.appendChild(L);document.body.appendChild(I);I.style.opacity=0;I.style.filter="alpha(opacity=0)";document.onmousemove=this.pos}I.style.display="block";J.innerHTML=P;I.style.width=O?O+"px":"auto";if(!O&&A){N.style.display="none";L.style.display="none";I.style.width=I.offsetWidth;N.style.display="block";L.style.display="block"}if(I.offsetWidth>K){I.style.width=K+"px"}H=parseInt(I.offsetHeight)+M;clearInterval(I.timer);I.timer=setInterval(function(){tooltip.fade(1)},B)},pos:function(Q){var P,O,R;P=A?event.clientY+document.documentElement.scrollTop:Q.pageY;O=A?event.clientX+document.documentElement.scrollLeft:Q.pageX;if(i_max_width>0&&O+E-10>i_max_width/2){O-=$(I).width()}I.style.top=(P-H)+"px";I.style.left=(O+E)+"px"},fade:function(Q){var P,O;O=F;if((O!=G&&Q==1)||(O!=0&&Q==-1)){P=D;if(G-O<D&&Q==1){P=G-O}else{if(F<D&&Q==-1){P=O}}F=O+(P*Q);I.style.opacity=F*0.01;I.style.filter="alpha(opacity="+F+")"}else{clearInterval(I.timer);if(Q==-1){I.style.display="none"}}},hide:function(){clearInterval(I.timer);I.timer=setInterval(function(){tooltip.fade(-1)},B)},park:function(){if(I!=null){if(I.timer!=null){clearInterval(I.timer)}I.style.display="none"}}}}();$(document).ready(function(){createViewerList()});var a_dv_html_array=new Array();var s_dv_buf="";function createViewerList(){var E,D,C,B,A;E=get_session_from_cookie();a_dv_html_array.length=0;A=0;a_dv_html_array[a_dv_html_array.length]='<table border="0" id="desktop_viewers">';for(D=1;D<=MAX_VIEWERS;D++){if(E[D]&&E[D]["name"]){A=1;a_dv_html_array[a_dv_html_array.length]='<tr class="desktop_viewer_link" id="desktop_viewer_link_';a_dv_html_array[a_dv_html_array.length]=D;a_dv_html_array[a_dv_html_array.length]='"><td>';a_dv_html_array[a_dv_html_array.length]='<a class="viewer_a" tip="';a_dv_html_array[a_dv_html_array.length]=E[D]["symbols"].join("<br/>");a_dv_html_array[a_dv_html_array.length]='" href="#" value="';a_dv_html_array[a_dv_html_array.length]=E[D]["name"];a_dv_html_array[a_dv_html_array.length]='" ';a_dv_html_array[a_dv_html_array.length]=' id="desktop_viewer_link_a_';a_dv_html_array[a_dv_html_array.length]=D;a_dv_html_array[a_dv_html_array.length]='" ';a_dv_html_array[a_dv_html_array.length]=" onclick=\"viewer('";a_dv_html_array[a_dv_html_array.length]=VIEWER_URL;a_dv_html_array[a_dv_html_array.length]="?viewer=";a_dv_html_array[a_dv_html_array.length]=D;a_dv_html_array[a_dv_html_array.length]="', ";a_dv_html_array[a_dv_html_array.length]=D;a_dv_html_array[a_dv_html_array.length]=');return false">';a_dv_html_array[a_dv_html_array.length]=E[D]["name"];a_dv_html_array[a_dv_html_array.length]="</a></td><td>";a_dv_html_array[a_dv_html_array.length]='<a tip="delete" href="javascript:delete_book_viewer(\'';a_dv_html_array[a_dv_html_array.length]=D;a_dv_html_array[a_dv_html_array.length]='\')" class="delete_desktop_viewer_link" value="';a_dv_html_array[a_dv_html_array.length]=D;a_dv_html_array[a_dv_html_array.length]='">&lt;</a>';a_dv_html_array[a_dv_html_array.length]="</td></tr>"}}a_dv_html_array[a_dv_html_array.length]="</table>";s_dv_buf=a_dv_html_array.join("");$("div#desktop_viewers_div").html(s_dv_buf);if(A){$("p#saved_book_p").show();setToolTips("a.viewer_a",$("div#desktop_viewers_div").width());setToolTips("a.delete_desktop_viewer_link",$("div#desktop_viewers_div").width())}else{$("p#saved_book_p").hide();clearToolTips("a.viewer_a");clearToolTips("a.delete_desktop_viewer_link")}}function delete_book_viewer(B){var A=get_session_from_cookie();delete (A[B]);set_session_to_cookie(A);createViewerList()}function get_session_from_cookie(){var A=readCookie("tq_popup_orderbooks");var B={};if(A){B=unserialize_cookie(A)}else{set_session_to_cookie(B)}return B}function _test_session(){return{"1":{symbols:["VOD_L.TQ"],orderbook_ids:[1859],name:"aaa"},"2":{symbols:["GSK_L.TQ","A2_MI.TQ"],orderbook_ids:[1802,1024],name:"bbb"}}}function set_session_to_cookie(A){createCookie("tq_popup_orderbooks",serialize_cookie(A),3652)}function unserialize_cookie(s_string){return eval("("+s_string+")")}function serialize_cookie(B){var A=new Array();A[0]="{";for(i=1;i<=MAX_VIEWERS;i++){if(B[i]){A[A.length]='"';A[A.length]=i;A[A.length]='":{';A[A.length]='"symbols":[';if(B[i]["symbols"]&&B[i]["symbols"].length>0){A[A.length]='"';A[A.length]=B[i]["symbols"].join('","');A[A.length]='"'}A[A.length]="],";A[A.length]='"orderbook_ids":[';if(B[i]["orderbook_ids"]&&B[i]["orderbook_ids"].length>0){A[A.length]='"';A[A.length]=B[i]["orderbook_ids"].join('","');A[A.length]='"'}A[A.length]="],";A[A.length]='"name":"';if(B[i]["name"]){A[A.length]=B[i]["name"]}A[A.length]='"},'}}A[A.length]='"tq":"tq"}';return A.join("")}var VIEWER_URL="tq_desktop_book_viewer.shtml";var popup_windows=new Array();function viewer(A,C){var B="popup_orderbook_"+C;if(jQuery.browser.safari){popup_windows[C]=window.open(A,B,"scrollbars=no,resizable=no,toolbar=no,status=no,menubar=no,location=no,width=422,height=500,left=100,top=100")}else{if(jQuery.browser.msie){popup_windows[C]=window.open(A,B,"scrollbars=no,resizable=no,toolbar=no,status=no,menubar=no,location=no,directories=no,width=408,height=490,left=100,top=100")}else{popup_windows[C]=window.open(A,B,"scrollbars=no,resizable=no,toolbar=no,status=no,menubar=no,location=no,width=412,height=490,left=100,top=100")}}if(popup_windows[C]){popup_windows[C].focus();return true}else{alert("could not open window - please allow popups in your popup blocker")}return false}function newViewer(){var A=0;var B=get_session_from_cookie();for(i=1;i<=MAX_VIEWERS;i++){if(!B[i]||(!B[i]["name"]&&(!popup_windows[i]||popup_windows[i].closed))){A=i}}if(A==0){alert("You can only have three book viewers per browser. Please open one of the saved book viewers.");return false}if(viewer(VIEWER_URL+"?viewer="+A,A)){B[A]={};set_session_to_cookie(B)}return false};