SIA.BetDetailsExpander=function(){this.attachFetchBetDetailsHandlers(document.getElementsByClassName("showBet"),"betID");this.attachFetchBetDetailsHandlers(document.getElementsByClassName("showSystemBet"),"systemBetID")};SIA.BetDetailsExpander.prototype.attachFetchBetDetailsHandlers=function(A,D){var C;for(var B=0;B<A.length;B++){A[B].onclick=this.fetchBetDetails.bindAsEventListener(this,D);C=A[B].up("td");A[B].style.marginTop=(C.getHeight()-32)+"px"}};SIA.BetDetailsExpander.prototype.fetchBetDetails=function(C,F){var B=Event.findElement(C,"a");var D="cfcName=BetcardFacade&functionName=showBet&"+F+"="+B.id.substr(7);var E=document.createElement("span");E.className="betDetailsLoadingIcon";E.style.marginTop=B.style.marginTop;B.hide();B.parentNode.appendChild(E);var A=new Ajax.Request(SIA.facadeURL,{method:"get",parameters:D,onComplete:this.fetchBetDetailsResponse.bindAsEventListener(this,B)})};SIA.BetDetailsExpander.prototype.fetchBetDetailsResponse=function(E,I){I.parentNode.removeChild(I.parentNode.lastChild);I.show();var C=E.responseText.evalJSON();var M=I.up("tr");var N=0;var K=M.childElements();for(var G=0;G<K.length;G++){N+=K[G].colSpan}new Insertion.After(M,'<tr class="'+M.className+'"><td colspan="'+N+'" ><div  id="'+I.id+'Details" style="display:none;">'+C.html+"</div></td></tr>");if(C.systembetlist){var A=document.createElement("div");A=$(A);A.className="fullListWrapper";A.innerHTML=C.systembetlist;A.hide();M.down("ul").parentNode.appendChild(A);var H=M.down("ul").childElements();var B=[];var J;var G,D;for(G=0;G<H.length;G++){listItemClassNames=$w(H[G].className);for(D=0;D<listItemClassNames.length;D++){if(listItemClassNames[D].startsWith("runner")){B.push(listItemClassNames[D]);break}}}var F=A.down("ul").childElements();var L;for(G=0;G<F.length;G++){L=false;for(D=0;D<B.length;D++){if(F[G].hasClassName(B[D])){L=true;break}}if(!L){F[G].addClassName("disabled")}}}this.showBetDetails(I)};SIA.BetDetailsExpander.prototype.showBetDetailsEventHandler=function(B){var A=Event.findElement(B,"a");this.showBetDetails(A)};SIA.BetDetailsExpander.prototype.showBetDetails=function(B){var A=B.up("tr").down(".fullListWrapper");if(A){B.up("tr").down("ul").hide();A.show()}Effect.BlindDown(B.id+"Details",{duration:0.5,afterFinish:function(){B.onclick=this.hideBetDetails.bindAsEventListener(this);B.down("span").innerHTML=SIA.sharedStrings.less;B.down("img").src=B.down("img").src.gsub("more_icon","less_icon")}.bindAsEventListener(this)})};SIA.BetDetailsExpander.prototype.hideBetDetails=function(C){var B=Event.findElement(C,"a");var A=B.up("tr").down(".fullListWrapper");if(A){B.up("tr").down("ul").show();A.hide()}Effect.BlindUp(B.id+"Details",{duration:0.5,afterFinish:function(){B.onclick=this.showBetDetailsEventHandler.bindAsEventListener(this);B.down("span").innerHTML=SIA.sharedStrings.more;B.down("img").src=B.down("img").src.gsub("less_icon","more_icon")}.bindAsEventListener(this)})};SIA.StatementDatePicker=function(){this.currentDate;this.selectedDateFrom;this.selectedDateTo;this.usDateFormat=$("usDateFormat").value;if(this.usDateFormat=="true"){this.usDateFormat=true}else{this.usDateFormat=false}var D=document.getElementsByClassName("day","datePicker");for(var A=0;A<D.length;A++){D[A].onclick=this.pick.bindAsEventListener(this)}$("dateFrom").onfocus=function(){$("viewDateRangeRadio").checked=true};$("dateTo").onfocus=function(){$("viewDateRangeRadio").checked=true};$("period").onfocus=function(){$("viewNumDaysRadio").checked=true};var B=document.getElementsByClassName("dateFromPicker");for(A=0;A<B.length;A++){Event.observe(B[A],"click",this.openPicker.bind(this,"dateFrom"))}var C=document.getElementsByClassName("dateToPicker");for(A=0;A<C.length;A++){Event.observe(C[A],"click",this.openPicker.bind(this,"dateTo"))}};SIA.StatementDatePicker.prototype.openPicker=function(F){$("viewDateRangeRadio").checked=true;this.currentDate=F;var B=$(this.switchDateFormat($(this.currentDate).value,"/","x"));var C=document.getElementsByClassName("current","datePicker");for(var A=0;A<C.length;A++){C[A].removeClassName("current")}if(F=="dateFrom"){var E=$("datePicker").getElementsByTagName("td");for(var A=0;A<E.length;A++){if(E[A].id!=""){E[A].className="day";E[A].onmouseover=function(){this.addClassName("hover")};E[A].onmouseout=function(){this.removeClassName("hover")}}}}if(B){B.addClassName("current")}if(F=="dateTo"){var D=$("dateFrom").value;var E=document.getElementsByClassName("day","datePicker");for(var A=0;A<E.length;A++){if(D!=this.switchDateFormat(E[A].id,"x","/")){E[A].className="dateUnavailable";E[A].onmouseover=null;E[A].onmouseout=null}else{break}}}if(F=="dateFrom"){$("datePicker").style.left="50px"}if(F=="dateTo"){$("datePicker").style.left="280px"}$("datePicker").style.display="block"};SIA.StatementDatePicker.prototype.pick=function(B){var A=this.switchDateFormat(Event.element(B).id,"x","/");$("datePicker").style.display="none";if(this.currentDate=="dateFrom"){$("dateFrom").value=A}if(this.currentDate=="dateTo"){$("dateTo").value=A}};SIA.StatementDatePicker.prototype.switchDateFormat=function(A,D,B){var C=A.split(D);var E;if(this.usDateFormat){E=C[0]+B+C[1]+B+C[2]}else{E=C[1]+B+C[0]+B+C[2]}return E};SIA.initHook=function(){var B=new SIA.StatementDatePicker();var A=new SIA.BetDetailsExpander()};
