(function(){var a=Flavors.Global.namespace("Flavors.TemplateGroup");var b=Flavors.Logger.getLogger(a.__name__);a.init=function(){for(var c in accounts){a.registerPanel(c)}$.address.strict(false);$.address.externalChange(function(e){b("$.address.externalChange()");if(e.value=="/"){return}var d=e.value.replace("/","-");b("serviceAnchor="+d);if(d.length>0){Flavors.Layout.switchToService(d)}})};a.services={};a.registerPanel=function(c){b("register() serviceAnchor="+c);a.services[c]={initialized:false};a.services[c]=new Flavors.Panel(c)};a.prepareSection=function(d,e){b("prepareSection() ... serviceAnchor="+e);var h={thumbsPerRow:5,thumbRowCount:3};if("photoGallery" in Flavors.LayoutSettings[window.layout_name]){$.extend(h,Flavors.LayoutSettings[window.layout_name].photoGallery)}var g={thumbsPerRow:5,thumbRowCount:3};if("chunkyGallery" in Flavors.LayoutSettings[window.layout_name]){$.extend(g,Flavors.LayoutSettings[window.layout_name].chunkyGallery)}if($(d).is(".gallery")){var f="photos";if($(d).closest(".compound-group").length>0){f=$(d).find(".subsection").attr("class").replace("subsection ","")}b("panelSection="+f);var c=(h.thumbRowCount*h.thumbsPerRow);$(d).find(".gallery").each(function(){$(this).scrollableGrid(".thumbnails",{rowHeight:93});$(this).photoViewer(".images-large");$(this).deferredImageLoad({batchSize:c,loadNow:2})})}if($(d).is(".lastfm")){var c=(g.thumbRowCount*g.thumbsPerRow);$(d).find(".gallery").scrollableGrid(".thumbnails",{rowHeight:140}).deferredImageLoad({batchSize:c,loadNow:2})}if($(d).is(".vimeo")){var c=(h.thumbRowCount*h.thumbsPerRow);$(d).find(".gallery").scrollableGrid(".thumbnails",{rowHeight:93}).deferredImageLoad({batchSize:c,loadNow:2});$(d).find(".gallery").videoViewer(".clips-large",{embedUrl:"http://vimeo.com/moogaloop.swf?clip_id={{{ID}}}&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1"})}if($(d).is(".tumblr-music")){$(d).find(".playlist").musicPlayer(".track")}if($(d).is(".soundcloud-music")){$(d).find(".playlist").musicPlayer(".track")}if($(d).is(".goodreads")){var c=(h.thumbRowCount*h.thumbsPerRow);$(d).find(".gallery").scrollableGrid(".thumbnails",{rowHeight:132}).deferredImageLoad({batchSize:c,loadNow:2})}if($(d).is(".foursquare")){$(d).find(".gallery-grid").deferredImageLoad({loadNow:1,loadAll:true})}if($(d).is(".netflix")){var c=(h.thumbRowCount*h.thumbsPerRow);$(d).find(".gallery").scrollableGrid(".thumbnails",{rowHeight:132}).deferredImageLoad({batchSize:c,loadNow:2});$(d).find(".thumbnails ul li a").hover(function(){$(this).find(".review").show()},function(){$(this).find(".review").hide()})}if($(d).is(".youtube")){var c=(h.thumbRowCount*h.thumbsPerRow);$(d).find(".gallery").scrollableGrid(".thumbnails",{rowHeight:91}).deferredImageLoad({batchSize:c,loadNow:2});$(d).find(".gallery").videoViewer(".clips-large",{embedUrl:"http://www.youtube.com/v/{{{ID}}}&hl=en_US&fs=1&rel=0"});$(d).find(".thumbnails ul a").hover(function(){$(this).find(".title").show()},function(){$(this).find(".title").hide()})}};a.preparePanel=function(d){b("preparePanel() serviceAnchor="+d);if(!(d in a.services)){return}var c=a.services[d];if(c.initialized){return c}$(c.element).find(".service").each(function(){$(this).clusters(".compound").each(function(){$(this).wrapAll("<div class='compound-group' />")})}).end().find(".compound-group").each(function(){var e=[];$(this).find(".section").each(function(g){if(g==0){e=[]}e.push({title:$(this).find(".header h2").text(),token:$(this).find(".subsection").attr("class").replace("subsection ","")})});var f="<select class='compound-switcher'>";$.each(e,function(g,h){f+="<option value='"+h.token+"'"+(g==0?"selected":"")+">"+h.title+"</option>"});f+="</select>";$(this).prepend(f)}).find("select.compound-switcher").change(function(){var f=$(this).val();b("navToSectionVal: "+f);var g=$(this).closest(".panel-box").find(".compound .subsection."+f).parent();var e=$(this).closest(".compound-group").find(".section:visible");$(e).fadeOut(function(){$(g).fadeIn(function(){var h=$(g).closest(".panel-box").outerHeight();$("#mask_content").animate({height:h+50})})})});$(c.element).css({visibility:"hidden",display:"block"}).find(".section").each(function(){b("preparing section! ... ");a.prepareSection(this,c.serviceAnchor)}).end().find(".compound-group").each(function(){$(this).find(".section").each(function(e){if(e>0){$(this).hide()}})}).end().css({display:"none",visibility:"visible"});c.initialized=true;return c}})();
