jQuery.extend(jQuery.easing,{def:"easeOutQuad",easeOutCubic:function(a,c,b,d,e){return d*((c=c/e-1)*c*c+1)+b},easeInOutCubic:function(a,c,b,d,e){return 1>(c/=e/2)?d/2*c*c*c+b:d/2*((c-=2)*c*c+2)+b},easeOutQuart:function(a,c,b,d,e){return-d*((c=c/e-1)*c*c*c-1)+b}});
$.fn.setCursorPosition=function(a){this.each(function(c,b){if(b.setSelectionRange)b.setSelectionRange(a,a);else if(b.createTextRange){var d=b.createTextRange();d.collapse(!0);d.moveEnd("character",a);d.moveStart("character",a);d.select()}});return this};var S=S||{},console=console||{};console.log=console.log||function(){};console.log=function(){};$(function(){S.EventListControl.init();S.EventFilterControl.init();S.ChannelSelector.init();S.TopListControl.init();S.SearchControl.init();S.Bootstrapper.init();S.HashController.init()});
S.Bootstrapper=function(a){a.init=function(){$(S.EventFilterControl).bind("eventCategoryChecked",function(b,d){S.EventManager.addToFilter(d);a();S.Statistics.trackEvent("Filters","Checked",d)});$(S.EventFilterControl).bind("eventCategoryUnchecked",function(b,d){S.EventManager.removeFromFilter(d);a();S.Statistics.trackEvent("Filters","Unchecked",d)});var a=function(b){b=S.EventManager.getRealCurrentFilter();S.EventFilterControl.updateToMatchFilter(b);S.EventManager.getEvents();$.post("_ax/filter.set.php",
{categories:b.join(",")});S.Helpers.setCookie("categories",b.join(","),1296E6)};$(S.EventFilterControl).bind("ShowAllSelected",function(){S.EventManager.setShowUtvalda(!1);S.EventManager.getEvents();$.post("_ax/filter.set.php",{show:"all"});S.Helpers.setCookie("visautvalda","0",1296E6);S.Statistics.trackEvent("Filters","ShowAll - Selected")});$(S.EventFilterControl).bind("ShowAllDeselected",function(){S.EventManager.setShowUtvalda(!0);S.EventManager.getEvents();$.post("_ax/filter.set.php",{show:"utvalda"});
S.Helpers.setCookie("visautvalda","1",1296E6);S.Statistics.trackEvent("Filters","ShowAll - Deselected")});$(S.EventListControl).bind("UserWillSee",function(b,a){S.TopListControl.load();var c=S.EventManager.getEventById(a);S.Statistics.trackEvent("Event","Click - Will Watch Game",c.title+" ("+c.tabladatum+")");S.Statistics.trackEvent("Event","Will Watch Game")});$(S.EventListControl).bind("UserWillNotSee",function(b,a){S.TopListControl.load();var c=S.EventManager.getEventById(a);S.Statistics.trackEvent("Event",
"Click - Will Not Watch Game",c.title+" ("+c.tabladatum+")");S.Statistics.trackEvent("Event","Will Not Watch Game")});$(S.EventListControl).bind("ItemOpened",function(){S.Statistics.trackEvent("Event","Expanded")});$(S.EventListControl).bind("ItemClosed",function(){S.HashController.hashStartsWith("/a/")&&S.HashController.resetHash();S.Statistics.trackEvent("Event","Collapsed")});S.SearchControl.setSearchInput("#s");$(S.SearchControl).bind("SearchTextChanged",function(b,a){S.EventListControl.reset();
S.EventListControl.setTextFilter(a);S.Helpers.isNullOrEmpty(a)?(S.EventManager.setIgnoreFilters(!1),S.EventFilterControl.enable(),$(".darthbox").removeClass("search"),S.HashController.resetHash()):(S.EventManager.setIgnoreFilters(!0),S.EventFilterControl.disable(),$(".darthbox").addClass("search"),S.HashController.setHash("#/s/"+a));!S.Helpers.isNullOrEmpty(a)&&2<=a.length?(S.TeamListControl.setSearchFilter(a),S.TeamListControl.load(),S.LeagueListControl.setSearchFilter(a),S.LeagueListControl.load()):
($("#teamListContainer").hide(),S.TeamListControl.reset(),$(".numTeamResults").text(""),$("#leagueListContainer").hide(),S.LeagueListControl.reset());S.EventManager.getEvents();S.Statistics.trackEvent("Search","SearchText",a)});$(S.TeamListControl).bind("TeamsLoaded",function(a,c){if(0<c.length){$("#teamListContainer").show();var e=[],f;for(f in c)for(var g in c[f].competitions)e.push(c[f].competitions[g]);S.LeagueListControl.setIdCollection(e);S.LeagueListControl.load()}else $("#teamListContainer").hide(),
S.LeagueListControl.resetIdCollection();$(".numTeamResults").text(" och "+c.length+" lag")});$(S.LeagueListControl).bind("LeaguesLoaded",function(a,c){if(0<c.length){$("#leagueListContainer").show();for(var e in c){var f=c[e];"NHL"!=f.name&&S.EventScheduleManager.getEvents(f.idC)}}else $("#leagueListContainer").hide()});$(S.EventScheduleManager).bind("EventScheduleLoaded",function(a,c,e){a=S.EventManagerBase.groupEventsByDay(e);S.EventListControl.setDataSet("ScheduledEvents"+c,a);S.EventListControl.update()});
$(S.HashController).bind("onScrollToEventRequest",function(b,d){var e=S.EventManager.getEventById(d);if(!S.EventManager.isEventPartOfFilters(e)||!S.EventListControl.isEventMatchingCurrentTextFilter(e))S.EventManager.clearFilter(),S.SearchControl.cancelSearch(),a();(function(){S.EventManager.getPeopleWhoWillSee(d);S.EventListControl.scrollToItem(d,function(){S.EventListControl.toggleItem(d,"expand")})})()});setTimeout(function(){window.location.reload(!0)},75E4);S.TopListControl.setItemTemplate("#tmplToplistItem");
S.TopListControl.setContainer("#othersWillSeeList");S.TopListControl.load();S.TeamListControl.setItemTemplate("#tmplTeamListItem");S.TeamListControl.setContainer("#teamList");S.LeagueListControl.setItemTemplate("#tmplLeagueListItem");S.LeagueListControl.setContainer("#leagueList")};return a}(S.Bootstrapper||{});S=S||{};S.Cache=function(a){var c={};a.get=function(a){console.log("S.Cache.get(): Get cache",a||"Not in cache");return c[a]||!1};a.set=function(a,d){console.log("S.Cache.set(): Set cache",a);c[a]=d};a.has=function(a){console.log("S.Cache.has(): Has cache",a,!!c[a]);return!!c[a]};return a}(S.Cache||{});S=S||{};
S.ChannelSelector=function(a){a.init=function(){$(".channel_selection .channel_list_option").click(b);c()};a.selectChannel=function(b){var b=$(".channel_list_option[data-id="+b+"]"),e=b.find("input[type=checkbox]");b.addClass("channel_list_option_active");e.attr("checked",!0);a.save();c()};a.deSelectChannel=function(b){var b=$(".channel_list_option[data-id="+b+"]"),e=b.find("input[type=checkbox]");b.removeClass("channel_list_option_active");e.attr("checked",!1);a.save();c()};a.save=function(){var a=$("#channel_settings_form").serialize()+
"&submit_kanaler=1";$.post("/installningar",a);_gaq.push(["_trackEvent","Settings","Save"])};var c=function(){0==$(".channel_selection input[type=checkbox]:checked").size()?$(".channel_selection").addClass("no_selections"):$(".channel_selection").removeClass("no_selections")},b=function(b){var b=$(b.currentTarget),c=b.attr("data-id");1==$(b).find("input[type=checkbox]:checked").size()?a.deSelectChannel(c):a.selectChannel(c)};return a}(S.ChannelSelector||{});S=S||{};S.DataRequest=function(a){a.get=function(a,b,d){console.log("S.DataRequest.get(): Data reset sent to",a);$.get(a,b,function(a){d(a)})};return a}(S||S.DataRequest);S=S||{};
S.EventFilterControl=function(a){a.init=function(){$("#eventFilter li").click(function(b){b=$(b.currentTarget).find(" > input");if(0!=b.size()){var c=b.val();1==b.is(":checked")?$(a).trigger("eventCategoryUnchecked",c):$(a).trigger("eventCategoryChecked",c);return!1}});var c=null;$("#eventFilter .droplist").mouseenter(function(a){clearTimeout(c);$(a.currentTarget).addClass("hover")}).mouseleave(function(a){c=setTimeout(function(){$(a.currentTarget).removeClass("hover")},250)});$(".utvalda").click(function(b){b=$(b.currentTarget).find(" > input");
b.is(":checked")?(b.attr("checked",!1),b.closest("li").removeClass("selected"),$(a).trigger("ShowAllDeselected")):(b.attr("checked",!0),b.closest("li").addClass("selected"),$(a).trigger("ShowAllSelected"))})};a.setShowAllEventsCheckbox=function(a){var b=$(".utvalda input");a?b.closest("li").addClass("selected"):b.closest("li").removeClass("selected");b.attr("checked",a)};a.updateToMatchFilter=function(a){console.log("S.EventFilterControl.updateToMatchFilter(): Update checkboxes to match filter",a);
$("#eventFilter li input").each(function(b,d){var e=$(d).val();S.Helpers.inArray(a,e)?($(d).attr("checked",!0),$(d).closest("li").addClass("selected")):($(d).attr("checked",!1),$(d).closest("li").removeClass("selected"))});$("#eventFilter .droplist").removeClass("selected");$("#eventFilter .droplist").has("li input:checked").addClass("selected")};a.enable=function(){$(".darthbox").removeClass("disabled")};a.disable=function(){$(".darthbox").addClass("disabled")};return a}(S.EventFilterControl||{});S=S||{};
S.EventListControl=function(a){var c=null,b=null,d=null,e={},f=!1,g=function(){},i=function(){b?(b.find(".eventItem").live("click",function(b){b=$(b.currentTarget).attr("data-id");a.toggleItem(b)}),b.find(".eventItem .btnPostToFacebook").live("click",function(a){var a=$(a.currentTarget).closest(".eventItem"),b=a.attr("data-id"),c=a.find(".channel").map(function(a,b){return $(b).attr("title")}),d=$.makeArray(c).join(", "),c=a.find("h3").text()+" (via sport.nu)",e=a.find(".info").text(),d=d+" "+a.closest(".day").find("h2").text()+
" kl. "+a.find(".time").text(),b="http://beta.sport.nu/#/a/"+b;S.Statistics.trackEvent("Event","Post to Facebook Feed",a.find("h3").text());S.Facebook.postToFeed(c,d,e,b);return!1}),b.find("input.btnWillSee.willNotSee").live("click",function(b){var c=$(b.currentTarget).closest(".eventItem").attr("data-id");$.post("/_ax/willsee.set.php",{id:c},function(b){if("Success"==b)S.EventManager.getEventById(c).will_see=!0,S.EventManager.getPeopleWhoWillSee(c,function(b){a.setWhoWillSeeGame(c,b);$(a).trigger("UserWillSee",
c)},!0)});return!1}),b.find("input.btnWillSee.willSee").live("click",function(b){var c=$(b.currentTarget).closest(".eventItem").attr("data-id");$.post("/_ax/willsee.unset.php",{id:c},function(b){if("Success"==b)S.EventManager.getEventById(c).will_see=!1;S.EventManager.getPeopleWhoWillSee(c,function(b){a.setWhoWillSeeGame(c,b);$(a).trigger("UserWillNotSee",c)},!0)});return!1})):console.log("Warning: No container set for EventListControl")};a.isEventMatchingCurrentTextFilter=function(b){return S.Helpers.isNullOrEmpty(d)?
!0:a.isEventMatchingTextFilter(b,d)};a.isEventMatchingTextFilter=function(a,b){var c=S.Helpers.getDayNameFromTimestamp(new Date(a.tabladatum));return a.category_friendly&&-1!=a.category_friendly.toLowerCase().indexOf(b.toLowerCase())||a.competition_friendly&&-1!=a.competition_friendly.toLowerCase().indexOf(b.toLowerCase())||a.title&&-1!=a.title.toLowerCase().indexOf(b.toLowerCase())||c&&-1!=c.toLowerCase().indexOf(b.toLowerCase())||a.channels&&S.Helpers.inArrayComparator(a.channels,function(a,c){return-1!=
c.name.toLowerCase().indexOf(b.toLowerCase())})||a.info&&-1!=a.info.toLowerCase().indexOf(b.toLowerCase())};a.init=function(){};a.setDataSet=function(a,b){console.log("S.EventListControl.setDataSet(): Display groups",b);null===c&&console.log("Warning: No template for events specified in S.EventManager. Use S.EventManager.setTemplate(jQueryTemplate) first.");e[a]=b};var h=function(a){var b=[],c;for(c in a){var d=a[c];console.log("S.EventListControl.getMergedDataSets(): Merging dataSet ",c,d);for(var e in d){var f=
d[e],h=j(f,b);if(-1==h)b.push(f),h=b.length-1;else for(var g in f.events){var i=S.Helpers.getIndexOfItem(b[h].events,function(a){return a.id==f.events[g].id});-1==i?b[h].events.push(f.events[g]):"tabla"==f.events[g].eventType&&(b[h].events[i]=f.events[g])}b[h].events=S.Helpers.removeDuplicatesFromArray(b[h].events,function(a){return a.title});b[h].events=b[h].events.sort(S.Helpers.sortByTimestampZeroTimesAtBottom)}}return b},j=function(a,b){for(var c in b)if(void 0!==b[c]&&b[c].day==a.day&&b[c].month==
a.month)return c;return-1};a.reset=function(){console.log("S.EventListControl.reset(): Reseting list");e=[]};a.update=function(){if(null===e||e.length=={})console.log("Warning: Cannot update EventListControl because no datasets are previously set");else{console.log("S.EventListControl.update(): Constructing merged data set from:",e);var f=h(e);if(!1===S.Helpers.isNullOrEmpty(d)){var k=[],l;for(l in f){var n=[],i;for(i in f[l].events)a.isEventMatchingTextFilter(f[l].events[i],d)&&n.push(f[l].events[i]);
if(0<n.length){var j=f[l];j.events=n;k.push(j)}}f=k}f.sort(S.Helpers.sortByTimestamp);console.log("S.EventListControl.update(): Updating with merged data set:",f);$(b).html($.render(c,f));g(f)}};a.toggleItem=function(b,c){var d=$(".eventItem[data-id="+b+"]"),e=d.find(".expandWrapper"),f=d.find(".expand");"collapse"==c||"expand"!=c&&d.hasClass("expanded")?(d.removeClass("expanded"),$.browser.msie?e.css({height:"0px"}):e.animate({height:"0px",opacity:0},{duration:250}),$(a).trigger("ItemClosed",b)):
(d.addClass("expanded"),f=f.outerHeight(),$.browser.msie?(e.css({height:"auto"}),e.css({height:"auto"})):e.animate({height:f+"px",opacity:100},{duration:250,complete:function(){e.css({height:"auto"})}}),$(a).trigger("ItemOpened",b),b=d.attr("data-id"),S.EventManager.getPeopleWhoWillSee(b,function(c){a.setWhoWillSeeGame(b,c)}))};a.setWhoWillSeeGame=function(a,c){console.log("Add people",c);var d=$(b).find("li[data-id="+a+"]"),e=0===c.length?"Ingen ska se matchen \u00e4nnu":1==c.length?c.length+" person ska se matchen":
c.length+" personer ska se matchen";d.find(".peopleCount").text(e);d.find(".peopleWhoWillSee").html($.render("#tmplPersonWhoWillSee",c));a:{for(var f in c)if(c[f].facebook_id==S.Settings.facebookId){e=!0;break a}e=!1}e?(d.find(".willSee").show(),d.find(".willNotSee").hide()):(d.find(".willSee").hide(),d.find(".willNotSee").show())};a.scrollToItem=function(a,c){var d=$(b).find("li[data-id="+a+"]");return null!==d&&0<$(d).size()?(d=d.offset().top,c=c||function(){},$.browser.msie?($("html, body").scrollTop(d),
c()):$("html, body").animate({scrollTop:d},1100,"easeOutQuart",c),!0):!1};a.setTextFilter=function(a){d=a;S.Helpers.isNullOrEmpty(d)?!1!==f&&(f=!1):f||(f=!0)};a.setTemplate=function(a){c=$(a).template()};a.setContainer=function(a){b=$(a);i()};a.setEventsPopulatedCallback=function(a){g=a};return a}(S.EventListControl||{});S=S||{};
S.EventManager=function(a){var c=[],b=!0,d=!1,e=function(){},f=[],g=function(a){return a?"Events_Utvalda":"Events_All"},i=function(a,c){console.log("S.EventManager.fetchEvents(): Retrieving from server. Utvalda: ",b);$.ajaxSetup({scriptCharset:"iso-8859-1",contentCategory:"application/json; charset=iso-8859-1"});S.DataRequest.get("_ax/events.get.php",{utvalda:a?1:0},function(a){a=S.Helpers.objectToArray(a);c(a)})},h=function(){return"americanfootball,bandy,baseball,basketball,bike,bowling,boxing,cards,cup,curling,extreme,fighting,floorball,horse,pool,ribbon,rugby,rugby,run,sailing,skate,tabletennis,volleyball,other".split(",")},j=
function(){return"tennis,handball,snow,golf,other,more".split(",")},m=function(c){var d=[],e=a.getCurrentFilter(),f;for(f in c){var h=c[f];S.Helpers.inArrayComparator(e,function(a,b){return h.category==b})&&(b&&1==h.utvald?d.push(h):!1==b&&d.push(h))}return d};a.getEventById=function(a){var c=g(b),c=S.Cache.get(c),d;for(d in c)if(c[d].id==a)return c[d]};a.isEventPartOfFilters=function(c){return(b&&1==c.utvald||!1==b)&&S.Helpers.inArrayComparator(a.getCurrentFilter(),function(a,b){return c.category==
b})};a.getPeopleWhoWillSee=function(a,b,c){b=b||function(){};a in f&&!0!=c?b(f[a]):$.ajax({url:"_ax/willsee.get.php",dataType:"json",cache:!1,data:{eventId:a},success:function(c){f[a]=c;b(f[a])}})};a.getCurrentFilter=function(){return 0<c.length?c:h().concat(j()).concat(["football","icehockey"])};a.getRealCurrentFilter=function(){return c};a.addToFilter=function(a){!1==jQuery.isArray(a)&&(a=[a]);"more"==a[0]&&(a=j());S.Helpers.inArray(a,"other")&&(a=a.concat(h()));for(var b in a)!1==S.Helpers.inArray(c,
a[b])&&c.push(a[b])};a.removeFromFilter=function(a){!1==jQuery.isArray(a)&&(a=[a]);S.Helpers.inArray(a,"more")&&(a=a.concat(j()));S.Helpers.inArray(a,"other")&&(a=a.concat(h()));for(var b in a)S.Helpers.removeFromArray(c,a[b]);!1==S.Helpers.arraysOverlap(c,j)&&S.Helpers.removeFromArray(c,"more")};a.clearFilter=function(){a.removeFromFilter(a.getRealCurrentFilter())};a.setShowUtvalda=function(a){b=a};a.setEventsRetrievedCallback=function(a){e=a};a.addEvents=function(a){for(var c in a){var d=a[c],d=
S.EventManagerBase.formatServerEventForClient(d);d.eventType="tabla";d.eventHasWillSee=!0}c=g(b);S.Cache.set(c,a)};a.getEvents=function(c){c=c||e;a.getCurrentFilter();console.log("S.EventManager.getEvents(): Update events (Utvalda: "+b+") using filter: ",a.getCurrentFilter());var f=d?!1:b,h=g(f);(h=S.Cache.get(h))?(!1==d&&(h=m(h)),c(h),$(a).trigger("EventsUpdated",h)):i(f,function(b){a.addEvents(b);!1==d&&(b=m(b));c(b);$(a).trigger("EventsUpdated",b)})};a.setIgnoreFilters=function(a){console.log("Set ignore filters to "+
a);d=a};return a}(S.EventManager||{});S=S||{};
S.EventManagerBase=function(a){a.groupEventsByDay=function(a){a.sort(S.Helpers.sortByTimestamp);var b={},d;for(d in a){var e=a[d],f=e.tabladatum,g=Date.parseExact(f,"yyyy-MM-dd");b[f]=b[f]||[];b[f].title=S.Helpers.getDayNameFromTimestamp(g);b[f].timestamp=g;b[f].day=g.getDate();b[f].month=S.Helpers.getMonthNameFromTimestamp(g).toUpperCase();b[f].events=b[f].events||[];b[f].events.push(e)}return S.Helpers.objectToArray(b)};a.formatServerEventForClient=function(a,b){var d=a;b&&(d=S.Helpers.clone(a));d.timestamp=
new Date(1E3*d.starttid_unixstamp);d.time=S.Helpers.formatTime(d.timestamp);d.title=d.title.replace("-"," - ");return d};return a}(S.EventManagerBase||{});S=S||{};
S.EventScheduleManager=function(a){a.init=function(){};a.getEvents=function(c,b){var b=b||function(){},d="S.EventScheduleManager_"+c,e=S.Cache.get(d);e?(b(e),$(a).trigger("EventScheduleLoaded",[c,e])):$.getJSON("_ax/events.schedule.get.php",{competitionId:c},function(e){for(var g in e){e[g]=S.EventManagerBase.formatServerEventForClient(e[g]);if("00:00"==e[g].time)e[g].time="";e[g].eventType="schedule"}S.Cache.set(d,e);b(e);$(a).trigger("EventScheduleLoaded",[c,e])})};return a}(S.EventScheduleManager||{});S=S||{};
S.Facebook=function(a){a.openLoginWindow=function(){window.open(S.Settings.facebookLoginUrl,"sportnulogin","toolbar=0, scrollbars=yes, location=0, statusbar=0, menubar=0, resizable=1, width=450, height=350").focus()};a.postToFeed=function(a,b,d,e){FB.ui({method:"feed",display:"popup",name:a,caption:b,description:d,link:e,picture:"http://beta.sport.nu/_gfx/sportnufb.png",action_links:[{text:"Bes&ouml;k sport.nu",href:"http://www.sport.nu"}],user_message_prompt:"Posta till facebook-logg:"},function(b){b&&
b.post_id?S.Statistics.trackEvent("Event","Post to Facebook Feed Completed",a):S.Statistics.trackEvent("Event","Post to Facebook Feed Aborted",a)})};return a}(S.Facebook||{});S=S||{};
S.HashController=function(a){var c="Sport.nu";a.init=function(){c=document.title;$(window).hashchange(a.onHashChanged);if(a.hashStartsWith("/a/")){var b=a.getHashValueFor("/a/");$(a).trigger("onScrollToEventRequest",[b]);(b=S.EventManager.getEventById(b))&&S.Statistics.trackEvent("Event","On Page Load",b.title+" ("+b.tabladatum+")")}else if(a.hashStartsWith("/s/"))b=a.getHashValueFor("/s/"),S.SearchControl.setSearchText(b),document.title=b+" - Sport.nu",S.Statistics.trackEvent("Search","On Page Load",b)};
a.onHashChanged=function(){if(a.hashStartsWith("/a/")){var b=a.getHashValueFor("/a/");$(a).trigger("onScrollToEventRequest",[b])}else if(a.hashStartsWith("/s"))b=a.getHashValueFor("/s/"),document.title=b+" - Sport.nu"};a.getHash=function(){return window.location.hash};a.hashStartsWith=function(b){return a.getHash().substr(1,b.length)==b};a.getHashValueFor=function(b){return a.getHash().substr(b.length+1)};a.setHash=function(a){window.location.hash=a};a.resetHash=function(){window.location.hash="#/";
history.pushState&&history.pushState("",document.title,window.location.pathname);document.title=c};return a}(S.HashController||{});S=S||{};
S.Helpers=function(a){a.removeFromArray=function(c,b){for(var d,e=arguments,f=e.length,g;f&&c.length;)for(d=e[--f];-1!=(g=a.indexOf(d,c));)c.splice(g,1);return c};a.inArray=function(c,b){return-1<a.indexOf(b,c)};a.containsOverlap=function(a,b){for(var d in a)for(var e in b)if(a[d]==b[e])return!0;return!1};a.getIndexOfItem=function(a,b){for(var d in a)if(!0==b(a[d]))return d};a.inArrayComparator=function(a,b){return 0<$(a).filter(b).size()};a.notInArrayComparator=function(a,b){return 0==$(a).filter(b).size()};a.arraysOverlap=
function(a,b){for(var d in a)for(var e in b)if(a[d]==b[e])return!0;return!1};a.distinct=function(c){return c.filter(function(b,c,e){return c==a.indexOf(b,e)})};a.arrayExceptFor=function(a,b){!1==jQuery.isArray(b)&&(b=[b]);for(var d in a)for(var e in b)console.log("check exception",exception[e]),a[d]!=b[e]&&(void 0).push(a[d]);return a};a.sortByTimestamp=function(a,b){var d=new Date(b.timestamp);return(new Date(a.timestamp)).getTime()-d.getTime()};a.sortByTimestampZeroTimesAtBottom=function(a,b){var d=
new Date(b.timestamp),e=(new Date(a.timestamp)).getTime(),d=d.getTime();return""==a.time?1:""==b.time?-1:e>d?1:e==d?0:-1};a.formatRawTime=function(c){return a.formatTime(new Date(1E3*c))};a.formatTime=function(a){var b=a.getHours().toString(),a=a.getMinutes().toString();1==b.length&&(b="0"+b);1==a.length&&(a="0"+a);return b+":"+a};a.isNullOrEmpty=function(a){return null==a||""==$.trim(a)};a.objectToArray=function(a){var b=[],d;for(d in a)b.push(a[d]);return b};a.getDayNameFromRawTimestamp=function(c){return a.getDayNameFromTimestamp(new Date(1E3*
c))};a.getDayNameFromTimestamp=function(a){var b="S\u00f6ndag,M\u00e5ndag,Tisdag,Onsdag,Torsdag,Fredag,L\u00f6rdag".split(",")[a.getDay()],d="",d=S.Settings.today,e=new Date;e.setDate(d.getDate()+1);a.toDateString()==d.toDateString()?d="Idag":a.toDateString()==e.toDateString()?d="Imorgon":(a.getDate(),a.getMonth(),d=b);return d};a.getMonthNameFromTimestamp=function(a){return"Jan,Feb,Mar,Apr,Maj,Jun,Jul,Aug,Sep,Okt,Nov,Dec".split(",")[a.getMonth()]};a.indexOf=function(a,b){if(b.indexOf)return b.indexOf(a);
for(var d=b.length,e=0;e<d;e++)if(b[e]==a)return e;return-1};a.setCookie=function(a,b,d){var e=new Date;e.setDate(e.getDate()+d);b=escape(b)+(null==d?"":"; expires="+e.toUTCString());document.cookie=a+"="+b};a.getCookie=function(a){var b,d,e,f=document.cookie.split(";");for(b=0;b<f.length;b++)if(d=f[b].substr(0,f[b].indexOf("=")),e=f[b].substr(f[b].indexOf("=")+1),d=d.replace(/^\s+|\s+$/g,""),d==a)return unescape(e)};a.clone=function(a){return jQuery.extend(!0,{},a)};a.flattenArray=function(a){var b=
[],d;for(d in a)b=b.concat(a[d]);return b};a.getFirst=function(a,b){for(var d=[],e=0;e<a&&e<b.length;e++)d.push(b[e]);return d};a.removeDuplicatesFromArray=function(a,b){var d={},e=[],f;for(f in a){var g=b(a[f]);!1==g in d&&(e.push(a[f]),d[g]=!0)}return e};return a}(S.Helpers||{});S=S||{};
S.LeagueListControl=function(a){var c=null,b=null,d=null,e=[],f=null;a.load=function(){g(function(f){var g=d,i=[],k;for(k in f){var l=null!=g&&-1!=f[k].name.toLowerCase().indexOf(g.toLowerCase()),n=null!=e&&S.Helpers.inArray(e,f[k].idC);(l||n)&&i.push(f[k])}console.log("Populating leagues",i);$(a).trigger("LeaguesLoaded",[i]);$(b).html($.render(c,i))})};a.reset=function(){d=null;a.resetIdCollection();$(b).html("")};var g=function(a){a=a||function(){};null==f?(console.log("Fetching leagues from server"),i(function(b){f=
b;a(f)})):(console.log("Retrieving leagues from cache"),a(f))},i=function(a){var a=a||function(){},b={};!1==S.Helpers.isNullOrEmpty(d)&&(b={filter:d});$.getJSON("_ax/leagues.get.php",b,function(b){for(var c in b)b[c].id=parseInt(b[c].id),b[c].idC=parseInt(b[c].idC);a(b)})};a.setSearchFilter=function(a){d=a};a.setIdCollection=function(a){e=a};a.resetIdCollection=function(){e=[]};a.setItemTemplate=function(a){c=$(a).template()};a.setContainer=function(a){b=a};return a}(S.LeagueListControl||{});S=S||{};
S.SearchControl=function(a){var c=null,b="S\u00f6k...",d,e=null;a.init=function(){$(window).keydown(function(b){27==b.keyCode&&(clearTimeout(d),a.cancelSearch())})};a.setSearchInput=function(e){c=$(e);b=c.val();c.val(b);c.unbind("keyup");c.keyup(function(e){c.val()==unescape(b)?a.cancelSearch():27==e.keyCode?(clearTimeout(d),a.cancelSearch()):(clearTimeout(d),d=setTimeout(i,300))});c.bind("click",function(){if("http://www.sport.nu/"!=window.location&&"http://www.sport.nu"!=window.location&&"http://sport.nu/"!=
window.location&&"http://sport.nu"!=window.location&&-1==window.location.href.indexOf("#"))window.location="http://www.sport.nu/";f()});c.bind("blur",g);if("http://www.sport.nu/"==window.location||"http://www.sport.nu"==window.location||"http://sport.nu/"==window.location||"http://sport.nu"==window.location)c.focus(),c.setCursorPosition(0);c.one("keydown",function(){f()});c.bind("focus",f)};var f=function(){c.val()==b&&c.val("")},g=function(){""==$.trim(c.val())&&c.val(b)},i=function(){var d=c.val();
d!=b&&d!=e&&(e=d,$(a).trigger("SearchTextChanged",c.val()))};a.setSearchText=function(b){$(c).val(b);$(a).trigger("SearchTextChanged",b)};a.cancelSearch=function(){c.val(b);c.blur();$(a).trigger("SearchTextChanged",null)};return a}(S.SearchControl||{});S=S||{};console=console||{};console.log=console.log||function(){};
S.TeamListControl=function(a){var c=null,b=null,d=null,e=null;a.load=function(){f(function(e){var f=d,g=[],m;for(m in e)-1!=e[m].name.toLowerCase().indexOf(f.toLowerCase())&&g.push(e[m]);console.log("Populating teams",g);$(a).trigger("TeamsLoaded",[g]);$(b).html($.render(c,g))})};a.reset=function(){d=null;$(b).html("")};var f=function(a){a=a||function(){};null==e?(console.log("Fetching teams from server"),g(function(b){for(var c in b)for(var d in b[c].competitions)b[c].competitions[d]=parseInt(b[c].competitions[d]);
e=b;a(e)})):(console.log("Retrieving teams from cache"),a(e))},g=function(a){var a=a||function(){},b={};!1==S.Helpers.isNullOrEmpty(d)&&(b={filter:d});$.getJSON("_ax/teams.get.php",b,function(b){a(b)})};a.setSearchFilter=function(a){d=a};a.setItemTemplate=function(a){c=$(a).template()};a.setContainer=function(a){b=a};return a}(S.TeamListControl||{});S=S||{};
S.TopListControl=function(a){var c=null,b=null;a.init=function(){$("#othersWillSeeList li a").live("click",function(){S.HashController.resetHash()})};a.load=function(){$.ajax({url:"_ax/willsee.toplist.get.php",cache:!1,dataType:"json",success:function(a){for(var e in a){var f=Date.parseExact(a[e].tabladatum,"yyyy-MM-dd");a[e].starttime_friendly=S.Helpers.getDayNameFromTimestamp(f)+", "+S.Helpers.formatRawTime(a[e].starttid_unixstamp)}$(b).html($.render(c,a))}})};a.setItemTemplate=function(a){c=$(a).template()};
a.setContainer=function(a){b=a};return a}(S.TopListControl||{});S=S||{};S.Statistics=function(a){a.trackEvent=function(a,b,d,e,f){var g=["_trackEvent"];g.push(a);g.push(b);d&&g.push(d);e&&g.push(e);f&&g.push(f);_gaq.push(g)};a.trackPageview=function(a){_gaq.push(["_trackPageview",a])};return a}(S.Statistics||{}); 
