$.extend({kabel:{Post:function(postUrl,isPopup,OnSuccess,OnError){if(isPopup){$("#popupContent").html("");$.kabel.Popup.Loader.Show()}$.ajax({type:"POST",contentType:"application/json",url:postUrl,dataType:"json",data:"{}",cache:false,async:false,success:function(data){OnSuccess(data)},error:function(data){OnError(data)}})},Popup:{Show:function(html){$("#popupContent").html(html);$("#popupLayer").jqmShow();$.kabel.Popup.Loader.Hide()},Hide:function(){$("#popupLayer").jqmHide()},Loader:{Show:function(){$("#popupLoader").jqmShow()},Hide:function(){$("#popupLoader").jqmHide()}}},News:{Get:function(id,OnSuccess){$.kabel.Post("/services/News/Get/"+id,true,function(data){OnSuccess(data)})},GetLatestNews:function(OnSuccess){$.post("/services/News/GetLatestNews/",{},function(data){OnSuccess(data)})}},Game:{Get:function(id,isPopup,OnSuccess){$.kabel.Post("/services/Game/Get/"+id,isPopup,function(data){OnSuccess(data)})},GetGameComments:function(id,OnSuccess){$.kabel.Post("/services/Game/GetGameComments/"+id,false,function(data){OnSuccess(data)})},AddGameComment:function(gameId,name,comment,OnSuccess,OnError){$.post("/services/Game/AddGameComment",{GameId:gameId,Name:name,Comment:comment},function(data){OnSuccess(data)})},GetLiveGames:function(OnSuccess,OnError){$.post("/services/Game/GetLiveGames",{},function(data){OnSuccess(data)})},GetLatestGames:function(OnSuccess,OnError){$.post("/services/Game/GetLatestGames",{},function(data){OnSuccess(data)})},GetNextGames:function(OnSuccess,OnError){$.post("/services/Game/GetNextGames",{},function(data){OnSuccess(data)})},GetUpcommingGames:function(OnSuccess,OnError){$.post("/services/Game/GetUpcommingGames",{},function(data){OnSuccess(data)})}},Guestbook:{Get:function(source,pageNumber,OnSuccess){$.post("/services/Guestbook/Get/",{PageNumber:pageNumber,Source:source},function(data){OnSuccess(data)})},Add:function(name,comment,OnSuccess){$.post("/services/Guestbook/Add/",{Name:name,Comment:comment},function(data){OnSuccess(data)})}},Player:{Get:function(id){$.kabel.Post("/services/Player/Get/"+id,true,function(data){var p=new Array();p.push('<div class="ContentHeader GameReportHeader"><h6><span>Spelartruppen</span></h6></div>');p.push('<div class="PlayerDetails">');p.push("<br />");p.push('<ul id="playerInfo">');p.push('<li class="column1"><img id="image" alt="image" class="PlayerImage" src="'+data.Image+'"/></li>');p.push('<li class="column2"><h3>Namn:</h3></li>');p.push('<li class="column3">'+data.Name+"</li>");p.push('<li class="column2"><h3>Född:</h3></li>');p.push('<li class="column3">'+data.Born+"</li>");p.push('<li class="column2"><h3>Kom till Kabel:</h3></li>');p.push('<li class="column3">'+data.Arrived+"</li>");p.push('<li class="column2"><h3>Match/mål A:</h3></li>');p.push('<li class="column3">'+data.Stats.Games+"/"+data.Stats.Goals+"</li>");p.push('<li class="column2"><h3>Match/mål tot:</h3></li>');p.push('<li class="column3">'+data.StatsTotal.Games+"/"+data.StatsTotal.Goals+"</li>");p.push('<li class="column2"><h3>Match/mål futsal:</h3></li>');p.push('<li class="column3">'+data.StatsFutsal.Games+"/"+data.StatsFutsal.Goals+"</li>");p.push('<li class="column2"><h3>Moderförening:</h3></li>');p.push('<li class="column3">'+data.StartClub+"</li>");p.push('<li class="column2"><h3>Utmärkelser:</h3></li>');p.push('<li class="column3">');$.each(data.Awards,function(i,award){p.push(award.Text+"<br/>")});p.push("</li>");p.push('<li class="clearBoth"><h3>Tränarens kommentar</h3></li>');p.push("<li>"+data.CoachComment+"</li>");p.push("</ul>");p.push("</div>");$.kabel.Popup.Show(p.join(""))})}},Gallery:{Get:function(id){$.kabel.Post("/services/Gallery/Get/"+id,true,function(data){var p=new Array();p.push('<div class="PlayerDetails">');p.push("<br />ddf");p.push("</div>");$.kabel.Popup.Loader.Hide();return p.join("")})},GetVideos:function(filters,OnSuccess){$.post("/services/Gallery/GetVideos/",{Filters:filters},function(data){OnSuccess(data)})}},Content:{Get:function(id,isPopup,OnSuccess){$.kabel.Post("/services/Content/Get/"+id,isPopup,function(data){OnSuccess(data)})},GetChronicles:function(OnSuccess){$.kabel.Post("/services/Content/GetChronicles/",false,function(data){OnSuccess(data)})}},Product:{Get:function(id,OnSuccess){$.kabel.Post("/services/Product/Get/"+id,false,function(data){OnSuccess(data)})}},CM:{LiveReport:function(gameId,result,halfTimeResult,OnSuccess){$.post("/api/CM/LiveReport/",{GameId:gameId,Result:result,HalfTimeResult:halfTimeResult},function(data){OnSuccess(data)})}},User:{Validate:function(userName,password,OnSuccess){$.post("/api/user/Validate/",{UserName:userName,Password:password},function(data){OnSuccess(data)})},Logout:function(OnSuccess){$.post("/api/user/Logout/",function(data){OnSuccess(data)})}}}});(function($){$.fn.jqm=function(o){var p={overlay:50,overlayClass:"jqmOverlay",closeClass:"jqmClose",trigger:".jqModal",ajax:F,ajaxText:"",target:F,modal:F,toTop:F,onShow:F,onHide:F,onLoad:F};return this.each(function(){if(this._jqm){return H[this._jqm].c=$.extend({},H[this._jqm].c,o)}s++;this._jqm=s;H[s]={c:$.extend(p,$.jqm.params,o),a:F,w:$(this).addClass("jqmID"+s),s:s};if(p.trigger){$(this).jqmAddTrigger(p.trigger)}})};$.fn.jqmAddClose=function(e){return hs(this,e,"jqmHide")};$.fn.jqmAddTrigger=function(e){return hs(this,e,"jqmShow")};$.fn.jqmShow=function(t){return this.each(function(){t=t||window.event;$.jqm.open(this._jqm,t)})};$.fn.jqmHide=function(t){return this.each(function(){t=t||window.event;$.jqm.close(this._jqm,t)})};$.jqm={hash:{},open:function(s,t){var h=H[s],c=h.c,cc="."+c.closeClass,z=(parseInt(h.w.css("z-index"))),z=(z>0)?z:3000,o=$("<div></div>").css({height:"100%",width:"100%",position:"fixed",left:0,top:0,"z-index":z-1,opacity:c.overlay/100});if(h.a){return F}h.t=t;h.a=true;h.w.css("z-index",z);if(c.modal){if(!A[0]){L("bind")}A.push(s)}else{if(c.overlay>0){h.w.jqmAddClose(o)}else{o=F}}h.o=(o)?o.addClass(c.overlayClass).prependTo("body"):F;if(ie6){$("html,body").css({height:"100%",width:"100%"});if(o){o=o.css({position:"absolute"})[0];for(var y in {Top:1,Left:1}){o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'")}}}if(c.ajax){var r=c.target||h.w,u=c.ajax,r=(typeof r=="string")?$(r,h.w):$(r),u=(u.substr(0,1)=="@")?$(t).attr(u.substring(1)):u;r.html(c.ajaxText).load(u,function(){if(c.onLoad){c.onLoad.call(this,h)}if(cc){h.w.jqmAddClose($(cc,h.w))}e(h)})}else{if(cc){h.w.jqmAddClose($(cc,h.w))}}if(c.toTop&&h.o){h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o)}(c.onShow)?c.onShow(h):h.w.show();e(h);return F},close:function(s){var h=H[s];if(!h.a){return F}h.a=F;if(A[0]){A.pop();if(!A[0]){L("unbind")}}if(h.c.toTop&&h.o){$("#jqmP"+h.w[0]._jqm).after(h.w).remove()}if(h.c.onHide){h.c.onHide(h)}else{h.w.hide();if(h.o){h.o.remove()}}return F},params:{}};var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version=="6.0"),F=false,i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),e=function(h){if(ie6){if(h.o){h.o.html('<p style="width:100%;height:100%"/>').prepend(i)}else{if(!$("iframe.jqm",h.w)[0]){h.w.prepend(i)}}}f(h)},f=function(h){if($(":input:visible",h.w)!=null&&$(":input:visible",h.w).length>0){$(":input:visible",h.w)[0].focus()}},L=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m)},m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents(".jqmID"+h.s)[0]);if(r){f(h)}return !r},hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function(){if(!this[c]){this[c]=[];$(this).click(function(){for(var i in {jqmShow:1,jqmHide:1}){for(var s in this[i]){if(H[this[i][s]]){H[this[i][s]].w[i](this)}}}return F})}this[c].push(s)})})}})(jQuery);(function($){$.extend($.fn,{swapClass:function(c1,c2){var c1Elements=this.filter("."+c1);this.filter("."+c2).removeClass(c2).addClass(c1);c1Elements.removeClass(c1).addClass(c2);return this},replaceClass:function(c1,c2){return this.filter("."+c1).removeClass(c1).addClass(c2).end()},hoverClass:function(className){className=className||"hover";return this.hover(function(){$(this).addClass(className)},function(){$(this).removeClass(className)})},heightToggle:function(animated,callback){animated?this.animate({height:"toggle"},animated,callback):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();if(callback){callback.apply(this,arguments)}})},heightHide:function(animated,callback){if(animated){this.animate({height:"hide"},animated,callback)}else{this.hide();if(callback){this.each(callback)}}},prepareBranches:function(settings){if(!settings.prerendered){this.filter(":last-child:not(ul)").addClass(CLASSES.last);this.filter((settings.collapsed?"":"."+CLASSES.closed)+":not(."+CLASSES.open+")").find(">ul").hide()}return this.filter(":has(>ul)")},applyClasses:function(settings,toggler){this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event){toggler.apply($(this).next())}).add($("a",this)).hoverClass();if(!settings.prerendered){this.filter(":has(>ul:hidden)").addClass(CLASSES.expandable).replaceClass(CLASSES.last,CLASSES.lastExpandable);this.not(":has(>ul:hidden)").addClass(CLASSES.collapsable).replaceClass(CLASSES.last,CLASSES.lastCollapsable);this.prepend('<div class="'+CLASSES.hitarea+'"/>').find("div."+CLASSES.hitarea).each(function(){var classes="";$.each($(this).parent().attr("class").split(" "),function(){classes+=this+"-hitarea "});$(this).addClass(classes)})}this.find("div."+CLASSES.hitarea).click(toggler)},treeview:function(settings){settings=$.extend({cookieId:"treeview"},settings);if(settings.add){return this.trigger("add",[settings.add])}if(settings.toggle){var callback=settings.toggle;settings.toggle=function(){return callback.apply($(this).parent()[0],arguments)}}function treeController(tree,control){function handler(filter){return function(){toggler.apply($("div."+CLASSES.hitarea,tree).filter(function(){return filter?$(this).parent("."+filter).length:true}));return false}}$("a:eq(0)",control).click(handler(CLASSES.collapsable));$("a:eq(1)",control).click(handler(CLASSES.expandable));$("a:eq(2)",control).click(handler())}function toggler(){$(this).parent().find(">.hitarea").swapClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).swapClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().swapClass(CLASSES.collapsable,CLASSES.expandable).swapClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightToggle(settings.animated,settings.toggle);if(settings.unique){$(this).parent().siblings().find(">.hitarea").replaceClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).replaceClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().replaceClass(CLASSES.collapsable,CLASSES.expandable).replaceClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightHide(settings.animated,settings.toggle)}}function serialize(){function binary(arg){return arg?1:0}var data=[];branches.each(function(i,e){data[i]=$(e).is(":has(>ul:visible)")?1:0});$.cookie(settings.cookieId,data.join(""))}function deserialize(){var stored=$.cookie(settings.cookieId);if(stored){var data=stored.split("");branches.each(function(i,e){$(e).find(">ul")[parseInt(data[i])?"show":"hide"]()})}}this.addClass("treeview");var branches=this.find("li").prepareBranches(settings);switch(settings.persist){case"cookie":var toggleCallback=settings.toggle;settings.toggle=function(){serialize();if(toggleCallback){toggleCallback.apply(this,arguments)}};deserialize();break;case"location":var current=this.find("a").filter(function(){return this.href.toLowerCase()==location.href.toLowerCase()});if(current.length){current.addClass("selected").parents("ul, li").add(current.next()).show()}break}branches.applyClasses(settings,toggler);if(settings.control){treeController(this,settings.control);$(settings.control).show()}return this.bind("add",function(event,branches){$(branches).prev().removeClass(CLASSES.last).removeClass(CLASSES.lastCollapsable).removeClass(CLASSES.lastExpandable).find(">.hitarea").removeClass(CLASSES.lastCollapsableHitarea).removeClass(CLASSES.lastExpandableHitarea);$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings,toggler)})}});var CLASSES=$.fn.treeview.classes={open:"open",closed:"closed",expandable:"expandable",expandableHitarea:"expandable-hitarea",lastExpandableHitarea:"lastExpandable-hitarea",collapsable:"collapsable",collapsableHitarea:"collapsable-hitarea",lastCollapsableHitarea:"lastCollapsable-hitarea",lastCollapsable:"lastCollapsable",lastExpandable:"lastExpandable",last:"last",hitarea:"hitarea"};$.fn.Treeview=$.fn.treeview})(jQuery);
