Ext.namespace("GhamL.msg");GhamL.msg={Please_wait:"Please wait",Match_info:"Match info",First_half:"First half",Second_half:"Second half",Extra_time:"Extra time",Event_label_Goal:"Goal",Event_label_Attempt:"Attempt",Event_label_Yellow_card:"Yellow booking",Event_label_Red_card:"Red booking",Event_label_End_of_the_match:"End of the match",Event_label_Best_player:"Best player",Event_label_Worst_player:"Worst player",Event_label_Bruised:"Bruised",Event_label_Injury:"Injury",Event_label_Other:"Other",Event_label_Information:"Information",Event_label_Goal_tooltip:"Goals",Event_label_Attempt_tooltip:"Attempts",Event_label_Yellow_card_tooltip:"Yellow bookings",Event_label_Red_card_tooltip:"Red bookings",Event_label_Best_player_tooltip:"Best player of the match",Event_label_Worst_player_tooltip:"Worst player of the match",Event_label_Bruised_tooltip:"Bruised",Event_label_Injury_tooltip:"Injured",Minute_short:"M",Team:"Team",Team_id:"Team id",Enter_team_id:"Enter team id",Teams:"Teams",Team_Matches:"Team Matches",Result:"Result",Attempts:"Attempts",Yellow_card_short:"Y",Red_card_short:"R",Date:"Date",Type:"Type",Type_short:"T",Side_short:"S",Text:"Text",Removing_match:"Removing match",Games_played_short:"Pl",Points_short:"Pts",Games_won_short:"W",Games_drawn_short:"D",Games_lost_short:"L",Goals_for_short:"GF",Goals_against_short:"GA",Goals_difference_short:"GD",Matches:"Matches",Match_id:"Match id",Enter_match_id:"Enter match id",Error:"Error",Start_Stop_relive:"Start/Stop relive",Start_relive:"Start relive",Stop_relive:"Stop relive",Add_match:"Add match",Logout:"Logout",User_name:"User name",Save_in_cookie:"Save in cookie",Security_code:"Security code",Login:"Login",Invalid_login:"Invalid user name or security code (security code is not hattrick password, you can set it from hatrrick preferences)",Log_out:"Log out",Logging_out:"Logging out",Reloading_page:"Reloading page",Downloading:"Downloading",Downloading_match:"Downloading match",Downloading_matches:"Downloading matches",Download_error:"Download error",Session_expired:"Your hattrick session is expired, logout and login again",Cup_Friendly:"Cup/Friendly",Popup_blocked_title:"Your browser is blocking popup for this site",Popup_blocked_text:"If you want to see match updates you must enable popup for this site",One_column:"One column",Two_columns:"Two columns",General:"General",Main_panel_layout:"Main panel layout",Changing_layout:"Changing layout",Change_layout:"Change layout",Hide_popup_after_seconds:"Hide popup after seconds",Show_popup_on_new_event:"Show popup on new event",Show_popup_warning:"you must enable popup for this site if your browser block popups",Events_for_popup:"Events for popup",Stop_on_each_event:"Stop on each event",Relive_speed:"Relive_speed",Live:"Live",Relive:"Relive",Settings:"Settings",Language:"Language",Logout_required:"Logout required",Logout_required_text:"Your language settings have been registered, but in order to switch to your new language, you must log out and then log in again",Group_events:"Group events",Filter_events:"Filter events",Your_matches:"Your matches",Friends_matches:"Friends matches",Add_new_friends:"Add new friends",Adding_team:"Adding team",Add_league_round_tooltip:"Live or relive league round",Add_match_tooltip:"Live or relive match",Remove:"Remove",Remove_friend_warning:"Do you really want to remove team {0}",Round:"Round",Match_time:"Match time",Id:"Id",Enter_team_name:"Enter team name",Team_name:"team name",Choose_a_team:"Choose a team",No_team_found:"No team found",Too_many_result:"Too many result: try to specify a different team name",Home_short:"H",Away_short:"A",Cards:"Cards",Special_event:"Special event",Free_kick:"Free kick",Center:"Center",Left:"Left",Right:"Right",Penalty:"Penalty",Counter_attack:"Counter attack",Special_event_short:"SE",Free_kick_short:"FK",Center_short:"C",Left_short:"L",Right_short:"R",Penalty_short:"P",Counter_attack_short:"CA",Player:"Player",Role:"Role",Stars:"Stars",Position:"Position",Position_group:"Position group",Behaviour:"Behaviour",Keeper:"Keeper",Right_back:"Right back",Central_defender:"Central defender",Left_Back:"Left Back",Right_winger:"Right winger",Inner_midfield:"Inner midfield",Left_winger:"Left winger",Forward:"Forward",Offensive:"Offensive",Defensive:"Defensive",Towards_Middle:"Towards Middle",Towards_Wing:"Towards Wing",Midfield:"Midfield",Forwards:"Forwards",Substitutions:"Substitutions",Replaceds:"Replaceds",Right:"Right",Mid:"Center",Attack:"Attack",Defence:"Defence",crowd:"crowd",Possession:"Possession",Report:"Report",Enable_sounds:"Enable sounds (flash plugin required)",Sounds_help:'if you are an "artist" and you want to help us you can send new sounds to gham@hattrickitalia.org',Sounds:"Sounds",Test_sounds:"Test sounds",Home_stars:"Home stars",Away_stars:"Away stars",Ratings:"Ratings",League_teams:"League teams",Retry:"Retry",League:"League"};
Ext.namespace("GhamL");GhamL.Callbacks=function(A){this.config=A};Ext.extend(GhamL.Callbacks,Ext.util.Observable,{pos:0,execute:function(B){var C=this.config[this.pos];
this.pos++;if(C){var A=[this];if(C.args){A=A.concat(C.args)}if(B){A=A.concat(B)}if(C.callback){C.callback.apply(C.scope||this,A)}else{if(typeof C=="function"){C.apply(C.scope||this,A)
}}}}});Ext.namespace("GhamL.connection");function showError(A,B){Ext.Msg.hide();Ext.Msg.alert(GhamL.msg.Error,A.statusText.replace(/_/g," "))}GhamL.connection.manager=function(){function B(G,F,H){if(G){G.apply(H||window,F||[])
}}function C(G,F){if(G.successFunction){B(G.successFunction,F,G.successScope)}else{if(G.callbacks){G.callbacks.execute(F)}}}function E(G,H){function F(){B(G.failureFunction,H,G.failureScope)
}if(G.logoutAndReloadOnSessionExpired){Ext.Msg.alert(GhamL.msg.Download_error,G.sessionExpiredError||GhamL.msg.Session_expired,function(){GhamL.login.logout()
})}else{if(G.logoutOnSessionExpired){Ext.Ajax.request({url:"logout.php",callback:function(I){Ext.Msg.alert(GhamL.msg.Download_error,G.sessionExpiredError||GhamL.msg.Session_expired,F)
}})}else{if(G.showMessageOnSessionExpired!==false){Ext.Msg.alert(GhamL.msg.Download_error,G.sessionExpiredError||GhamL.msg.Session_expired,F)}}}}function D(G,I,H){function F(){B(G.failureFunction,I,G.failureScope)
}if(G.dontShowErrors){F()}else{Ext.Msg.alert(GhamL.msg.Download_error,H||GhamL.msg.Download_error,F)}if(G.callbacks){G.callbacks.execute(I)}}function A(G,I,K,H){if(K){if(H&&H.documentElement&&H.documentElement.nodeName=="parsererror"){D(G,I)
}else{var J=H&&Ext.DomQuery.selectValue("ErrorCode",H);if(J){if(J==="0"){E(G,I)}else{var F=Ext.DomQuery.selectValue("Error",H);D(G,I,F)}}else{C(G,I)}}}else{Ext.Msg.hide();
D(G,I)}}return{loadStore:function(G,F){F=F||{};G.load({callback:function(H,I,J){A(F,[H,I],J,G.reader.xmlData)},params:F.params||{}})},ajaxRequest:function(F){Ext.Ajax.request({url:F.url,params:F.params,callback:function(H,I,G){A(F,[G,H],I,G.responseXML)
},failure:showError})}}}();Ext.namespace("GhamL.cookie");GhamL.cookie.setCookie=function(D,A,C){var B=new Date();var E=new Date();C=C||2000;E.setTime(B.getTime()+24*C*3600000);
document.cookie=D+"="+escape(A)+"; expires="+E.toGMTString()};GhamL.cookie.getCookie=function(E,A){var B=document.cookie.split("; ");for(var C=0;C<B.length;
C++){var D=B[C].split("=");if(E==D[0]){return(unescape(D[1]))}}return A};GhamL.cookie.getCookieBoolean=function(E,A){var B=document.cookie.split("; ");
for(var C=0;C<B.length;C++){var D=B[C].split("=");if(E==D[0]){return(unescape(D[1])=="true")}}return A};GhamL.cookie.getCookies=function(C){var B=[];var A=document.cookie.split("; ");
for(var D=0;D<A.length;D++){var E=A[D].split("=");var F=E[0];if(F.indexOf(C)===0){B.push({id:F.substring(C.length,F.length),text:unescape(E[1])})}}return B
};GhamL.cookie.delCookie=function(A){GhamL.cookie.setCookie(A,"",-1)};GhamL.cookie.bindInCookie=function(B,C,A){B.on("change",function(E,F,D){GhamL.cookie.setCookie(C,F)
});B.setValue(GhamL.cookie.getCookie(C,A))};Ext.ux.EventCalendar=Ext.extend(Ext.Component,{todayText:"Today",okText:"&#160;OK&#160;",cancelText:"Cancel",todayTip:"{0} (Spacebar)",minDate:null,maxDate:null,minText:"This date is before the minimum date",maxText:"This date is after the maximum date",format:"m/d/y",disabledDays:null,disabledDaysText:"",disabledDatesRE:null,disabledDatesText:"",constrainToViewport:true,monthNames:Date.monthNames,dayNames:Date.dayNames,nextText:"Next Month (Control+Right)",prevText:"Previous Month (Control+Left)",monthYearText:"Choose a month (Control+Up/Down to move years)",startDay:0,events:null,initComponent:function(){Ext.ux.EventCalendar.superclass.initComponent.call(this);
this.value=this.value?this.value.clearTime():new Date().clearTime();this.addEvents("select");if(this.handler){this.on("select",this.handler,this.scope||this)
}this.initDisabledDays()},initDisabledDays:function(){if(!this.disabledDatesRE&&this.disabledDates){var A=this.disabledDates;var C="(?:";for(var B=0;B<A.length;
B++){C+=A[B];if(B!=A.length-1){C+="|"}}this.disabledDatesRE=new RegExp(C+")")}},setValue:function(B){var A=this.value;this.value=B.clearTime(true);if(this.el){this.update(this.value)
}},getValue:function(){return this.value},focus:function(){if(this.el){this.update(this.activeDate)}},onRender:function(D,B){var A=['<table cellspacing="0">','<tr><td class="x-date-left"><a href="#" title="',this.prevText,'">&#160;</a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="',this.nextText,'">&#160;</a></td></tr>','<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'];
var C=this.dayNames;for(var F=0;F<7;F++){var H=this.startDay+F;if(H>6){H=H-7}A.push("<th><span>",C[H].substr(0,1),"</span></th>")}A[A.length]="</tr></thead><tbody><tr>";
for(var F=0;F<42;F++){if(F%7==0&&F!=0){A[A.length]="</tr><tr>"}A[A.length]='<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>'
}A[A.length]='</tr></tbody></table></td></tr></table><div class="x-date-mp"></div>';var G=document.createElement("div");G.className="x-date-picker";G.innerHTML=A.join("");
D.dom.insertBefore(G,B);this.el=Ext.get(G);this.eventEl=Ext.get(G.firstChild);new Ext.util.ClickRepeater(this.el.child("td.x-date-left a"),{handler:this.showPrevMonth,scope:this,preventDefault:true,stopDefault:true});
new Ext.util.ClickRepeater(this.el.child("td.x-date-right a"),{handler:this.showNextMonth,scope:this,preventDefault:true,stopDefault:true});this.eventEl.on("mousewheel",this.handleMouseWheel,this);
this.monthPicker=this.el.down("div.x-date-mp");this.monthPicker.enableDisplayMode("block");var E=new Ext.KeyNav(this.eventEl,{"left":function(I){I.ctrlKey?this.showPrevMonth():this.update(this.activeDate.add("d",-1))
},"right":function(I){I.ctrlKey?this.showNextMonth():this.update(this.activeDate.add("d",1))},"up":function(I){I.ctrlKey?this.showNextYear():this.update(this.activeDate.add("d",-7))
},"down":function(I){I.ctrlKey?this.showPrevYear():this.update(this.activeDate.add("d",7))},"pageUp":function(I){this.showNextMonth()},"pageDown":function(I){this.showPrevMonth()
},"enter":function(I){I.stopPropagation();return true},scope:this});this.eventEl.on("click",this.handleDateClick,this,{delegate:"a.x-date-date"});this.eventEl.addKeyListener(Ext.EventObject.SPACE,this.selectToday,this);
this.el.unselectable();this.cells=this.el.select("table.x-date-inner tbody td");this.textNodes=this.el.query("table.x-date-inner tbody span");this.mbtn=new Ext.Button({text:"&#160;",tooltip:this.monthYearText,renderTo:this.el.child("td.x-date-middle",true)});
this.mbtn.on("click",this.showMonthPicker,this);this.mbtn.el.child(this.mbtn.menuClassTarget).addClass("x-btn-with-menu");if(Ext.isIE){this.el.repaint()
}this.update(this.value)},createMonthPicker:function(){if(!this.monthPicker.dom.firstChild){var A=['<table border="0" cellspacing="0">'];for(var B=0;B<6;
B++){A.push('<tr><td class="x-date-mp-month"><a href="#">',this.monthNames[B].substr(0,3),"</a></td>",'<td class="x-date-mp-month x-date-mp-sep"><a href="#">',this.monthNames[B+6].substr(0,3),"</a></td>",B==0?'<td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-prev"></a></td><td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-next"></a></td></tr>':'<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year"><a href="#"></a></td></tr>')
}A.push('<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',this.okText,'</button><button type="button" class="x-date-mp-cancel">',this.cancelText,"</button></td></tr>","</table>");
this.monthPicker.update(A.join(""));this.monthPicker.on("click",this.onMonthClick,this);this.monthPicker.on("dblclick",this.onMonthDblClick,this);this.mpMonths=this.monthPicker.select("td.x-date-mp-month");
this.mpYears=this.monthPicker.select("td.x-date-mp-year");this.mpMonths.each(function(C,D,E){E+=1;if((E%2)==0){C.dom.xmonth=5+Math.round(E*0.5)}else{C.dom.xmonth=Math.round((E-1)*0.5)
}})}},showMonthPicker:function(){this.createMonthPicker();var A=this.el.getSize();this.monthPicker.setSize(A);this.monthPicker.child("table").setSize(A);
this.mpSelMonth=(this.activeDate||this.value).getMonth();this.updateMPMonth(this.mpSelMonth);this.mpSelYear=(this.activeDate||this.value).getFullYear();
this.updateMPYear(this.mpSelYear);this.monthPicker.slideIn("t",{duration:0.2})},updateMPYear:function(E){this.mpyear=E;var C=this.mpYears.elements;for(var B=1;
B<=10;B++){var D=C[B-1],A;if((B%2)==0){A=E+Math.round(B*0.5);D.firstChild.innerHTML=A;D.xyear=A}else{A=E-(5-Math.round(B*0.5));D.firstChild.innerHTML=A;
D.xyear=A}this.mpYears.item(B-1)[A==this.mpSelYear?"addClass":"removeClass"]("x-date-mp-sel")}},updateMPMonth:function(A){this.mpMonths.each(function(B,C,D){B[B.dom.xmonth==A?"addClass":"removeClass"]("x-date-mp-sel")
})},selectMPMonth:function(A){},onMonthClick:function(D,B){D.stopEvent();var C=new Ext.Element(B),A;if(C.is("button.x-date-mp-cancel")){this.hideMonthPicker()
}else{if(C.is("button.x-date-mp-ok")){this.update(new Date(this.mpSelYear,this.mpSelMonth,(this.activeDate||this.value).getDate()));this.hideMonthPicker()
}else{if((A=C.up("td.x-date-mp-month",2))){this.mpMonths.removeClass("x-date-mp-sel");A.addClass("x-date-mp-sel");this.mpSelMonth=A.dom.xmonth}else{if((A=C.up("td.x-date-mp-year",2))){this.mpYears.removeClass("x-date-mp-sel");
A.addClass("x-date-mp-sel");this.mpSelYear=A.dom.xyear}else{if(C.is("a.x-date-mp-prev")){this.updateMPYear(this.mpyear-10)}else{if(C.is("a.x-date-mp-next")){this.updateMPYear(this.mpyear+10)
}}}}}}},onMonthDblClick:function(D,B){D.stopEvent();var C=new Ext.Element(B),A;if((A=C.up("td.x-date-mp-month",2))){this.update(new Date(this.mpSelYear,A.dom.xmonth,(this.activeDate||this.value).getDate()));
this.hideMonthPicker()}else{if((A=C.up("td.x-date-mp-year",2))){this.update(new Date(A.dom.xyear,this.mpSelMonth,(this.activeDate||this.value).getDate()));
this.hideMonthPicker()}}},hideMonthPicker:function(A){if(this.monthPicker){if(A===true){this.monthPicker.hide()}else{this.monthPicker.slideOut("t",{duration:0.2})
}}},showPrevMonth:function(A){this.update(this.activeDate.add("mo",-1))},showNextMonth:function(A){this.update(this.activeDate.add("mo",1))},showPrevYear:function(){this.update(this.activeDate.add("y",-1))
},showNextYear:function(){this.update(this.activeDate.add("y",1))},handleMouseWheel:function(A){var B=A.getWheelDelta();if(B>0){this.showPrevMonth();A.stopEvent()
}else{if(B<0){this.showNextMonth();A.stopEvent()}}},handleDateClick:function(B,A){B.stopEvent();if(A.dateValue&&!Ext.fly(A.parentNode).hasClass("x-date-disabled")){this.setValue(new Date(A.dateValue));
this.fireEvent("select",this,this.value);if(A.linkValue){window.open(A.linkValue)}}},selectToday:function(){this.setValue(new Date().clearTime());this.fireEvent("select",this,this.value)
},update:function(W){var A=this.activeDate;this.activeDate=W;if(A&&this.el){var I=W.getTime();if(A.getMonth()==W.getMonth()&&A.getFullYear()==W.getFullYear()){this.cells.removeClass("x-date-selected");
this.cells.each(function(a){if(a.dom.firstChild.dateValue==I){a.addClass("x-date-selected");setTimeout(function(){try{a.dom.firstChild.focus()}catch(b){}},50);
return false}});return }}var F=W.getDaysInMonth();var J=W.getFirstDateOfMonth();var C=J.getDay()-this.startDay;if(C<=this.startDay){C+=7}var S=W.add("mo",-1);
var D=S.getDaysInMonth()-C;var B=this.cells.elements;var K=this.textNodes;F+=C;var P=86400000;var U=(new Date(S.getFullYear(),S.getMonth(),D)).clearTime();
var T=new Date().clearTime().getTime();var N=W.clearTime().getTime();var M=this.minDate?this.minDate.clearTime():Number.NEGATIVE_INFINITY;var Q=this.maxDate?this.maxDate.clearTime():Number.POSITIVE_INFINITY;
var X=this.disabledDatesRE;var L=this.disabledDatesText;var Z=this.disabledDays?this.disabledDays.join(""):false;var V=this.disabledDaysText;var R=this.format;
var G=function(e,a){a.title="";var b=U.getTime();a.firstChild.dateValue=b;if(b==T){a.className+=" x-date-today";a.title=e.todayText}if(b==N){a.className+=" x-date-selected";
setTimeout(function(){try{a.firstChild.focus()}catch(g){}},50)}if(b<M){a.className=" x-date-disabled";a.title=e.minText;return }if(b>Q){a.className=" x-date-disabled";
a.title=e.maxText;return }if(Z){if(Z.indexOf(U.getDay())!=-1){a.title=V;a.className=" x-date-disabled"}}if(X&&R){var c=U.dateFormat(R);if(X.test(c)){a.title=L.replace("%0",c);
a.className=" x-date-disabled"}}if(e.events&&(a.className.indexOf("x-date-active")!=-1)){for(var f=0;f<e.events.length;f++){var d=e.events[f].date.clearTime().getTime();
if(b==d){a.className+=" x-date-today x-date-selected";a.firstChild.linkValue=e.events[f].linkValue;a.title="1234567890\n\n\n\n\n";break}}}};var O=0;for(;
O<C;O++){K[O].innerHTML=(++D);U.setDate(U.getDate()+1);B[O].className="x-date-prevday";G(this,B[O])}for(;O<F;O++){intDay=O-C+1;K[O].innerHTML=(intDay);
U.setDate(U.getDate()+1);B[O].className="x-date-active";G(this,B[O])}var Y=0;for(;O<42;O++){K[O].innerHTML=(++Y);U.setDate(U.getDate()+1);B[O].className="x-date-nextday";
G(this,B[O])}this.mbtn.setText(this.monthNames[W.getMonth()]+" "+W.getFullYear());if(!this.internalRender){var E=this.el.dom.firstChild;var H=E.offsetWidth;
if(this.autoWidth){this.el.setWidth("99%");Ext.fly(E).setWidth("100%")}else{this.el.setWidth(H+this.el.getBorderWidth("lr"));Ext.fly(E).setWidth(H)}this.internalRender=true;
if(Ext.isOpera&&!this.secondPass){E.rows[0].cells[1].style.width=(H-(E.rows[0].cells[0].offsetWidth+E.rows[0].cells[2].offsetWidth))+"px";this.secondPass=true;
this.update.defer(10,this,[W])}}}});Ext.reg("eventcalendar",Ext.ux.EventCalendar);Ext.namespace("GhamL.friends");GhamL.friends.FriendManager=function(){GhamL.friends.FriendManager.superclass.constructor.call(this)
};Ext.extend(GhamL.friends.FriendManager,Ext.util.Observable,{addFriend:function(){var G=new Ext.form.Radio({hideLabel:true,boxLabel:GhamL.msg.Enter_team_id,name:"rad"});
var B=new Ext.form.NumberField({hideLabel:true,anchor:"100%",listeners:{change:function(){if(B.getValue()!=""){G.setValue(true)}}}});var D=new Ext.form.Radio({hideLabel:true,boxLabel:GhamL.msg.Enter_team_name,name:"rad",checked:true});
var F=new Ext.form.TextField({hideLabel:true,anchor:"100%",listeners:{change:function(){if(F.getValue()!=""){D.setValue(true)}}}});var A;function C(I,J,H){this.saveFriend(I,J);
this.addTeamNode(I,J,H)}function E(){var M=B.getValue();var H=F.getValue();if(G.getValue()){if(M==""){B.markInvalid(Ext.form.TextField.prototype.blankText);
return }}else{if(H==""){F.markInvalid(Ext.form.TextField.prototype.blankText);return }else{if(H.length<2){F.markInvalid(String.format(Ext.form.TextField.prototype.minLengthText,2));
return }}}A.close();Ext.Msg.wait(GhamL.msg.Please_wait+"...",GhamL.msg.Adding_team);if(G.getValue()){this.getTeamDetails(M,function(O,N){if(O){C.apply(this,[M,O,N])
}else{Ext.MessageBox.alert(GhamL.msg.Error,GhamL.msg.No_team_found)}},this)}else{var L=new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:"searchTeam.php"}),reader:new Ext.data.XmlReader({record:"Result",id:"ResultID"},[{name:"ResultID",type:"int"},"ResultName"])});
var J;var K;function I(){var N=J.getSelectionModel().getSelected();if(N){C.apply(this,[N.data.ResultID,N.data.ResultName]);K.hide()}}J=new Ext.grid.GridPanel({store:L,region:"center",autoExpandColumn:"nameCol",selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),cm:new Ext.grid.ColumnModel([{header:GhamL.msg.Team_id,dataIndex:"ResultID",width:80,sortable:true},{id:"nameCol",header:GhamL.msg.Team_name,dataIndex:"ResultName",sortable:true}])});
J.on("dblclick",I,this);J.getSelectionModel().grid=J;GhamL.connection.manager.loadStore(L,{params:{teamName:H},successFunction:function(N,P){var O=Ext.DomQuery.selectValue("MoreRecordsExist",L.reader.xmlData);
var Q=[J];if(O=="True"){Q.push({region:"south",html:GhamL.msg.Too_many_result})}K=new Ext.Window({modal:true,layout:"border",width:300,resizable:false,height:400,title:GhamL.msg.Choose_a_team,items:Q,keys:[{key:Ext.EventObject.ENTER,fn:I,scope:this}],buttons:[{id:"okbutton",text:Ext.MessageBox.buttonText.ok,handler:I,scope:this},{text:Ext.MessageBox.buttonText.cancel,handler:function(){K.close()
}}]});Ext.MessageBox.hide();K.show();if(N.length){J.getSelectionModel().selectFirstRow()}J.focus(false,true)},successScope:this})}}A=new Ext.Window({modal:true,layout:"fit",width:300,resizable:false,height:180,title:GhamL.msg.Add_new_friends,items:new Ext.form.FormPanel({bodyStyle:"padding:5px;",height:150,items:[D,F,G,B],keys:[{key:Ext.EventObject.ENTER,fn:E,scope:this}],buttons:[{id:"okbutton1",text:Ext.MessageBox.buttonText.ok,handler:E,scope:this},{text:Ext.MessageBox.buttonText.cancel,handler:function(){A.close()
}}]})});A.show();F.focus(true,true)},getTeamDetails:function(C,B,A){GhamL.connection.manager.ajaxRequest({url:"getTeamDetails.php",params:{"teamId":C},logoutAndReloadOnSessionExpired:true,successFunction:function(E){var F=Ext.DomQuery.selectValue("TeamName",E.responseXML);
var D=Ext.DomQuery.selectValue("LeagueLevelUnitID",E.responseXML);B.apply(A||this,[F,D])},successScope:this})},saveFriend:function(A,B){GhamL.cookie.setCookie("gl_friends_"+GhamL.loggedTeamId+"_"+A,B)
},loadFriends:function(){var A=GhamL.cookie.getCookies("gl_friends_"+GhamL.loggedTeamId+"_");Ext.each(A,function(B){this.addTeamNode(B.id,B.text)},this);
if(A.length){GhamL.treeTeamMatches.friendsNode.expand()}},loadLeagueTeamNode:function(C,A,B){var D=new Ext.tree.TreeNode({text:B||GhamL.msg.League_teams});
GhamL.treeTeamMatches.getRootNode().appendChild(D);Ext.each(C,function(E){this.addTeamNode(E.id,E.name,A,D,true)},this)},removetreeNode:function(B){var A=GhamL.treeTeamMatches.friendsNode;
var C=GhamL.treeTeamMatches.getNodeById("fr_"+B);Ext.MessageBox.confirm(GhamL.msg.Remove,String.format(GhamL.msg.Remove_friend_warning,C.teamName)+"?",function(D){if(D=="yes"){A.removeChild(C);
GhamL.cookie.delCookie("gl_friends_"+GhamL.loggedTeamId+"_"+B)}})},addTeamNode:function(D,F,B,A,C){var E="fr_"+D;A=A||GhamL.treeTeamMatches.friendsNode;
A.appendChild(new GhamL.friends.FriendNode({id:E,teamId:D,teamName:F,leagueId:B,notAddedFriendTeam:C}));A.expand();Ext.Msg.hide()}});GhamL.friends.FriendNode=function(A){this.leagueId=A.leagueId;
GhamL.friends.FriendNode.superclass.constructor.call(this,A);this.updateText(A.teamId,A.teamName,A.notAddedFriendTeam)};Ext.extend(GhamL.friends.FriendNode,Ext.tree.AsyncTreeNode,{updateText:function(C,D,B){this.teamId=C;
if(this.teamName!=D){if(!B){GhamL.friendManager.saveFriend(C,D)}this.teamName=D}var A=D;if(!B){A+="&nbsp;&nbsp;"+GhamL.utils.createToolsButton("close","GhamL.friendManager.removetreeNode('"+C+"')",'ext:qtip="'+GhamL.msg.Remove+'"')
}this.setText(A)},expand:function(A,C,E){if(this.loading){var D;var B=function(){if(!this.loading){clearInterval(D);this.expand(A,C,E)}}.createDelegate(this);
D=setInterval(B,200);return }if(!this.loaded){if(this.fireEvent("beforeload",this)===false){return }this.loading=true;this.ui.beforeLoad(this);this.loadChilds(A,C,E);
return }Ext.tree.AsyncTreeNode.superclass.expand.call(this,A,C,E)},innerLoad:function(A,C,D){var B=GhamL.login.getMatchesListDs("getMatchesList.php");GhamL.connection.manager.loadStore(B,{params:{teamId:this.teamId},successFunction:function(E,F){GhamL.treeTeamMatches.loadMatchTree(B,this.loadComplete.createDelegate(this,[A,C,D]),this,this,this.leagueId)
},successScope:this})},loadChilds:function(A,B,C){if(!this.leagueId){GhamL.friends.FriendManager.prototype.getTeamDetails(this.teamId,function(E,D){this.leagueId=D;
this.updateText(this.teamId,E);this.innerLoad()},this)}else{this.innerLoad()}}});Ext.namespace("GhamL");GhamL.LiveButtons=function(){this.relive=new Ext.Button({text:GhamL.msg.Start_Stop_relive,id:"relive-btn",disabled:true,handler:function(){matchesUpdater.startStopRelive()
},noMoreMatches:function(){this.setText(GhamL.msg.Start_Stop_relive);this.disable()},afterStart:function(){this.setText(GhamL.msg.Stop_relive);if(this.disabled){this.enable()
}},afterStop:function(){this.setText(GhamL.msg.Start_relive)}});this.addMatch=new Ext.Button({text:GhamL.msg.Add_match,handler:addSingleMatchAsk});this.logout=new Ext.Button({text:GhamL.msg.Logout,handler:function(){GhamL.login.logout()
}});this.toolbar=new Ext.Toolbar([this.addMatch,this.logout,this.relive])};Ext.namespace("GhamL");GhamL.MatchNotifier=function(A){this.optionPanel=A;GhamL.MatchNotifier.superclass.constructor.call(this)
};Ext.extend(GhamL.MatchNotifier,Ext.util.Observable,{addLiveMatch:function(A){A.on(anyEvent,this.showPopup,this)},showPopup:function(A,C){var D=[];var B=[];
Ext.each(A,function(G){if(this.optionPanel.showPopup(G.data.Type)){D.push(G)}var H=this.optionPanel.getEventSound(G.data.Type);if(H){B.push(H)}},this);
if(B.length){soundManager.play("mySound",B[0])}if(D.length){var E=window.open("",Ext.id(null,"p"),"height=150,width=500, status=no, menubar=no, toolbar=no, scrollbars=yes");
if(E){var F=E.document;F.write("<html><head><title>"+C.getMatchTitle()+"</title>");F.write("<script>");F.write("setTimeout(function() {self.close()}, "+this.optionPanel.hidePopupSeconds()+");");
F.write("<\/script>");F.write("</head><body>");F.write("<b>"+C.getMatchTitle()+"</b><br>");Ext.each(D,function(G){F.write("<p>"+G.data.EventText+"</p>")
});F.write("</body></html>");F.close()}else{Ext.MessageBox.alert(GhamL.msg.Popup_blocked_title,GhamL.msg.Popup_blocked_text);return }}},addReliveMatch:function(A){A.on(anyEvent,function(B,C){if(this.optionPanel.stopOnEvent()){matchesUpdater.stopRelive()
}},this)}});Ext.namespace("GhamL");GhamL.MatchRatings=function(C){function A(L,K){K.attr='style="padding: 0px"';return'<div class="x-progress-wrap"><div class="x-progress-inner"><div class="x-progress-bar" style="width:'+L+'%"></div></div></div>'
}function D(L,K){if(L>50){return A(100,K)}return A(L*2,K)}function J(L,K){if(L>50){return A((L-50)*2,K)}return A(0,K)}function B(K){return Math.round(K)+"%"
}function E(K){return Math.round(100-K)+"%"}function F(K){return GhamL.MatchRatings.positions[K]}function G(K){return GhamL.MatchRatings.positionGroup[K]
}function I(K){K--;switch(K%4){case 0:return Math.floor(K/4+1)+"--";case 1:return Math.floor(K/4+1)+"-";case 2:return Math.floor(K/4+1)+"+";default:return Math.floor(K/4+1)+"++"
}}var H=new Ext.grid.ColumnModel([{dataIndex:"homePos",width:100,id:"homePos",renderer:F},{dataIndex:"homeRat",width:40,align:"center",id:"homeRat",renderer:I},{dataIndex:"perc",width:40,renderer:B},{dataIndex:"perc",width:80,renderer:D,id:"hperc"},{dataIndex:"perc",width:80,renderer:J,id:"aperc"},{dataIndex:"perc",width:40,renderer:E},{dataIndex:"awayRat",width:40,align:"center",id:"arat",renderer:I},{dataIndex:"awayPos",align:"center",width:100,id:"apos",renderer:F},{dataIndex:"group",id:"group",renderer:G,width:1},]);
this.grid=new Ext.grid.GridPanel({cls:"no-column-headers",region:"center",ds:C.ratingsDs,cm:H,selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),stripeRows:true,view:new Ext.grid.GroupingView({showGroupName:false,autoFill:true,forceFit:true,hideGroupedColumn:true,groupTextTpl:"{text} {[GhamL.MatchRatings.groupCalc(values.rs)]}"})});
GhamL.MatchRatings.superclass.constructor.call(this,{items:[{region:"north",html:'<span class="x-form-field"><img src="icons/weather'+C.weatherID+'.png"> '+C.arenaName+", "+GhamL.msg.crowd+": "+C.soldTotal+"<br>"+GhamL.msg.Possession+": "+C.possessionFirstHalfHome+"% - "+(100-C.possessionFirstHalfHome)+"% / "+C.possessionSecondHalfHome+"% - "+(100-C.possessionSecondHalfHome)+"%</span>",style:"padding: 3px"},this.grid],layout:"border"})
};Ext.extend(GhamL.MatchRatings,Ext.Panel,{});GhamL.MatchRatings.positions={Midfield:GhamL.msg.Midfield,Left:GhamL.msg.Left,Right:GhamL.msg.Right,Mid:GhamL.msg.Mid};
GhamL.MatchRatings.positionGroup={0:GhamL.msg.Midfield,1:GhamL.msg.Defence+" / "+GhamL.msg.Attack,2:GhamL.msg.Attack+" / "+GhamL.msg.Defence};GhamL.MatchRatings.groupCalc=function(D){var B=0;
Ext.each(D,function(E){B+=E.data.homeRat*(E.data.group==0?3:1)});var A=0;Ext.each(D,function(E){A+=E.data.awayRat*(E.data.group==0?3:1)});var C=Math.round(B/(B+A)*100);
return B+" - "+A+"  ("+C+"% - "+(100-C)+"%)"};Ext.namespace("GhamL");GhamL.OptionPanel=function(J){var E;var B;var D=150;function M(){E=new Ext.form.Radio({fieldLabel:GhamL.msg.One_column,name:"columnsNumber"});
var P="change";E.on(P,function(V,U){GhamL.cookie.setCookie("oneColumn",U);GhamL.cookie.setCookie("twoColumn",!U)});E.setValue(GhamL.cookie.getCookieBoolean("oneColumn",true));
B=new Ext.form.Radio({fieldLabel:GhamL.msg.Two_columns,name:"columnsNumber"});B.on(P,function(V,U){GhamL.cookie.setCookie("oneColumn",!U);GhamL.cookie.setCookie("twoColumn",U)
});B.setValue(GhamL.cookie.getCookieBoolean("twoColumn",false));var S=new Ext.data.SimpleStore({fields:["id","name"],data:[["it","Italiano"],["en","English"],["es","Espanol"]],id:0});
var T=new Ext.form.ComboBox({fieldLabel:GhamL.msg.Language,mode:"local",valueField:"id",triggerAction:"all",displayField:"name",editable:false,width:80,store:S});
T.on("select",function(U,V){GhamL.cookie.setCookie("gl_lang",V.data.id);Ext.MessageBox.alert(GhamL.msg.Logout_required,GhamL.msg.Logout_required_text)});
var O;try{O=Ext.util.Format.substr(browserLanguage,0,5).replace("-","_").toLowerCase();if(!S.getById(O)){O=null}}catch(R){}T.setValue(O||"en");var Q=new Ext.form.FormPanel({title:GhamL.msg.General,labelWidth:120,items:[{xtype:"fieldset",title:GhamL.msg.Main_panel_layout,autoHeight:true,items:[E,B],buttons:[{text:GhamL.msg.Change_layout,handler:function(){var U=GhamL.msg.Changing_layout;
Ext.MessageBox.progress(U,U+"..."," ");setTimeout(function(){if(B.getValue()){portal.setNumberOfColumns(2)}else{portal.setNumberOfColumns(1)}Ext.MessageBox.hide()
},250)}}],buttonAlign:"center"},T]});return Q}this.isOneColumnLayout=function(){return E.getValue()};var F={};function N(R,S,P,Q){var O=new Ext.form.Checkbox(R);
O.on("check",function(U,T){GhamL.cookie.setCookie(S,T);if(Q){Ext.each(Q,function(V){if(V!=O){if(!T){V.disable()}else{V.enable()}}})}});O.setValue(GhamL.cookie.getCookie(S,P));
return O}var A;var I;function K(){var P=[goalEvent,attemptEvent,redCardEvent,yellowCardEvent,bruisedEvent,injuryEvent,endOfMatchEvent];var R={};R[yellowCardEvent]=true;
R[bruisedEvent]=true;H=new Ext.form.NumberField({fieldLabel:GhamL.msg.Hide_popup_after_seconds,width:40,allowDecimals:false});GhamL.cookie.bindInCookie(H,"hidePopup",10);
var S=[];A=N({fieldLabel:GhamL.msg.Show_popup_on_new_event,boxLabel:"("+GhamL.msg.Show_popup_warning+")"},"showPopup",true,S);var Q=[];var O=[];O.push(A);
Ext.each(P,function(V,W){var U={boxLabel:GhamL.events.labels[V],hideLabel:true};var T=N(U,"live_ev_"+V,!R[V]);Q.push(T);S.push(T);F[V]=T});O.push({xtype:"fieldset",autoHeight:true,title:GhamL.msg.Events_for_popup,items:Q});
I=N({boxLabel:GhamL.msg.Enable_sounds+"<br>"+GhamL.msg.Sounds_help,hideLabel:true},"gl_sounds",true);O.push({xtype:"fieldset",autoHeight:true,title:GhamL.msg.Sounds,items:I,buttons:[{text:GhamL.msg.Test_sounds,handler:function(){soundManager.play("mySound","sounds/goal.mp3")
}}]});S.push(H);O.push(H);return new Ext.form.FormPanel({title:GhamL.msg.Live,labelWidth:D,items:O,autoScroll:true})}var H;var L;var C;function G(){L=N({fieldLabel:GhamL.msg.Stop_on_each_event},"stopOnEvent",false);
C=new Ext.form.NumberField({fieldLabel:GhamL.msg.Relive_speed,width:40,allowDecimals:false});GhamL.cookie.bindInCookie(C,"reliveSpeed",2000);C.on("change",function(Q,R,P){matchesUpdater.refreshReliveSpeed()
});var O=new Ext.form.FormPanel({title:GhamL.msg.Relive,labelWidth:D,items:[L,C]});return O}this.showPopup=function(P){var O=F[P];return O&&O.checked};
this.getEventSound=function(O){if(I.getValue()&&O==goalEvent){return"sounds/goal.mp3"}};this.hidePopupSeconds=function(){return H.getValue()*1000};this.stopOnEvent=function(){return L.getValue()
};this.getReliveSpeed=function(){return C.getValue()};GhamL.OptionPanel.superclass.constructor.call(this,{layout:"fit",title:GhamL.msg.Settings,items:new Ext.TabPanel({border:false,tabPosition:"bottom",deferredRender:false,activeTab:0,items:[M(),G(),K()]})})
};Ext.extend(GhamL.OptionPanel,Ext.Panel,{});Ext.namespace("Ext.ux.layout");Ext.ux.layout.RowFitLayout=Ext.extend(Ext.layout.ContainerLayout,{monitorResize:true,trackChildEvents:["collapse","expand","hide","show"],renderAll:function(A,B){Ext.ux.layout.RowFitLayout.superclass.renderAll.apply(this,arguments);
A.on("add",this.containerListener);A.on("remove",this.containerListener)},renderItem:function(E,A,C){Ext.ux.layout.RowFitLayout.superclass.renderItem.apply(this,arguments);
for(var B=0,D=this.trackChildEvents.length;B<D;B++){E.on(this.trackChildEvents[B],this.itemListener)}E.animCollapse=false;E.rowFit={hasAbsHeight:false,relHeight:0,calcRelHeight:0,calcAbsHeight:0};
if(E.height){if(typeof E.height=="string"&&E.height.indexOf("%")){E.rowFit.relHeight=parseInt(E.height)}else{E.setHeight(E.height);E.rowFit.hasAbsHeight=true
}}},onLayout:function(F,G){Ext.ux.layout.RowFitLayout.superclass.onLayout.call(this,F,G);if(this.container.collapsed||!F.items||!F.items.length){return 
}var B=0,K=0,I=1,H=[],L=0;for(var D=0,A=F.items.length;D<A;D++){var J=F.items.itemAt(D);if(!J.isVisible()){continue}if(J.collapsed){B+=J.getFrameHeight()
}else{if(J.rowFit.hasAbsHeight){B+=J.height}else{if(!J.rowFit.relHeight){L++}else{K+=J.rowFit.relHeight}H.push(J)}}}if(L===0&&K!=100){I=100/K}var N=G.getStyleSize().height-B,C=N;
while(H.length){var J=H.shift(),E=J.rowFit.relHeight*I,M=0;if(!E){E=(100-K)/L}if(!H.length){M=C}else{M=Math.round(N*E/100)}if(M<0){M=0}J.rowFit.calcAbsHeight=M;
J.rowFit.calcRelHeight=E;J.setHeight(M);C-=M}},itemListener:function(A){A.ownerCt.doLayout()},containerListener:function(A){A.doLayout()}});if(Ext.SplitBar.BasicLayoutAdapter){Ext.ux.layout.RowFitLayout.SplitAdapter=function(C){if(C&&C.el.dom.nextSibling){var B=Ext.getCmp(C.el.dom.nextSibling.id),A=Ext.getCmp(C.resizingEl.id);
if(B){C.maxSize=(A.height||A.rowFit.calcAbsHeight)+B.getInnerHeight()-1}C.minSize=A.getFrameHeight()+1}};Ext.extend(Ext.ux.layout.RowFitLayout.SplitAdapter,Ext.SplitBar.BasicLayoutAdapter,{setElementSize:function(F,G,B){var E=Ext.getCmp(F.resizingEl.id);
if(!E||E.collapsed||!E.isVisible()){return }if(E.rowFit.hasAbsHeight){E.setHeight(G)}else{if(F.el.dom.nextSibling){var D=Ext.getCmp(F.el.dom.nextSibling.id),K=G-E.rowFit.calcAbsHeight,C=D.rowFit,J=E.rowFit,H=J.calcRelHeight/J.calcAbsHeight,I=H*K;
J.relHeight=J.calcRelHeight+I;if(C.hasAbsHeight){var A=D.height-K;D.height=A;D.setHeight(A)}else{C.relHeight=C.calcRelHeight-I}}}E.ownerCt.doLayout()}})
}Ext.Container.LAYOUTS["row-fit"]=Ext.ux.layout.RowFitLayout;Ext.namespace("GhamL.utils");GhamL.utils.dateRenderer=function(A){if(A){return A.substring(0,16)
}else{return null}};GhamL.utils.isNumeric=function(B){var D="0123456789";var A;for(var C=0;C<B.length;C++){A=B.charAt(C);if(D.indexOf(A)==-1){return false
}}return true};GhamL.utils.createToolsButton=function(D,B,A){var C="<span ";if(A){C+=A}if(B){C+='onclick="'+B+'"'}return C+' class="x-tool x-tool-'+D+'" style="float:none; margin:0px 0px 0px 0px; padding:0px 0px 1px 11px">&#160;</span>'
};GhamL.utils.reportException=function(A){Ext.MessageBox.alert("Error",A)};Ext.namespace("GhamL.utils");GhamL.utils.XmlReaderExt=function(A,B){GhamL.utils.XmlReaderExt.superclass.constructor.call(this,A,B)
};Ext.extend(GhamL.utils.XmlReaderExt,Ext.data.XmlReader,{readRecords:function(S){this.xmlData=S;var M=S.documentElement||S;var I=Ext.DomQuery;var B=this.recordType,K=B.prototype.fields;
var D=this.meta.id;var G=0;if(this.meta.totalRecords){G=I.selectNumber(this.meta.totalRecords,M,0)}var P=[];var T=I.select(this.meta.record,M);for(var O=0,Q=T.length;
O<Q;O++){var L=T[O];var A={};var J=D?I.selectValue(D,L):undefined;for(var N=0,H=K.length;N<H;N++){var R=K.items[N];var E;if(typeof R.mapping=="function"){E=R.mapping(L)
}else{E=I.selectValue(R.mapping||R.name,L,R.defaultValue)}E=R.convert(E);A[R.name]=E}var F=B;var C=new F(A,J);C.node=L;P[P.length]=C}return{records:P,totalRecords:G||P.length}
}});Ext.namespace("GhamL");GhamL.createPortal=function(){var D=new Ext.Panel({layout:"row-fit",border:false,defaults:{},items:[{xtype:"panel",title:GhamL.msg.Please_wait+"...",html:" "}],columnWidth:1});
var C=new Ext.Panel({layout:"row-fit",border:false,defaults:{},items:[{xtype:"panel",title:GhamL.msg.Please_wait+"...",html:" "}],columnWidth:0});var E=function(){A.resizeAll();
D.items.each(function(F){F.doLayout()});C.items.each(function(F){F.doLayout()});A.doLayout()};var B=200;var A=new Ext.Panel({region:"center",layout:"fit",border:false,items:{layout:"column",autoScroll:true,layoutConfig:{columns:1},items:[D,C]},initColumns:function(){var F=D.items.get(0);
F.hide();D.items.remove(F);F=C.items.get(0);F.hide();C.items.remove(F)},removePortlet:function(F){F.ownerCt.remove(F,true);this.setNumberOfColumns(this.optionPanel.isOneColumnLayout()?1:2)
},addPortlet:function(F){F.collapsible=true;F.on("collapse",E);F.on("expand",E);if(!this.optionPanel.isOneColumnLayout()&&D.items.length>C.items.length){D.columnWidth=0.5;
C.columnWidth=0.5;C.show();C.items.add(F);F.ownerCt=C}else{D.items.add(F);F.ownerCt=D}this.resizeAll();this.setNumberOfColumns(this.optionPanel.isOneColumnLayout()?1:2);
D.doLayout();this.doLayout()},containsMatch:function(H){var G=new Ext.util.MixedCollection();G.addAll(D.items.getRange());G.addAll(C.items.getRange());
var F=false;G.each(function(I){if(I.matchModel.getId()==H){F=true;return true}});return F},resizeAll:function(){var K=new Ext.util.MixedCollection();K.addAll(D.items.getRange());
K.addAll(C.items.getRange());if(K.length){var F=0;var M=0;var G=0;D.items.each(function(N){if(!N.collapsed){F++}else{G=N.header.getHeight()}});C.items.each(function(N){if(!N.collapsed){M++
}else{G=N.header.getHeight()}});var H;var L;if(F<M){H=M;L=C.items.length-H}else{H=F;L=D.items.length-H}if(H){var I;if(G){I=this.getInnerHeight()-L*G}else{I=this.getInnerHeight()
}var J=Math.max(B,parseInt(I/H)-2);K.each(function(N){if(!N.collapsed){N.setHeight(J)}})}}},setNumberOfColumns:function(G){function I(M){var O=[];for(var N=M.getCount();
N>=1;N--){O.push(M.removeAt(N-1))}O.reverse();return O}var H;var F;var K=I(D.items);var J=I(C.items);if(G==1||K.length+J.length==1){D.columnWidth=1;C.columnWidth=0.01;
C.hide()}else{D.columnWidth=0.5;C.columnWidth=0.5;C.show()}if(G==1){F=Math.max(K.length,J.length);for(H=0;H<F;H++){if(K[H]){D.add(K[H])}if(J[H]){D.add(J[H])
}}}else{var L=[];F=Math.max(K.length,J.length);for(H=0;H<F;H++){if(K[H]){L.push(K[H])}if(J[H]){L.push(J[H])}}Ext.each(L,function(M,N){if(N%2===0){D.add(M)
}else{C.add(M)}})}E()}});D.on("resize",E);D.on("remove",E);C.on("resize",E);C.on("remove",E);return A};Ext.namespace("GhamL.events");var goalEvent="G";
var attemptEvent="A";var yellowCardEvent="Y";var redCardEvent="R";var endOfMatchEvent="E";var bestPlayerEvent="BP";var worstPlayerEvent="WP";var bruisedEvent="B";
var injuryEvent="IN";var otherEvent="O";var anyEvent="ANY";var minuteEvent="MIN";var informationEvent="I";GhamL.events=function(){function A(E){if(E>=100&&E<200){return goalEvent
}if(E>=100&&E<300){return attemptEvent}if(E==511||E==510){return yellowCardEvent}if(E>=512&&E<=514){return redCardEvent}if(E==599){return endOfMatchEvent
}if(E==41){return bestPlayerEvent}if(E==42){return worstPlayerEvent}if(E==90||E==94){return bruisedEvent}if(E==91||E==92||E==93||E==95||E==96){return injuryEvent
}return otherEvent}var C={5:"SE",6:"SE",7:"SE",8:"SE",9:"SE",15:"SE",16:"SE",17:"SE",18:"SE",19:"SE",35:"SE",36:"SE",37:"SE",38:"SE",39:"SE",0:"FK",10:"FK",20:"FK",30:"FK",50:"FK",60:"FK",70:"FK",80:"FK",1:"C",11:"C",21:"C",31:"C",51:"C",61:"C",71:"C",81:"C",2:"L",12:"L",22:"L",32:"L",52:"L",62:"L",72:"L",82:"L",3:"R",13:"R",23:"R",33:"R",53:"R",63:"R",73:"R",83:"R",4:"P",14:"P",24:"P",34:"P",54:"P",64:"P",74:"P",84:"P",40:"CA",41:"CA",42:"CA",43:"CA",44:"CA"};
var B={};function D(F,E){return"player_"+F+"_"+E}return{createEventRecord:function(H,I){function E(N,P,M,L,J){var K=D(P,I);var O=M.replace(/'/,"\\'");return"<b id="+K+' onmouseover="GhamL.events.initTooltip('+P+", '"+O+"', "+I+')">'
}if(H.EventText){H.EventText=H.EventText.replace("<br />","");H.EventText=H.EventText.replace(/<a href=\"\/Club\/Arena\/Default.aspx\?ArenaID=([0-9]*)\">/ig,"<b>");
H.EventText=H.EventText.replace(/<a href=\"\/Club\/Players\/Player.aspx\?playerId=([0-9]*)\" title=\"([^\"]*)\">/ig,E);H.EventText=H.EventText.replace(/<a href=\"\/World\/Regions\/Region.aspx\?RegionID=([0-9]*)\" title=\"([^\"]*)\">/ig,"<b>");
H.EventText=H.EventText.replace(/<a href=\"\/Common\/Arena\/arenaDetails.aspx\?ArenaID=([0-9]*)\" title=\"([^\"]*)\">/ig,"<b>");H.EventText=H.EventText.replace(/<a href=\"\/Common\/Players\/PlayerDetails.aspx\?playerId=([0-9]*)\" title=\"([^\"]*)\">/ig,E);
H.EventText=H.EventText.replace(/<a href=\"\/Common\/Regions\/regionDetails.aspx\?RegionID=([0-9]*)&LeagueID=([0-9]*)\" title=\"([^\"]*)\">/ig,"<b>");H.EventText=H.EventText.replace(/<a href=\"\/Common\/Regions\/regionDetails.aspx\?RegionID=([0-9]*)&amp;LeagueID=([0-9]*)\" title=\"([^\"]*)\">/ig,"<b>");
H.EventText=H.EventText.replace(/<a href=\"\/Common\/PlayerDetails.asp\?PlayerID=([0-9]*)\" title=\"([^\"]*)\">/ig,E);H.EventText=H.EventText.replace(/<a href=\"\/Common\/regionDetails.asp\?RegionID=([0-9]*)&LeagueID=([0-9]*)\" title=\"([^\"]*)\">/ig,"<b>");
H.EventText=H.EventText.replace(/<a href=\"gameRules.asp\?find=labels\&amp;lt=teamskills\&amp;ll=[0-9]*#teamskills" style=\"text-decoration: none;\">/ig,"<b>");
H.EventText=H.EventText.replace(/<\/a>/g,"</b>")}else{return null}var G=H.EventKey;G=G.substring(0,G.length-2);H.Type=A(G);if(H.Type=="G"||H.Type=="A"){H.Side=C[G%100]
}else{H.Side=""}var F=parseInt(H.Minute);H.Minute=F;if(F===0){H.MinuteGroup="0"+GhamL.msg.Match_info}else{if(F<=45){H.MinuteGroup="1"+GhamL.msg.First_half
}else{if(F<=90){H.MinuteGroup="2"+GhamL.msg.Second_half}else{if(F<=90){H.MinuteGroup="3"+GhamL.msg.Extra_time}}}}return new Ext.data.Record(H,H.Index)},sides:{"SE":GhamL.msg.Special_event_short,"FK":GhamL.msg.Free_kick_short,"C":GhamL.msg.Center_short,"L":GhamL.msg.Left_short,"R":GhamL.msg.Right_short,"P":GhamL.msg.Penalty_short,"CA":GhamL.msg.Counter_attack_short},sideTooltip:{"SE":GhamL.msg.Special_event,"FK":GhamL.msg.Free_kick,"C":GhamL.msg.Center,"L":GhamL.msg.Left,"R":GhamL.msg.Right,"P":GhamL.msg.Penalty,"CA":GhamL.msg.Counter_attack},initTooltip:function(J,F,I){var G=J+"_"+I;
if(!B[G]){var E=D(J,I);var H=Ext.QuickTips.getQuickTip();H.register({target:E,title:F,text:matchDetails[I].getPlayerTooltip(J),playerId:J,matchId:I,frame:true,headerAsText:false});
B[G]=true}},updatePlayerTooltip:function(G){var E=G.activeTarget;if(E&&E.matchId&&E.playerId){var F=matchDetails[E.matchId].getPlayerTooltip(E.playerId);
G.body.update(F)}},isInformationEvents:function(E){return E!=goalEvent&&E!=attemptEvent&&E!=yellowCardEvent&&E!=redCardEvent&&E!=bruisedEvent&&E!=injuryEvent
},labels:function(){var E={};E[goalEvent]=GhamL.msg.Event_label_Goal;E[attemptEvent]=GhamL.msg.Event_label_Attempt;E[yellowCardEvent]=GhamL.msg.Event_label_Yellow_card;
E[redCardEvent]=GhamL.msg.Event_label_Red_card;E[endOfMatchEvent]=GhamL.msg.Event_label_End_of_the_match;E[bestPlayerEvent]=GhamL.msg.Event_label_Best_player;
E[worstPlayerEvent]=GhamL.msg.Event_label_Worst_player;E[bruisedEvent]=GhamL.msg.Event_label_Bruised;E[injuryEvent]=GhamL.msg.Event_label_Injury;E[otherEvent]=GhamL.msg.Event_label_Other;
E[informationEvent]=GhamL.msg.Event_label_Information;return E}(),eventsForTooltipOrder:[bestPlayerEvent,worstPlayerEvent,goalEvent,attemptEvent,yellowCardEvent,redCardEvent,bruisedEvent,injuryEvent],eventsNoNumber:function(){var E={};
E[bestPlayerEvent]=true;E[worstPlayerEvent]=true;E[bruisedEvent]=true;E[injuryEvent]=true;return E}(),eventsImage:function(){var E={};E[goalEvent]="goal.png";
E[attemptEvent]="attempt.png";E[yellowCardEvent]="yellow_card.gif";E[redCardEvent]="red_card.gif";E[bruisedEvent]="bruised.gif";E[injuryEvent]="injured.gif";
return E}(),labelsTooltip:function(){var E={};E[goalEvent]=GhamL.msg.Event_label_Goal_tooltip;E[attemptEvent]=GhamL.msg.Event_label_Attempt_tooltip;E[yellowCardEvent]=GhamL.msg.Event_label_Yellow_card_tooltip;
E[redCardEvent]=GhamL.msg.Event_label_Red_card_tooltip;E[bestPlayerEvent]=GhamL.msg.Event_label_Best_player_tooltip;E[worstPlayerEvent]=GhamL.msg.Event_label_Worst_player_tooltip;
E[bruisedEvent]=GhamL.msg.Event_label_Bruised_tooltip;E[injuryEvent]=GhamL.msg.Event_label_Injury_tooltip;return E}()}}();Ext.namespace("GhamL.layout");
GhamL.layout.createGridMatches=function(){var B=new Ext.data.GroupingStore({proxy:new Ext.data.HttpProxy({url:"addMatch.php"}),reader:new Ext.data.XmlReader({record:"Match",id:"MatchID",loadPosition:false},["MatchID","MatchDate","HomeTeamName","AwayTeamName"]),groupField:"matchTitle"});
function C(F,G,D){var E=D.data.HomeTeamName+"-"+D.data.AwayTeamName+"&nbsp;&nbsp;"+GhamL.utils.createToolsButton("close","GhamL.layout.removeMatchFromList('"+D.data.MatchID+"')");
return E}var A=new Ext.grid.ColumnModel([{header:GhamL.msg.Minute_short,dataIndex:"currentMinute",width:30,align:"center"},{header:GhamL.msg.Teams,dataIndex:"HomeTeamName",width:200,renderer:C},{header:GhamL.msg.Result,dataIndex:"result",width:45,align:"center"},{header:GhamL.msg.Attempts,dataIndex:"attempts",width:45,align:"center"},{header:GhamL.msg.Cards,dataIndex:"cards",width:60,align:"center"},{header:GhamL.msg.Date,dataIndex:"MatchDate",width:110,renderer:GhamL.utils.dateRenderer},{header:GhamL.msg.Type,dataIndex:"matchTitle",width:100,hidden:true}]);
A.defaultSortable=true;return new Ext.grid.GridPanel({region:"center",headerAsText:false,ds:B,cm:A,autoSizeColumns:false,border:false,selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),view:new Ext.grid.GroupingView({groupTextTpl:"{group}",enableGroupingMenu:false,hideGroupedColumn:true})})
};GhamL.layout.removeMatchFromList=function(C){function B(D){GhamL.layout.gridMatches.getStore().remove(GhamL.layout.gridMatches.getStore().getById(D));
var E=matchDetails[D];portal.removePortlet(E);matchesUpdater.removeMatch(D);Ext.Msg.hide()}var A=matchesUpdater.getMatchModel(C);if(!A.isFinished()){Ext.Msg.wait(GhamL.msg.Please_wait+"...",GhamL.msg.Removing_match,{text:GhamL.msg.Removing_match});
GhamL.connection.manager.ajaxRequest({url:"deleteMatch.php",params:{"matchId":C},successFunction:function(D){var E=Ext.util.JSON.decode(D.responseText).removed;
B(E)}})}else{B(C)}};Ext.namespace("GhamL");GhamL.LeagueTable=function(C,F,M,A){var I=function(N,O){return function(R,P,Q){if(Q.data[O]>Q.data[O+"_or"]){P.css=N+"cell"
}return R}};var D=30;var J=new Ext.grid.ColumnModel([{header:GhamL.msg.Team,dataIndex:"TeamName",width:140},{header:GhamL.msg.Games_played_short,dataIndex:"Matches",width:D,align:"center"},{header:GhamL.msg.Points_short,dataIndex:"Points",width:D,renderer:I("green","Points"),align:"center"},{header:GhamL.msg.Games_won_short,dataIndex:"Victories",width:D,renderer:I("green","Victories"),align:"center"},{header:GhamL.msg.Games_drawn_short,dataIndex:"Draws",width:D,renderer:I("green","Draws"),align:"center"},{header:GhamL.msg.Games_lost_short,dataIndex:"Looses",width:D,renderer:I("red","Looses"),align:"center"},{header:GhamL.msg.Goals_for_short,dataIndex:"GD",width:D,align:"center"},{header:GhamL.msg.Goals_against_short,dataIndex:"GS",width:D,align:"center"},{header:GhamL.msg.Goals_difference_short,dataIndex:"Difference",width:D,align:"center"}]);
J.defaultSortable=true;this.ds=new Ext.data.Store({reader:new Ext.data.JsonReader({record:"Match",id:"TeamID",loadPosition:false},["TeamID","TeamName","Matches","Points","Victories","Draws","Looses","GD","GS","Difference"])});
var G={};getRecord=function(P,O){var N=G[P];if(!N){N=new Ext.data.Record({TeamID:P,TeamName:O,Matches:0,Points:0,Victories:0,Draws:0,Looses:0,GD:0,GS:0,Difference:0},P);
G[P]=N}return N};M=parseInt(M);F.each(function(N){var P=N.data;var T=parseInt(P.MatchRound);if(T<M||M==1){var R=getRecord(P.HomeTeamID,P.HomeTeamName);
var Q=getRecord(P.AwayTeamID,P.AwayTeamName);var S=P.HomeGoals;if(T<M&&S!==""){var O=P.AwayGoals;S=parseInt(S);O=parseInt(O);this.updateRecord(R,S,O);this.updateRecord(Q,O,S)
}}},this);for(var K in G){var L=G[K];var H=this.ds.fields;for(var E=2;E<H.getCount();E++){var B=H.get(E).name;L.data[B+"_or"]=L.data[B]}this.ds.add(L)}this.ds.sort("Difference","desc");
this.ds.sort("Points","desc");GhamL.LeagueTable.superclass.constructor.call(this,{title:C+" "+GhamL.msg.Round+" "+M,ds:this.ds,cm:J,region:"south",selModel:new Ext.grid.RowSelectionModel({singleSelect:true})});
Ext.each(A,function(N){this.updateTable(null,N);N.on(goalEvent,this.updateTable,this)},this)};Ext.extend(GhamL.LeagueTable,Ext.grid.GridPanel,{updateTable:function(B,A){var C=this.getStore();
this.updateExistingRecord(C.getById(A.home.id),A.home.goals,A.away.goals);this.updateExistingRecord(C.getById(A.away.id),A.away.goals,A.home.goals);C.sort("Difference","desc");
C.sort("Points","desc")},updateRecord:function(D,B,A){var C=D.data;if(B>A){C.Points+=3;C.Victories++}else{if(B==A){C.Points++;C.Draws++}else{C.Looses++
}}C.GD+=B;C.GS+=A;C.Difference=C.GD-C.GS;C.Matches++},updateExistingRecord:function(D,B,A){if(D){var C=D.data;if(B>A){this.updateField(C,"Points",3);this.updateField(C,"Victories",1);
this.updateField(C,"Draws",0);this.updateField(C,"Looses",0)}else{if(B==A){this.updateField(C,"Points",1);this.updateField(C,"Victories",0);this.updateField(C,"Draws",1);
this.updateField(C,"Looses",0)}else{this.updateField(C,"Points",0);this.updateField(C,"Victories",0);this.updateField(C,"Draws",0);this.updateField(C,"Looses",1)
}}this.updateField(C,"Matches",1);this.updateField(C,"GD",B);this.updateField(C,"GS",A);C.Difference=C.GD-C.GS;D.commit()}},updateField:function(C,A,B){C[A]=C[A+"_or"]+B
}});Ext.namespace("GhamL");var matchesTab;var matchesCont;var matchesCont2;var portal;var liveButtons;var matchDetails={};var matchesUpdater;GhamL.treeTeamMatches=null;
GhamL.friendManager=null;GhamL.calendar=null;GhamL.initLiveLayout=function(){Ext.QuickTips.init();Ext.QuickTips.getQuickTip().on("beforeshow",GhamL.events.updatePlayerTooltip);
liveButtons=new GhamL.LiveButtons();matchesUpdater=new GhamL.MatchesUpdater();Ext.state.Manager.setProvider(new Ext.state.CookieProvider());GhamL.layout.gridMatches=GhamL.layout.createGridMatches();
GhamL.treeTeamMatches=new GhamL.TreeTeamMatches();GhamL.friendManager=new GhamL.friends.FriendManager();if(loggedIn){GhamL.login.getMatchesListFromServer()
}matchesCont=new Ext.TabPanel({region:"south",collapseMode:"mini",split:true,collapsible:true,showTitle:false});matchesCont2=new Ext.Panel({layout:"border",title:GhamL.msg.Matches,id:"matchesAndLeague",items:[GhamL.layout.gridMatches,matchesCont]});
matchesTab=new Ext.TabPanel({border:false,region:"center",tabPosition:"bottom",deferredRender:false,activeTab:1,items:[matchesCont2,{layout:"border",title:GhamL.msg.Team_Matches,items:[GhamL.treeTeamMatches,{layout:"fit",collapseMode:"mini",split:true,collapsible:true,region:"south",height:190,autoScroll:true,borde:false,html:'<div id="calDiv" align="center"></div><div style="font:normal 12px tahoma,arial,helvetica,sans-serif">'+GhamL.msg.Match_time+': <span id="matchTimeId"></span></div>'}]}]});
var B=new Ext.Panel({split:true,initialSize:100,minSize:100,maxSize:400,autoScroll:true,collapsible:true,titlebar:true,title:GhamL.msg.Matches,layout:"border",items:[matchesTab]});
var A=new GhamL.OptionPanel();var E={region:"east",id:"west-panel",collapseMode:"mini",split:true,width:240,minSize:175,collapsible:true,layout:"accordion",layoutConfig:{animate:true},tbar:liveButtons.toolbar,items:[B,A]};
portal=GhamL.createPortal();portal.optionPanel=A;var C=[portal,E];if(!ghamDebug){C.push({region:"west",split:false,width:160,titlebar:true,collapsible:false,title:"Gham Live "+liveVersion,closable:false,html:'<div id="westPanel" class="x-layout-inactive-content" align="center"><br><center> <a href="http://www.hattrickitalia.org/gham/" target="_blank">  <img src="images/gham2.jpg" width="157" height="94"> </a></center><br><span style="font:12px tahoma,arial,helvetica;"><i><a style="text-decoration: none" href="mailto:gham@hattrickitalia.org">gham@hattrickitalia.org</a></i></span><br><br><a href="http://sourceforge.net/donate/index.php?group_id=126995"> <img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" border="0" alt="Support This Project" /></a><br><br><div align="center" id="adsWrapper"></div><br><img src="images/chpp_logotype.gif"><br><br><a href="http://sourceforge.net/" target="_blank"> <img src="http://sourceforge.net/sflogo.php?group_id=126995&type=2" border="0"></a></div>'})
}var D=new Ext.Viewport({layout:"border",items:C});if(!ghamDebug){Ext.get("adsWrapper").appendChild(Ext.get("adsDiv"))}GhamL.calendar=new Ext.ux.EventCalendar({renderTo:"calDiv",autoWidth:true});
if(portal.initColumns){portal.initColumns()}matchesCont.hide();if(!loggedIn){GhamL.login.showDialog()}else{matchesUpdater.refreshFromServer()}matchesUpdater.matchNotifiers.push(new GhamL.MatchNotifier(A));
matchesUpdater.optionPanel=A;setTimeout(function(){Ext.get("loading").remove();Ext.get("loading-mask").fadeOut({remove:true})},250)};function addSingleMatch(A){if(GhamL.utils.isNumeric(A)){matchesUpdater.refreshFromServer(A)
}else{Ext.MessageBox.alert(GhamL.msg.Error,String.format(Ext.form.NumberField.prototype.nanText,A))}}function parseRequestParameters(){var D=location.search;
if(D){D=D.substring(1);var F=D.split("&");for(var B=0;B<F.length;B++){var E=F[B];var C=E.split("=");var A=C[0];if(A=="matchId"){addSingleMatch(C[1])}}}}function addSingleMatchAsk(){Ext.MessageBox.prompt(GhamL.msg.Match_id,GhamL.msg.Enter_match_id+":",function(A,B){if(A=="ok"){addSingleMatch(B)
}})}Ext.namespace("GhamL");GhamL.login={loginDialog:null,userNameCoockie:"gl_userName",securityCodeCoockie:"gl_securityCode",userNameTf:null,securityCodeTf:null,saveInfoInCoockie:null,eseguiLogin:function(){if(this.userNameTf.isValid()&&this.securityCodeTf.isValid()){var A=this.userNameTf.getValue();
var B=this.securityCodeTf.getValue();this.loginDialog.hide();Ext.Msg.wait(GhamL.msg.Login+"...",GhamL.msg.Login);this.getMatchesListFromServer(A,B)}},showDialog:function(){if(!this.loginDialog){this.userNameTf=new Ext.form.TextField({fieldLabel:GhamL.msg.User_name,name:"first",anchor:"100%",allowBlank:false});
var A=GhamL.cookie.getCookie(this.userNameCoockie);if(A){this.userNameTf.setValue(A)}this.saveInfoInCoockie=new Ext.form.Checkbox({boxLabel:GhamL.msg.Save_in_cookie,width:"auto"});
this.securityCodeTf=new Ext.form.TextField({fieldLabel:GhamL.msg.Security_code,name:"last",anchor:"100%",allowBlank:false,inputType:"password"});A=GhamL.cookie.getCookie(this.securityCodeCoockie);
if(A){this.securityCodeTf.setValue(A);this.saveInfoInCoockie.setValue(true)}this.loginDialog=new Ext.Window({layout:"fit",title:"Gham Live "+GhamL.msg.Login,modal:true,closable:false,resizable:false,width:350,height:155,shadow:true,proxyDrag:true,buttonAlign:"center",items:new Ext.form.FormPanel({bodyStyle:"padding:5px;",labelWidth:100,labelSeparator:" ",items:[this.userNameTf,this.securityCodeTf,this.saveInfoInCoockie],keys:{key:Ext.EventObject.ENTER,fn:this.eseguiLogin,scope:this}}),buttons:[{text:GhamL.msg.Login,handler:this.eseguiLogin,scope:this}]})
}this.loginDialog.show(Ext.get("show-dialog-btn"))},getMatchesListFromServer:function(A,C){var E=undefined;if(A&&C){E={username:A,password:C}}var B=this.getMatchesListDs();
function D(F,G){GhamL.loggedTeamId=Ext.DomQuery.selectValue("TeamID",B.reader.xmlData);GhamL.loggedTeamName=Ext.DomQuery.selectValue("TeamName",B.reader.xmlData);
GhamL.treeTeamMatches.loadMatchTree(B,function(I,H,J){if(this.saveInfoInCoockie&&this.saveInfoInCoockie.getValue()){GhamL.cookie.setCookie(this.userNameCoockie,A);
GhamL.cookie.setCookie(this.securityCodeCoockie,C)}GhamL.cookie.setCookie("gl_version",liveVersion);if(typeof (pageTracker)!="undefined"&&pageTracker._trackPageview){pageTracker._trackPageview("/live/loginOk")
}GhamL.friendManager.loadFriends();var K=[];I.each(function(L){var M=L.data;if(M.MatchRound==1){if(M.HomeTeamID!=GhamL.loggedTeamId){K.push({id:M.HomeTeamID,name:M.HomeTeamName})
}if(M.AwayTeamID!=GhamL.loggedTeamId){K.push({id:M.AwayTeamID,name:M.AwayTeamName})}}});GhamL.friendManager.loadLeagueTeamNode(K,H,J);parseRequestParameters()
},this)}GhamL.connection.manager.loadStore(B,{params:E,successFunction:D,successScope:this,failureFunction:this.showDialog,failureScope:this,sessionExpiredError:GhamL.msg.Invalid_login,logoutOnSessionExpired:false})
},getMatchesListDs:function(A){return new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:A||"login.php",timeout:120000}),reader:new Ext.data.XmlReader({record:"Match",id:"MatchID",loadPosition:false},["MatchID","Status","MatchDate","HomeTeamName","AwayTeamName","MatchType"])})
},logout:function(){Ext.MessageBox.progress(GhamL.msg.Log_out,GhamL.msg.Logging_out+"...");Ext.MessageBox.updateProgress(0," ");Ext.Ajax.request({url:"logout.php",success:function(A){if(A.responseText=="OK"){Ext.MessageBox.updateProgress(0.5,GhamL.msg.Reloading_page+"...");
window.location.reload()}else{Ext.MessageBox.hide()}}})}};Ext.namespace("GhamL");GhamL.MatchDetail=function(L){this.matchModel=L;var M=L.getId();this.matchModel.on(anyEvent,function(){if(this.eventsGrid.getView().ds){this.eventsGrid.getView().ensureVisible(this.eventsGrid.getStore().getCount()-1,0)
}},this);var F=function(T,P,W,V,R,Q,U){if(W.data.SubjectTeamID==U){var S=GhamL.events.eventsImage[T];if(S){return"<img src='icons/"+S+"'/>"}else{if(W.data.EventKey.indexOf("21_")==0){if(L.home.id==U){return L.home.formation
}else{return L.away.formation}}}}return""};function G(S,P,Q){var R=parseInt(Q.data.Minute);if(R&&L.getCurrentMinute()<=R+2){P.css="yellowcell"}return String.format('<table width="100%"><tr><td nowrap="false" style="white-space:normal; margin:0px">{0}</td></tr></table>',S)
}function H(P){if(P){return'<div ext:qtip="'+GhamL.events.sideTooltip[P]+'">'+GhamL.events.sides[P]+"</div>"}return""}var N=new Ext.grid.ColumnModel([{header:GhamL.msg.Minute_short,dataIndex:"Minute",width:25,align:"center"},{header:GhamL.msg.Home_short,dataIndex:"Type",width:30,renderer:F.createDelegate(this,[this.matchModel.home.id],true),align:"center"},{header:GhamL.msg.Away_short,dataIndex:"Type",width:30,renderer:F.createDelegate(this,[this.matchModel.away.id],true),align:"center"},{header:GhamL.msg.Side_short,dataIndex:"Side",width:25,align:"center",renderer:H},{header:GhamL.msg.Text,id:"eventColumn",dataIndex:"EventText",renderer:G},{dataIndex:"MinuteGroup",id:"MinuteGroup",hidden:true}]);
N.defaultSortable=true;this.eventsGrid=new Ext.grid.GridPanel({cls:"no-column-headers",ds:L.ds,cm:N,selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),stripeRows:true,autoExpandColumn:"eventColumn",view:new Ext.grid.GroupingView({groupTextTpl:"{group:substr(1, 100)}",enableGroupingMenu:false}),enableColumnHide:false,title:GhamL.msg.Report+" ("+L.getCurrentMinute()+")"});
this.getPlayerTooltip=function(P){return L.getPlayerTooltip(P)};var B=this.eventsGrid;var J=true;function I(P){return{text:GhamL.events.labels[P],eventType:P,checked:true,checkHandler:L.filterEvents,scope:L,hideOnClick:false}
}var C=new Ext.menu.Menu({id:"mainMenu",items:[{text:GhamL.msg.Group_events,checked:true,checkHandler:L.updateGroup,scope:L,hideOnClick:false},{text:GhamL.msg.Filter_events,menu:{items:[I(goalEvent),I(attemptEvent),I(yellowCardEvent),I(redCardEvent),I(bruisedEvent),I(injuryEvent),I(informationEvent)]}}]});
var O=new GhamL.WrappedPanel(GhamL.msg.Home_stars);var E=new GhamL.WrappedPanel(GhamL.msg.Away_stars);var D=new GhamL.WrappedPanel(GhamL.msg.Ratings);var K=new Ext.TabPanel({activeTab:0,enableTabScroll:true,items:[this.eventsGrid],layoutOnTabChange:true});
this.matchModel.on(minuteEvent,function(P,Q,R){this.eventsGrid.setTitle(GhamL.msg.Report+" ("+Q.getCurrentMinute()+")");this.setTitle(this.matchModel.getMatchTitleShort());
if(this.eventsGrid.getView().ds){this.eventsGrid.getView().refresh()}},this);GhamL.MatchDetail.superclass.constructor.call(this,{title:this.matchModel.getMatchTitleShort(),items:K,layout:"fit",height:200,tools:[{id:"gear",handler:function(R,Q,P){C.show(Q)
},qtip:GhamL.msg.Settings}]});this.matchModel.on(endOfMatchEvent,function(P,Q){K.add(O);K.add(E);K.add(D);K.doLayout()},this);function A(Q,R,S){var P=0;
Q.each(function(T){if(T.data.RoleID>=1&&T.data.RoleID<=11){P+=T.data.RatingStars}});R.swapPanel(new GhamL.MatchStars(Q),S+P)}this.matchModel.on("homeStarsLoaded",A.createDelegate(this,[O,GhamL.msg.Home_stars+" "],true));
this.matchModel.on("awayStarsLoaded",A.createDelegate(this,[E,GhamL.msg.Away_stars+" "],true));this.matchModel.on("ratingsLoaded",function(R){var Q=0,P=0;
R.ratingsDs.each(function(T){var S=T.data.group==0?3:1;Q+=T.data.homeRat*S;P+=T.data.awayRat*S});D.swapPanel(new GhamL.MatchRatings(R),GhamL.msg.Ratings+" "+Q+" - "+P);
K.doLayout()});this.matchModel.on("homeStarsLoadedError",O.showRetryButton.createDelegate(O,[GhamL.msg.Home_stars,this.matchModel.reloadHomeStars.createDelegate(this.matchModel,[])]));
this.matchModel.on("awayStarsLoadedError",O.showRetryButton.createDelegate(E,[GhamL.msg.Away_stars,this.matchModel.reloadAwayStars.createDelegate(this.matchModel,[])]));
this.matchModel.on("ratingsLoadedError",O.showRetryButton.createDelegate(D,[GhamL.msg.Ratings,this.matchModel.reloadRatings.createDelegate(this.matchModel,[])]))
};Ext.extend(GhamL.MatchDetail,Ext.Panel,{});GhamL.WrappedPanel=function(A){this.loadingPanel=new Ext.Panel({html:'<div id="loading">	<div class="loading-indicator">		<img src="images/large-loading.gif" width="32" height="32" style="margin-right:8px;float:left;vertical-align:top;"/>		Gham Live<br />		<span id="loading-msg">'+Ext.LoadMask.prototype.msg+"</span></div></div> "});
GhamL.WrappedPanel.superclass.constructor.call(this,{layout:"fit",items:[this.loadingPanel]});this.curPan=this.loadingPanel;this.setTitle(A,"loading-background")
};Ext.extend(GhamL.WrappedPanel,Ext.Panel,{removeTitleIcon:function(){var C=this.ownerCt.getTabEl(this);if(C){var A=Ext.fly(C);var B=A.findParent("li.x-tab-with-icon");
if(B){A.child("span.x-tab-strip-text").removeClass("loading-background");Ext.get(B).removeClass("x-tab-with-icon")}}},swapPanel:function(A,B){this.remove(this.curPan);
this.add(A);this.curPan=A;if(B){if(this.ownerCt){this.removeTitleIcon()}else{this.setIconClass(null)}this.setTitle(B)}if(this.ownerCt){this.ownerCt.doLayout()
}},showRetryButton:function(B,A){this.swapPanel(new Ext.Panel({html:"<br><center>"+GhamL.msg.Download_error+"</center>",buttons:[{text:GhamL.msg.Retry,handler:function(){this.swapPanel(this.loadingPanel);
A()},scope:this}],buttonAlign:"center"}),B)}});Ext.namespace("GhamL");GhamL.MatchModel=function(A){this.home=new GhamL.Team();this.away=new GhamL.Team();
this.groupField="MinuteGroup";this.ds=new Ext.data.GroupingStore({proxy:new Ext.data.HttpProxy({url:"matches.php"}),reader:new Ext.data.JsonReader({record:"Item",id:"Index",loadPosition:false},["Minute","Type","Side","EventText","MinuteGroup"]),groupField:this.groupField,sortInfo:{field:"Minute",direction:"ASC"}});
this.home.id=A.data.HomeTeamID;this.away.id=A.data.AwayTeamID;this.matchRecord=A;this.matchRecord.data.currentMinute=-1;if(A.data){this.addEventsInDs(A.data.events)
}GhamL.MatchModel.superclass.constructor.call(this);this.addEvents({goalEvent:true,attemptEvent:true,yellowCardEvent:true,redCardEvent:true,endOfMatchEvent:true,bestPlayerEvent:true,worstPlayerEvent:true,otherEvent:true,anyEvent:true,homeStarsLoaded:true,awayStarsLoaded:true,ratingsLoaded:true,homeStarsLoadedError:true,awayStarsLoadedError:true,ratingsLoadedError:true});
if(!this.isFinished()){this.home.goals=A.data.HomeGoals;this.away.goals=A.data.AwayGoals;this.matchRecord.set("result",this.home.goals+" - "+this.away.goals);
this.updateCurrentMinute(A.data.fetchedDate);this.ds.each(this.updateStatistics,this);this.on(endOfMatchEvent,function(){this.endOfMatchEventFired=true;
this.loadMatchStats()},this)}else{this.loadMatchStats()}this.endOfMatchEventFired=false;this.matchRecord.data.result=this.home.goals+" - "+this.away.goals;
this.matchRecord.data.attempts=this.home.attempts+" - "+this.away.attempts;this.updateCards();this.matchRecord.commit();this.matchTeams=this.matchRecord.data.HomeTeamName+" - "+this.matchRecord.data.AwayTeamName;
this.filteredTypes={};this.filteredTypes[goalEvent]=true;this.filteredTypes[attemptEvent]=true;this.filteredTypes[yellowCardEvent]=true;this.filteredTypes[redCardEvent]=true;
this.filteredTypes[bruisedEvent]=true;this.filteredTypes[injuryEvent]=true;this.filteredTypes["I"]=true};GhamL.MatchModel.isFormationEvent=function(A){return A.data.EventKey.indexOf("20_")===0
};GhamL.Team=function(){this.id=0;this.goals=0;this.attempts=0;this.yellows=0;this.reds=0};Ext.extend(GhamL.MatchModel,Ext.util.Observable,{getStarsDs:function(){return new Ext.data.GroupingStore({proxy:new Ext.data.HttpProxy({url:"getMatchLineup.php"}),reader:new Ext.data.XmlReader({record:"Player",id:"RoleID",loadPosition:true},[{name:"PlayerID",type:"int"},{name:"RoleID",type:"int"},"PlayerName",{name:"RatingStars",type:"float"},{name:"PositionCode",type:"int"},{name:"Behaviour",type:"int"},{name:"PositionGroup"}]),sortInfo:{field:"PositionCode"},groupField:"PositionGroup"})
},filterPlayers:function(C,D,B){if(D.getCount()){D.each(function(E){if(E.data.PositionCode==null||E.data.PositionCode==""){E.data.PositionCode=100}var F=E.data.PositionCode;
if(F>=0&&F<=5){E.data.PositionGroup="1"}else{if(F>=6&&F<=9){E.data.PositionGroup="2"}else{if(F>=10&&F<=11){E.data.PositionGroup="3"}else{F=E.data.RoleID;
if(F>=12&&F<=16){E.data.PositionGroup="5"}else{if(F>=19&&F<=21){E.data.PositionGroup="4"}}}}}});var A=D.getById(17);if(A){D.remove(A)}A=D.getById(18);if(A){D.remove(A)
}this.fireEvent(B,D)}else{this.fireEvent(B+"Error",D)}C.execute()},loadDsStars:function(B,C,D){var A={callbacks:B,dontShowErrors:true};A.params={matchId:this.getId(),teamId:D};
GhamL.connection.manager.loadStore(C,A)},loadMatchDetails:function(B){var A={callbacks:B,url:"getMatchDetails.php",params:{matchId:this.getId()},dontShowErrors:true};
GhamL.connection.manager.ajaxRequest(A)},parseMatchDetails:function(C,D){var A=["RatingMidfield","RatingRightDef","RatingMidDef","RatingLeftDef","RatingRightAtt","RatingMidAtt","RatingLeftAtt"];
var B=D.responseXML;if(B&&B.documentElement&&B.documentElement.nodeName!="parsererror"){function F(H,G){G.ratings=[];var J=0;function I(K){G.ratings[J++]=parseInt(Ext.DomQuery.selectValue(H+" "+K,B))
}Ext.each(A,I)}this.arenaName=Ext.DomQuery.selectValue("ArenaName",B);this.weatherID=Ext.DomQuery.selectValue("WeatherID",B);this.soldTotal=Ext.DomQuery.selectValue("SoldTotal",B);
this.possessionFirstHalfHome=parseInt(Ext.DomQuery.selectValue("PossessionFirstHalfHome",B));this.possessionSecondHalfHome=parseInt(Ext.DomQuery.selectValue("PossessionSecondHalfHome",B));
F("HomeTeam",this.home);F("AwayTeam",this.away);this.ratingsDs=new Ext.data.GroupingStore({reader:new Ext.data.XmlReader({},[{name:"homePos"},{name:"homeRat",type:"int"},{name:"awayRat",type:"int"},{name:"awayPos"},{name:"group",type:"int"},{name:"perc",type:"int"}]),groupField:"group",sortInfo:{field:"group",direction:"ASC"}});
function E(H,G){return(H/(H+G))*100}this.ratingsDs.add(new Ext.data.Record({homePos:"Midfield",homeRat:this.home.ratings[0],awayRat:this.away.ratings[0],awayPos:"Midfield",group:0,perc:E(this.home.ratings[0],this.away.ratings[0])}));
Ext.each(A,function(I,J){if(J){var H=this.home.ratings[J];var G=this.away.ratings[7-J];this.ratingsDs.add(new Ext.data.Record({homePos:I.substring(6,I.length-3),homeRat:H,awayRat:G,awayPos:A[7-J].substring(6,A[7-J].length-3),group:Math.floor((J-1)/3)+1,perc:E(H,G)}))
}},this);this.fireEvent("ratingsLoaded",this)}else{this.fireEvent("ratingsLoadedError",this)}C.execute()},loadMatchStats:function(C,A){this.homeStarsDs=this.getStarsDs();
this.awayStarsDs=this.getStarsDs();var B=new GhamL.Callbacks([{callback:this.loadDsStars,scope:this,args:[this.homeStarsDs,this.home.id]},{callback:this.filterPlayers,scope:this,args:[this.homeStarsDs,"homeStarsLoaded"]},{callback:this.loadDsStars,scope:this,args:[this.awayStarsDs,this.away.id]},{callback:this.filterPlayers,scope:this,args:[this.awayStarsDs,"awayStarsLoaded"]},{callback:this.loadMatchDetails,scope:this},{callback:this.parseMatchDetails,scope:this},{callback:C,scope:A}]);
B.execute()},reloadRatings:function(C,A){var B=new GhamL.Callbacks([{callback:this.loadMatchDetails,scope:this},{callback:this.parseMatchDetails,scope:this},{callback:C,scope:A}]);
B.execute()},reloadHomeStars:function(C,A){this.homeStarsDs=this.getStarsDs();var B=new GhamL.Callbacks([{callback:this.loadDsStars,scope:this,args:[this.homeStarsDs,this.home.id]},{callback:this.filterPlayers,scope:this,args:[this.homeStarsDs,"homeStarsLoaded"]},{callback:C,scope:A}]);
B.execute()},reloadAwayStars:function(C,A){this.awayStarsDs=this.getStarsDs();var B=new GhamL.Callbacks([{callback:this.loadDsStars,scope:this,args:[this.awayStarsDs,this.away.id]},{callback:this.filterPlayers,scope:this,args:[this.awayStarsDs,"awayStarsLoaded"]},{callback:C,scope:A}]);
B.execute()},filterByEvents:function(A){if(A.data.Minute>this.getCurrentMinute()){return false}if(this.filteredTypes[A.data.Type]){return true}if(this.filteredTypes[informationEvent]){return GhamL.events.isInformationEvents(A.data.Type)
}return false},updateGroup:function(A,B){if(B){this.ds.groupBy(this.groupField)}else{this.ds.clearGrouping()}},filterEvents:function(B,A){this.filteredTypes[B.eventType]=A;
this.ds.filterBy(this.filterByEvents,this)},getPlayerTooltip:function(D){var B={};this.ds.each(function(E){if(E.data.SubjectPlayerID==D){B[E.data.Type]=(B[E.data.Type]||0)+1
}});var C=GhamL.msg.Id+": "+D;Ext.each(GhamL.events.eventsForTooltipOrder,function(E){if(B[E]){C+="<br>"+GhamL.events.labelsTooltip[E];if(!GhamL.events.eventsNoNumber[E]){C+=": "+B[E]
}}});if(this.endOfMatchEventFired&&this.homeStarsDs){var A;this.homeStarsDs.each(function(E){if(E.data.PlayerID==D){A=E.data.RatingStars;return false}});
if(A===undefined&&this.awayStarsDs){this.awayStarsDs.each(function(E){if(E.data.PlayerID==D){A=E.data.RatingStars;return false}})}C+="<br>"+GhamL.MatchStars.starsRenderer(A)
}return C},updateRelive:function(){this.matchRecord.set("currentMinute",this.getCurrentMinute()+1);this.matchRecord.commit();var A=[];this.ds.filterBy(function(B){if(B.data.Minute==this.getCurrentMinute()){A.push(B);
this.updateResult([B]);this.updateStatistics(B)}return this.filterByEvents(B)},this);this.fireEvents(A)},updateReliveBot:function(){this.matchRecord.set("currentMinute",this.getCurrentMinute()+1);
this.home.goals=this.matchRecord.data.HomeGoals;this.away.goals=this.matchRecord.data.AwayGoals;this.matchRecord.set("result",this.home.goals+" - "+this.away.goals);
this.matchRecord.commit()},addMatchEvents:function(A){var B=this.addEventsInDs(A.events);this.home.goals=A.HomeGoals;this.away.goals=A.AwayGoals;this.updateResultString();
this.updateStatisticsArray(B);this.fireEvents(B)},updateCurrentMinuteLive:function(A){if(this.updateCurrentMinute(A)){this.matchRecord.commit();this.fireEvent(minuteEvent,[],this,this.getCurrentMinute())
}},calculateMinute:function(D){D=D/60000;if(D>-60){if(D<=45){return D+1}if(D<=60){return 45}return D-14}else{var B=-D;var A=B%60;B=Math.floor(B/60);var C=B%24;
var E=Math.floor(B/24);return"-"+(E>0?E+"d":"")+C+"h"+A+"m"}},updateCurrentMinute:function(A){var C=this.parseDate(this.matchRecord.data.MatchDate);var B=this.parseDate(A);
var D=B-C;var E=this.calculateMinute(D);if(E!=this.matchRecord.data.currentMinute){this.matchRecord.set("currentMinute",E);return true}else{return false
}},parseFormation:function(A){return A.ObjectPlayerID.substring(2,3)+A.ObjectPlayerID.substring(4,5)+A.ObjectPlayerID.substring(6,7)},addEventsInDs:function(E){var D=[];
if(E){var B=E.length;for(var C=0;C<B;C++){var F=E[C];if(!this.ds.getById(F.Index)){var A=GhamL.events.createEventRecord(F,this.getId());if(A){if(GhamL.MatchModel.isFormationEvent(A)){if(this.home.id==F.SubjectTeamID){this.home.formation=this.parseFormation(F)
}else{this.away.formation=this.parseFormation(F)}}else{D.push(A)}}}}if(D.length>0){this.ds.add(D)}}return D},updateResult:function(C){if(C){var A=C.length;
for(var B=0;B<A;B++){var D=C[B];if(D.data.Type==goalEvent){if(D.data.SubjectTeamID==this.home.id){this.home.goals++}else{this.away.goals++}}}this.updateResultString()
}},updateResultString:function(){var A=this.home.goals+" - "+this.away.goals;if(this.matchRecord.data.result!=A){this.matchRecord.set("result",A)}},updateStatisticsArray:function(C){if(C){var A=C.length;
for(var B=0;B<A;B++){this.updateStatistics(C[B])}}},updateStatistics:function(A){if(A.data.Type==goalEvent||A.data.Type==attemptEvent){if(A.data.SubjectTeamID==this.home.id){this.home.attempts++
}else{this.away.attempts++}this.matchRecord.set("attempts",this.home.attempts+" - "+this.away.attempts)}else{if(A.data.Type==yellowCardEvent){if(A.data.SubjectTeamID==this.home.id){this.home.yellows++
}else{this.away.yellows++}this.updateCards()}else{if(A.data.Type==redCardEvent){if(A.data.SubjectTeamID==this.home.id){this.home.reds++}else{this.away.reds++
}this.updateCards()}}}},updateCards:function(){this.matchRecord.set("cards",this.home.yellows+"/"+this.home.reds+"-"+this.away.yellows+"/"+this.away.reds)
},parseDate:function(A){if(A){return new Date(A.substring(0,4),parseFloat(A.substring(5,7))-1,A.substring(8,10),A.substring(11,13),A.substring(14,16),0,0)
}return""},fireEvents:function(F){var C=F.length;var D={};for(var E=0;E<C;E++){var G=F[E];var A=D[G.data.Type];if(!A){A=[];D[G.data.Type]=A}A.push(G)}for(var B in D){this.endOfMatchEventFired=this.endOfMatchEventFired||B==endOfMatchEvent;
this.fireEvent(B,D[B],this)}if(F.length>0){this.fireEvent(anyEvent,F,this)}this.fireEvent(minuteEvent,F,this,this.getCurrentMinute())},getId:function(){return this.matchRecord.id
},getCurrentMinute:function(){return this.matchRecord.data.currentMinute},getResult:function(){return this.matchRecord.data.result},getMatchTitle:function(){return this.matchTeams+" "+this.getResult()+" ["+this.getCurrentMinute()+"]"
},getMatchTitleShort:function(){return this.matchTeams+" "+this.getResult()},getEvents:function(){return this.matchRecord.data.events},isFinished:function(){var B=this.getEvents();
if(B&&B.length>0){var A=B[B.length-1];return A.EventKey.substring(0,3)==599}return false},isBotMatch:function(){var B=this.getEvents();if(B&&B.length>0){var A=B[B.length-1];
return A.Minute===0&&A.EventKey.substring(0,3)==599}return false}});Ext.namespace("GhamL");GhamL.MatchStars=function(B){function E(F){return F&&GhamL.MatchStars.positions[F]
}function D(F){return GhamL.MatchStars.positionGroup[F]}function C(F){return GhamL.MatchStars.behaviour[F]}var A=new Ext.grid.ColumnModel([{header:GhamL.msg.Player,dataIndex:"PlayerName",width:120,sortable:true,id:"nameCol"},{header:GhamL.msg.Stars,dataIndex:"RatingStars",width:100,align:"center",sortable:true,summaryType:"sum",renderer:GhamL.MatchStars.starsRenderer},{header:GhamL.msg.Position,dataIndex:"PositionCode",width:100,align:"center",sortable:true,renderer:E},{header:GhamL.msg.Behaviour,dataIndex:"Behaviour",align:"center",width:120,sortable:true,renderer:C},{header:GhamL.msg.Position_group,dataIndex:"PositionGroup",align:"center",width:100,sortable:true,renderer:D}]);
B.sort("PositionCode","ASC");this.grid=new Ext.grid.GridPanel({ds:B,cm:A,selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),stripeRows:true,autoExpandColumn:"nameCol",view:new Ext.grid.GroupingView({showGroupName:false,hideGroupedColumn:true,groupTextTpl:"{text} {[somma(values.rs)]}"})});
GhamL.MatchStars.superclass.constructor.call(this,{items:[this.grid],layout:"fit"})};Ext.extend(GhamL.MatchStars,Ext.Panel,{});GhamL.MatchStars.starsRenderer=function(D){if(D){var C="";
for(var B=5;B<=D;B+=5){C+='<img src="icons/star_big_yellow.png" ext:qtip="'+D+" "+GhamL.msg.Stars+'">'}var A=Math.floor(D%5);for(var B=0;B<A;B++){C+='<img src="icons/star_yellow.png" ext:qtip="'+D+" "+GhamL.msg.Stars+'">'
}if((D*10)%10!=0){C+='<img src="icons/star_half_yellow.png" ext:qtip="'+D+" "+GhamL.msg.Stars+'">'}return C}return""};GhamL.MatchStars.positions={1:GhamL.msg.Keeper,2:GhamL.msg.Right_back,3:GhamL.msg.Central_defender,4:GhamL.msg.Central_defender,5:GhamL.msg.Left_Back,6:GhamL.msg.Right_winger,7:GhamL.msg.Inner_midfield,8:GhamL.msg.Inner_midfield,9:GhamL.msg.Left_winger,10:GhamL.msg.Forward,11:GhamL.msg.Forward};
GhamL.MatchStars.behaviour={1:GhamL.msg.Offensive,2:GhamL.msg.Defensive,3:GhamL.msg.Towards_Middle,4:GhamL.msg.Towards_Wing};GhamL.MatchStars.positionGroup={1:GhamL.msg.Defence,2:GhamL.msg.Midfield,3:GhamL.msg.Forwards,5:GhamL.msg.Substitutions,4:GhamL.msg.Replaceds};
function somma(B){var A=0;Ext.each(B,function(C){A+=C.data.RatingStars});if(A){return GhamL.msg.Stars+": "+A}return""}Ext.namespace("GhamL");GhamL.MatchesUpdater=function(){GhamL.MatchesUpdater.superclass.constructor.call(this)
};Ext.extend(GhamL.MatchesUpdater,Ext.util.Observable,{matchesToUpdate:new Ext.util.MixedCollection(),matchesRelive:new Ext.util.MixedCollection(),matchesEnded:new Ext.util.MixedCollection(),idUpdate:undefined,idRelive:undefined,optionPanel:undefined,matchNotifiers:[],registerMatch:function(A,B){var D=false;
var C=false;if(!A.isFinished()){this.matchesToUpdate.add(A.getId(),A);Ext.each(this.matchNotifiers,function(E){E.addLiveMatch(A)});D=true}else{if(!A.isBotMatch()){this.matchesRelive.add(A.getId(),A);
A.updateRelive();Ext.each(this.matchNotifiers,function(E){E.addReliveMatch(A)});C=true}else{this.matchesEnded.add(A.getId(),A);A.updateReliveBot()}}A.on(endOfMatchEvent,function(E,F){this.removeMatch(F.getId())
},this);if(D&&!this.idUpdate){this.idUpdate=setInterval(this.refreshFromServer.createDelegate(this,[]),30000,this)}if(!B&&C){this.startRelive()}},removeMatch:function(B){B=""+B;
var A=this.matchesRelive.get(B);if(A){this.matchesRelive.removeKey(B);if(this.matchesRelive.length===0){this.stopRelive();liveButtons.relive.noMoreMatches()
}this.matchesEnded.add(B,A)}else{A=this.matchesToUpdate.get(B);if(A){this.matchesToUpdate.removeKey(B);if(this.matchesToUpdate.length===0){clearInterval(this.idUpdate);
this.idUpdate=null}this.matchesEnded.add(B,A)}else{A=this.matchesEnded.get(B);this.matchesEnded.removeKey(B)}}},startRelive:function(){if(!this.idRelive&&this.matchesRelive.getCount()>0){var A=this.matchesRelive;
this.idRelive=setInterval(function(){A.each(function(B){B.updateRelive()})},this.optionPanel.getReliveSpeed());liveButtons.relive.afterStart()}},stopRelive:function(A){clearInterval(this.idRelive);
this.idRelive=null;if(!A){liveButtons.relive.afterStop()}},refreshReliveSpeed:function(){this.stopRelive(true);this.startRelive()},refreshList:function(B){var A=Ext.decode(B.responseText);
this.matchesToUpdate.each(function(E){var C=A[E.getId()];var D=C.EVENT;E.addMatchEvents(D,C)})},startStopRelive:function(){if(this.idRelive){this.stopRelive()
}else{this.startRelive()}},getMatchModel:function(B){var A=this.matchesToUpdate.get(B);if(A){return A}A=this.matchesEnded.get(B);if(A){return A}return this.matchesRelive.get(B)
},getDsMatchesTmp:function(A){return new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:(A?"addMatch.php":"refreshMatches.php")}),reader:new GhamL.utils.XmlReaderExt({record:"Match",id:"MatchID",loadPosition:false},["MatchID","MatchDate","HomeTeamID","AwayTeamID","HomeTeamName","AwayTeamName","HomeGoals","AwayGoals",{name:"fetchedDate",mapping:function(B){return Ext.DomQuery.selectValue("FetchedDate",B.ownerDocument)
}},{name:"events",mapping:function(F){var B=Ext.DomQuery.select("EventList > Event",F);var C=[];for(var E=0;E<B.length;E++){var D=B[E];C[E]={};C[E].Minute=Ext.DomQuery.selectValue("Minute",D);
C[E].SubjectPlayerID=Ext.DomQuery.selectValue("SubjectPlayerID",D);C[E].SubjectTeamID=Ext.DomQuery.selectValue("SubjectTeamID",D);C[E].ObjectPlayerID=Ext.DomQuery.selectValue("ObjectPlayerID",D);
C[E].EventKey=Ext.DomQuery.selectValue("EventKey",D);C[E].EventText=Ext.DomQuery.selectValue("EventText",D);C[E].Index=D.attributes[0].value}return C}}])})
},currentRequest:0,maxNumberOfViewNewRequest:20,refreshFromServer:function(H,B,D,F,E){var C=this.getDsMatchesTmp(H);var G={};if(H){G.matchId=H;if(!D){Ext.MessageBox.progress(GhamL.msg.Downloading,GhamL.msg.Downloading_match)
}this.currentRequest=0}else{if(this.currentRequest===0){this.currentRequest=this.maxNumberOfViewNewRequest}else{G.viewNew=true;this.currentRequest--}}function A(J,L){var I=Ext.DomQuery.selectValue("FetchedDate",C.reader.xmlData);
this.matchesToUpdate.each(function(M){M.updateCurrentMinuteLive(I)});var K=false;C.each(function(N){var M;if(!GhamL.layout.gridMatches.getStore().getById(N.id)){N.data.matchTitle=E||GhamL.msg.Cup_Friendly;
M=new GhamL.MatchModel(N);var O=new GhamL.MatchDetail(M);matchDetails[N.id]=O;portal.addPortlet(O);this.registerMatch(M,B);GhamL.layout.gridMatches.getStore().add(N);
K=true}else{M=this.matchesToUpdate.get(N.id);if(M){M.addMatchEvents(N.data)}}if(M&&M.isFinished()){Ext.Ajax.request({url:"deleteMatch.php",params:{"matchId":N.id}})
}},this);if(F){F()}if(!D){if(K){matchesTab.activate("matchesAndLeague")}Ext.MessageBox.hide()}}GhamL.connection.manager.loadStore(C,{params:G,successFunction:A,successScope:this,failureFunction:function(){this.currentRequest=0
},failureScope:this})}});Ext.namespace("GhamL");GhamL.TreeTeamMatches=function(){GhamL.TreeTeamMatches.superclass.constructor.call(this,{region:"center",autoScroll:true,animate:false,rootVisible:false,containerScroll:true,enableDD:true,dropConfig:{appendOnly:true},root:new Ext.tree.TreeNode({})});
Ext.override(Ext.tree.TreeNodeUI,{onDblClick:Ext.emptyFn});this.yourMatchesNode=new Ext.tree.TreeNode({text:GhamL.msg.Your_matches,expanded:true});this.getRootNode().appendChild(this.yourMatchesNode);
this.friendsNode=new Ext.tree.TreeNode({text:GhamL.msg.Friends_matches+"&nbsp;&nbsp;&nbsp;"+GhamL.utils.createToolsButton("plus","GhamL.friendManager.addFriend()",'ext:qtip="'+GhamL.msg.Add_new_friends+'"')});
this.getRootNode().appendChild(this.friendsNode);this.getSelectionModel().on("selectionchange",function(A,B){if(B&&B.matchDate){GhamL.calendar.setValue(B.matchDate);
Ext.get("matchTimeId").update(B.matchDate.format("H:i"))}});this.fixturesMap={}};Ext.extend(GhamL.TreeTeamMatches,Ext.tree.TreePanel,{yourMatchesNode:undefined,friendsNode:undefined,fixturesMap:null,loadMatchTree:function(F,G,A,B,C){B=B||this.yourMatchesNode;
var E=this.fixturesMap[C];if(E){this.loadMatchTreeCallBack(E,B,F,G,A)}else{E=this.getFixturesListDs();var D={successScope:this,successFunction:this.loadMatchTreeCallBack.createDelegate(this,[E,B,F,G,A])};
if(C){D.params={leagueId:C}}GhamL.connection.manager.loadStore(E,D)}},loadMatchTreeCallBack:function(D,F,E,H,K){var B=Ext.DomQuery.selectValue("LeagueLevelUnitName",D.reader.xmlData)||GhamL.msg.League;
var G=Ext.DomQuery.selectValue("LeagueLevelUnitID",D.reader.xmlData);this.fixturesMap[G]=D;if(E&&E.getCount()>0){var I={};var J={};D.each(function(L){var N=L.data;
var M=N.MatchRound;I[N.MatchID]=M;var O=J[M];if(!O){O=[];J[M]=O}O.push(N)});var C;E.each(function(L){if(L.data.Status!="FINISHED"){C=L;return false}});
var A;E.each(function(T){var Q=T.data;var V;if(T==C){V=function(W){return"<b>"+W+"</b>"}}else{V=function(W){return W}}if(Q.MatchType==1){var M=null;if(I){M=I[Q.MatchID]
}if(M){var U=J[M];var O=G+"_r_"+M;var S=new Ext.tree.TreeNode({id:O,text:V(B+" Round "+M+"&nbsp;&nbsp;"+GhamL.utils.createToolsButton("search","GhamL.treeTeamMatches.onRoundDblClick(null, '"+O+"')",'ext:qtip="'+GhamL.msg.Add_league_round_tooltip+'"'))});
if(T==C){A=S}S.matches=[];S.leagueName=B;S.matchRound=M;S.fixtures=D;S.matchDate=this.parseMatchDate(U[0].MatchDate);S.getUI().onDblClick=this.onRoundDblClick;
for(var R=0;R<U.length;R++){var L=U[R];var P=this.creaNodoPartita(L,V);S.appendChild(P);S.matches.push(L.MatchID)}F.appendChild(S)}else{var N=this.creaNodoPartita(Q,V);
F.appendChild(N);if(T==C){A=N}}}else{var N=this.creaNodoPartita(Q,V);F.appendChild(N);if(T==C){A=N}}},this);if(A){this.getSelectionModel().select(A);A.ensureVisible()
}}if(H){H.apply(K||this,[D,G,B])}Ext.Msg.hide()},addLeagueTable:function(E,D,B,F){var A=new GhamL.LeagueTable(E,D,B,F);A.region="south";A.initialSize=210;
var C=matchesCont;A=C.add(A);A.show();if(matchesCont.getSize().height===0){matchesCont.setHeight(200)}matchesCont.show();C.doLayout();matchesCont2.doLayout()
},getSelectedNode:function(A){if(A){return GhamL.treeTeamMatches.getNodeById(A)}else{return GhamL.treeTeamMatches.getSelectionModel().getSelectedNode()
}},onRoundDblClick:function(C,F){Ext.MessageBox.progress(GhamL.msg.Downloading,GhamL.msg.Downloading_matches);var D=GhamL.treeTeamMatches.getSelectedNode(F);
var G=D.matches;var A=matchesUpdater.matchesRelive.getCount();var E=GhamL.msg.Downloading_match+" ";Ext.MessageBox.updateProgress(0,E+G[0]);var B=D.leagueName+" "+GhamL.msg.Round+" "+D.matchRound;
matchesUpdater.refreshFromServer(G[0],true,true,function(){Ext.MessageBox.updateProgress(0.25,E+G[1]);matchesUpdater.refreshFromServer(G[1],true,true,function(){Ext.MessageBox.updateProgress(0.5,E+G[2]);
matchesUpdater.refreshFromServer(G[2],true,true,function(){Ext.MessageBox.updateProgress(0.75,E+G[3]);matchesUpdater.refreshFromServer(G[3],true,true,function(){matchesTab.activate("matchesAndLeague");
var H=[matchesUpdater.getMatchModel(G[0]),matchesUpdater.getMatchModel(G[1]),matchesUpdater.getMatchModel(G[2]),matchesUpdater.getMatchModel(G[3])];GhamL.treeTeamMatches.addLeagueTable(D.leagueName,D.fixtures,D.matchRound,H);
if(A!=matchesUpdater.matchesRelive.getCount()){matchesUpdater.startRelive()}Ext.MessageBox.hide()},B)},B)},B)},B)},creaNodoPartita:function(C,A){var D=C.HomeTeamName+" - "+C.AwayTeamName;
var F=C.MatchID;var E=new Ext.tree.TreeNode({id:F,text:A(D+"&nbsp;&nbsp;"+GhamL.utils.createToolsButton("search","GhamL.treeTeamMatches.onMatchClick(null, '"+F+"')",'ext:qtip="'+GhamL.msg.Add_match_tooltip+'"'))});
E.matchDate=this.parseMatchDate(C.MatchDate);var B=this.getSelectionModel();E.getUI().onDblClick=this.onMatchClick;return E},parseMatchDate:function(A){return Date.parseDate(A,"Y-m-d h:i:s")
},onMatchClick:function(A,C){var B=GhamL.treeTeamMatches.getSelectedNode(C);var D=B.id;matchesUpdater.refreshFromServer(D,false,false,function(){matchesTab.activate("matchesAndLeague")
})},getFixturesListDs:function(){return new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:"fixtures.php"}),reader:new Ext.data.XmlReader({record:"Match",id:"MatchID",loadPosition:false},["MatchID","MatchDate","HomeTeamID","AwayTeamID","HomeTeamName","AwayTeamName","HomeGoals","AwayGoals","MatchRound"])})
}});function SoundManager(B,A){var C=this;this.version="V2.0b.20070415";this.url=(B||"soundmanager2.swf");this.debugMode=false;this.useConsole=true;this.consoleOnly=false;
this.nullURL="data/null.mp3";this.defaultOptions={"autoLoad":false,"stream":true,"autoPlay":false,"onid3":null,"onload":null,"whileloading":null,"onplay":null,"whileplaying":null,"onstop":null,"onfinish":null,"onbeforefinish":null,"onbeforefinishtime":5000,"onbeforefinishcomplete":null,"onjustbeforefinish":null,"onjustbeforefinishtime":200,"multiShot":true,"pan":0,"volume":100};
this.allowPolling=true;this.enabled=false;this.o=null;this.id=(A||"sm2movie");this.oMC=null;this.sounds=[];this.soundIDs=[];this.isIE=(navigator.userAgent.match(/MSIE/));
this.isSafari=(navigator.userAgent.match(/safari/i));this.debugID="soundmanager-debug";this._debugOpen=true;this._didAppend=false;this._appendSuccess=false;
this._didInit=false;this._disabled=false;this._hasConsole=(typeof console!="undefined"&&typeof console.log!="undefined");this._debugLevels=!C.isSafari?["debug","info","warn","error"]:["log","log","log","log"];
this.getMovie=function(D){return C.isIE?window[D]:(C.isSafari?document[D+"-embed"]:document.getElementById(D+"-embed"))};this.loadFromXML=function(D){try{C.o._loadFromXML(D)
}catch(E){C._failSafely();return true}};this.createSound=function(D){if(!C._didInit){throw new Error("soundManager.createSound(): Not loaded yet - wait for soundManager.onload() before calling sound-related methods")
}if(arguments.length==2){D={"id":arguments[0],"url":arguments[1]}}var E=C._mergeObjects(D);C._writeDebug('soundManager.createSound(): "<a href="#" onclick="soundManager.play(\''+E.id+'\');return false" title="play this sound">'+E.id+'</a>" ('+E.url+")",1);
if(C._idCheck(E.id,true)){C._writeDebug("sound "+E.id+" already defined - exiting",2);return false}C.sounds[E.id]=new SMSound(C,E);C.soundIDs[C.soundIDs.length]=E.id;
try{C.o._createSound(E.id,E.onjustbeforefinishtime)}catch(F){C._failSafely();return true}if(E.autoLoad||E.autoPlay){C.sounds[E.id].load(E)}if(E.autoPlay){C.sounds[E.id].playState=1
}};this.destroySound=function(D){if(!C._idCheck(D)){return false}for(var E=C.soundIDs.length;E--;){if(C.soundIDs[E]==D){delete C.soundIDs[E];continue}}C.sounds[D].unload();
delete C.sounds[D]};this.load=function(D,E){if(!C._idCheck(D)){return false}C.sounds[D].load(E)};this.unload=function(D){if(!C._idCheck(D)){return false
}C.sounds[D].unload()};this.play=function(D,E){if(!C._idCheck(D)){if(typeof E!="Object"){E={url:E}}if(E&&E.url){C._writeDebug('soundController.play(): attempting to create "'+D+'"',1);
E.id=D;C.createSound(E)}else{return false}}C.sounds[D].play(E)};this.start=this.play;this.setPosition=function(D,E){if(!C._idCheck(D)){return false}C.sounds[D].setPosition(E)
};this.stop=function(D){if(!C._idCheck(D)){return false}C._writeDebug("soundManager.stop("+D+")",1);C.sounds[D].stop()};this.stopAll=function(){C._writeDebug("soundManager.stopAll()",1);
for(var D in C.sounds){if(C.sounds[D] instanceof SMSound){C.sounds[D].stop()}}};this.pause=function(D){if(!C._idCheck(D)){return false}C.sounds[D].pause()
};this.resume=function(D){if(!C._idCheck(D)){return false}C.sounds[D].resume()};this.togglePause=function(D){if(!C._idCheck(D)){return false}C.sounds[D].togglePause()
};this.setPan=function(D,E){if(!C._idCheck(D)){return false}C.sounds[D].setPan(E)};this.setVolume=function(E,D){if(!C._idCheck(E)){return false}C.sounds[E].setVolume(D)
};this.setPolling=function(D){if(!C.o||!C.allowPolling){return false}C._writeDebug("soundManager.setPolling("+D+")");C.o._setPolling(D)};this.disable=function(){if(C._disabled){return false
}C._disabled=true;C._writeDebug("soundManager.disable(): Disabling all functions - future calls will return false.",1);for(var D=C.soundIDs.length;D--;
){C._disableObject(C.sounds[C.soundIDs[D]])}C.initComplete();C._disableObject(C)};this.getSoundById=function(E,F){if(!E){throw new Error("SoundManager.getSoundById(): sID is null/undefined")
}var D=C.sounds[E];if(!D&&!F){C._writeDebug('"'+E+'" is an invalid sound ID.',2)}return D};this.onload=function(){soundManager._writeDebug("<em>Warning</em>: soundManager.onload() is undefined.",2)
};this.onerror=function(){};this._idCheck=this.getSoundById;this._disableObject=function(E){for(var D in E){if(typeof E[D]=="function"&&typeof E[D]._protected=="undefined"){E[D]=function(){return false
}}}D=null};this._failSafely=function(){var F="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html";var G="You may need to whitelist this location/domain eg. file:///C:/ or C:/ or mysite.com, or set ALWAYS ALLOW under the Flash Player Global Security Settings page. Note that this seems to apply only to file system viewing.";
var E='<a href="'+F+'" title="'+G+'">view/edit</a>';var D='<a href="'+F+'" title="Flash Player Global Security Settings">FPGSS</a>';if(!C._disabled){C._writeDebug("soundManager: JS-&gt;Flash communication failed. Possible causes: flash/browser security restrictions ("+E+"), insufficient browser/plugin support, or .swf not found",2);
C._writeDebug("Verify that the movie path of <em>"+C.url+'</em> is correct (<a href="'+C.url+'" title="If you get a 404/not found, fix it!">test link</a>)',1);
if(C._didAppend){if(!document.domain){C._writeDebug("Loading from local file system? (document.domain appears to be null, this URL path may need to be added to 'trusted locations' in "+D+")",1);
C._writeDebug("Possible security/domain restrictions ("+E+"), should work when served by http on same domain",1)}}C.disable()}};this._createMovie=function(F,E){if(C._didAppend&&C._appendSuccess){return false
}if(window.location.href.indexOf("debug=1")+1){C.debugMode=true}C._didAppend=true;var J=['<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="16" height="16" id="'+F+'"><param name="movie" value="'+E+'"><param name="quality" value="high"><param name="allowScriptAccess" value="always" /></object>','<embed name="'+F+'-embed" id="'+F+'-embed" src="'+E+'" width="1" height="1" quality="high" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>'];
var M='<div id="'+C.debugID+'-toggle" style="position:fixed;_position:absolute;right:0px;bottom:0px;_top:0px;width:1.2em;height:1.2em;line-height:1.2em;margin:2px;padding:0px;text-align:center;border:1px solid #999;cursor:pointer;background:#fff;color:#333;z-index:706" title="Toggle SM2 debug console" onclick="soundManager._toggleDebug()">-</div>';
var K='<div id="'+C.debugID+'" style="display:'+(C.debugMode&&((!C._hasConsole||!C.useConsole)||(C.useConsole&&C._hasConsole&&!C.consoleOnly))?"block":"none")+';opacity:0.85"></div>';
var I="soundManager._createMovie(): appendChild/innerHTML set failed. Serving application/xhtml+xml MIME type? Browser may be enforcing strict rules, not allowing write to innerHTML. (PS: If so, this means your commitment to XML validation is going to break stuff now, because this part isn't finished yet. ;))";
var G='<div style="position:absolute;left:-256px;top:-256px;width:1px;height:1px" class="movieContainer">'+J[C.isIE?0:1]+"</div>"+(C.debugMode&&((!C._hasConsole||!C.useConsole)||(C.useConsole&&C._hasConsole&&!C.consoleOnly))&&!document.getElementById(C.debugID)?"x"+K+M:"");
var D=(document.body?document.body:document.getElementsByTagName("div")[0]);if(D){C.oMC=document.createElement("div");C.oMC.className="movieContainer";
C.oMC.style.position="absolute";C.oMC.style.left="-256px";C.oMC.style.width="1px";C.oMC.style.height="1px";try{D.appendChild(C.oMC);C.oMC.innerHTML=J[C.isIE?0:1];
C._appendSuccess=true}catch(L){throw new Error(I)}if(!document.getElementById(C.debugID)&&((!C._hasConsole||!C.useConsole)||(C.useConsole&&C._hasConsole&&!C.consoleOnly))){var N=document.createElement("div");
N.id=C.debugID;N.style.display=(C.debugMode?"block":"none");if(C.debugMode){try{var H=document.createElement("div");D.appendChild(H);H.innerHTML=M}catch(L){throw new Error(I)
}}D.appendChild(N)}D=null}C._writeDebug("-- SoundManager 2 Version "+C.version.substr(1)+" --",1);C._writeDebug('soundManager._createMovie(): trying to load <a href="'+E+'" title="Test this link (404=bad)">'+E+"</a>",1)
};this._writeDebug=function(D,I){if(!C.debugMode){return false}if(C._hasConsole&&C.useConsole){console[C._debugLevels[I]||"log"](D);if(C.useConsoleOnly){return true
}}var H="soundmanager-debug";try{var G=document.getElementById(H);if(!G){return false}var F=document.createElement("div");F.innerHTML=D;G.insertBefore(F,G.firstChild)
}catch(E){}G=null};this._writeDebug._protected=true;this._writeDebugAlert=function(D){alert(D)};if(window.location.href.indexOf("debug=alert")+1){C.debugMode=true;
C._writeDebug=C._writeDebugAlert}this._toggleDebug=function(){var E=document.getElementById(C.debugID);var D=document.getElementById(C.debugID+"-toggle");
if(!E){return false}if(C._debugOpen){D.innerHTML="+";E.style.display="none"}else{D.innerHTML="-";E.style.display="block"}C._debugOpen=!C._debugOpen};this._toggleDebug._protected=true;
this._debug=function(){C._writeDebug("soundManager._debug(): sounds by id/url:",0);for(var E=0,D=C.soundIDs.length;E<D;E++){C._writeDebug(C.sounds[C.soundIDs[E]].sID+" | "+C.sounds[C.soundIDs[E]].url,0)
}};this._mergeObjects=function(E,D){var G=E;var F=(typeof D=="undefined"?C.defaultOptions:D);for(var H in F){if(typeof G[H]=="undefined"){G[H]=F[H]}}return G
};this.createMovie=function(D){if(D){C.url=D}C._initMovie()};this._initMovie=function(){if(C.o){return false}C.o=C.getMovie(C.id);if(!C.o){C._createMovie(C.id,C.url);
C.o=C.getMovie(C.id)}if(C.o){C._writeDebug("soundManager._initMovie(): Got "+C.o.nodeName+" element ("+(C._didAppend?"created via JS":"static HTML")+")",1)
}};this.initComplete=function(){if(C._didInit){return false}C._didInit=true;C._writeDebug("-- SoundManager 2 "+(C._disabled?"failed to load":"loaded")+" ("+(C._disabled?"security/load error":"OK")+") --",1);
if(C._disabled){C._writeDebug("soundManager.initComplete(): calling soundManager.onerror()",1);C.onerror.apply(window);return false}C._writeDebug("soundManager.initComplete(): calling soundManager.onload()",1);
try{C.onload.apply(window)}catch(D){C._writeDebug("soundManager.onload() threw an exception: "+D.message,2);throw D}C._writeDebug("soundManager.onload() complete",1)
};this.init=function(){if(window.removeEventListener){window.removeEventListener("load",C.beginInit,false)}else{if(window.detachEvent){window.detachEvent("onload",C.beginInit)
}}try{C.o._externalInterfaceTest();C._writeDebug("Flash ExternalInterface call (JS -&gt; Flash) succeeded.",1);if(!C.allowPolling){C._writeDebug("Polling (whileloading/whileplaying support) is disabled.",1)
}C.setPolling(true);C.enabled=true}catch(D){C._failSafely();C.initComplete();return false}C.initComplete()};this.beginDelayedInit=function(){setTimeout(C.beginInit,200)
};this.beginInit=function(){C.createMovie();C._initMovie();setTimeout(C.init,1000)};this.destruct=function(){if(C.isSafari){for(var D=C.soundIDs.length;
D--;){if(C.sounds[C.soundIDs[D]].readyState==1){C.sounds[C.soundIDs[D]].unload()}}}C.disable()}}function SMSound(C,B){var A=this;var D=C;this.sID=B.id;
this.url=B.url;this.options=D._mergeObjects(B);this.id3={};A.resetProperties=function(E){A.bytesLoaded=null;A.bytesTotal=null;A.position=null;A.duration=null;
A.durationEstimate=null;A.loaded=false;A.loadSuccess=null;A.playState=0;A.paused=false;A.readyState=0;A.didBeforeFinish=false;A.didJustBeforeFinish=false
};A.resetProperties();this.load=function(E){A.loaded=false;A.loadSuccess=null;A.readyState=1;A.playState=(E.autoPlay||false);var F=D._mergeObjects(E);if(typeof F.url=="undefined"){F.url=A.url
}try{D._writeDebug("loading "+F.url,1);D.o._load(A.sID,F.url,F.stream,F.autoPlay,F.whileloading?1:0)}catch(G){D._writeDebug("SMSound().load(): JS-&gt;Flash communication failed.",2)
}};this.unload=function(){D._writeDebug('SMSound().unload(): "'+A.sID+'"');A.setPosition(0);D.o._unload(A.sID,D.nullURL);A.resetProperties()};this.play=function(F){if(!F){F={}
}if(F.onfinish){A.options.onfinish=F.onfinish}if(F.onbeforefinish){A.options.onbeforefinish=F.onbeforefinish}if(F.onjustbeforefinish){A.options.onjustbeforefinish=F.onjustbeforefinish
}var G=D._mergeObjects(F);if(A.playState==1){var E=G.multiShot;if(!E){D._writeDebug('SMSound.play(): "'+A.sID+'" already playing? (one-shot)',1);return false
}else{D._writeDebug('SMSound.play(): "'+A.sID+'" already playing (multi-shot)',1)}}if(!A.loaded){if(A.readyState==0){D._writeDebug('SMSound.play(): .play() before load request. Attempting to load "'+A.sID+'"',1);
G.stream=true;G.autoPlay=true;A.load(G)}else{if(A.readyState==2){D._writeDebug('SMSound.play(): Could not load "'+A.sID+'" - exiting',2);return false}else{D._writeDebug('SMSound.play(): "'+A.sID+'" is loading - attempting to play..',1)
}}}else{D._writeDebug('SMSound.play(): "'+A.sID+'"')}if(A.paused){A.resume()}else{A.playState=1;A.position=(G.offset||0);if(G.onplay){G.onplay.apply(A)
}A.setVolume(G.volume);A.setPan(G.pan);if(!G.autoPlay){D.o._start(A.sID,G.loop||1,A.position)}}};this.start=this.play;this.stop=function(E){if(A.playState==1){A.playState=0;
A.paused=false;if(D.defaultOptions.onstop){D.defaultOptions.onstop.apply(A)}D.o._stop(A.sID)}};this.setPosition=function(E){D.o._setPosition(A.sID,E/1000,A.paused||!A.playState)
};this.pause=function(){if(A.paused){return false}D._writeDebug("SMSound.pause()");A.paused=true;D.o._pause(A.sID)};this.resume=function(){if(!A.paused){return false
}D._writeDebug("SMSound.resume()");A.paused=false;D.o._pause(A.sID)};this.togglePause=function(){D._writeDebug("SMSound.togglePause()");if(!A.playState){A.play({offset:A.position/1000});
return false}if(A.paused){D._writeDebug("SMSound.togglePause(): resuming..");A.resume()}else{D._writeDebug("SMSound.togglePause(): pausing..");A.pause()
}};this.setPan=function(E){if(typeof E=="undefined"){E=0}D.o._setPan(A.sID,E);A.options.pan=E};this.setVolume=function(E){if(typeof E=="undefined"){E=100
}D.o._setVolume(A.sID,E);A.options.volume=E};this._whileloading=function(E,F,G){A.bytesLoaded=E;A.bytesTotal=F;A.duration=G;A.durationEstimate=parseInt((A.bytesTotal/A.bytesLoaded)*A.duration);
if(A.readyState!=3&&A.options.whileloading){A.options.whileloading.apply(A)}};this._onid3=function(H,E){D._writeDebug('SMSound()._onid3(): "'+this.sID+'" ID3 data received.');
var I=[];for(var G=0,F=H.length;G<F;G++){I[H[G]]=E[G]}A.id3=D._mergeObjects(A.id3,I);if(A.options.onid3){A.options.onid3.apply(A)}};this._whileplaying=function(E){if(isNaN(E)||E==null){return false
}A.position=E;if(A.playState==1){if(A.options.whileplaying){A.options.whileplaying.apply(A)}if(A.loaded&&A.options.onbeforefinish&&A.options.onbeforefinishtime&&!A.didBeforeFinish&&A.duration-A.position<=A.options.onbeforefinishtime){D._writeDebug("duration-position &lt;= onbeforefinishtime: "+A.duration+" - "+A.position+" &lt= "+A.options.onbeforefinishtime+" ("+(A.duration-A.position)+")");
A._onbeforefinish()}}};this._onload=function(E){E=(E==1?true:false);D._writeDebug('SMSound._onload(): "'+A.sID+'"'+(E?" loaded.":' failed to load (or loaded from cache - weird bug) - [<a href="'+A.url+'">test URL</a>]'));
A.loaded=E;A.loadSuccess=E;A.readyState=E?3:2;if(A.options.onload){A.options.onload.apply(A)}};this._onbeforefinish=function(){if(!A.didBeforeFinish){A.didBeforeFinish=true;
if(A.options.onbeforefinish){A.options.onbeforefinish.apply(A)}}};this._onjustbeforefinish=function(E){if(!A.didJustBeforeFinish){A.didJustBeforeFinish=true;
if(A.options.onjustbeforefinish){A.options.onjustbeforefinish.apply(A)}}};this._onfinish=function(){D._writeDebug('SMSound._onfinish(): "'+A.sID+'"');A.playState=0;
A.paused=false;if(A.options.onfinish){A.options.onfinish.apply(A)}if(A.options.onbeforefinishcomplete){A.options.onbeforefinishcomplete.apply(A)}A.setPosition(0);
A.didBeforeFinish=false;A.didJustBeforeFinish=false}}var soundManager=new SoundManager();if(window.addEventListener){window.addEventListener("load",soundManager.beginDelayedInit,false);
window.addEventListener("beforeunload",soundManager.destruct,false)}else{if(window.attachEvent){window.attachEvent("onload",soundManager.beginInit);window.attachEvent("beforeunload",soundManager.destruct)
}else{soundManager.onerror();soundManager.disable()}}