$(document).ready(function(){ fixLists(); // fix margins for displaying the lists correctly initNavigation(); // set positions and :active for navigation elements handleNavigation(); // handle animations and content switch orderNavigation(); // order if predefined category onImageError(); // replace broken image links with placeholders }); $(window).load(function() { initSearchDropdown(); // dropdown for the search input fitArtistImages(); // resize and resposition images (artists, album) }); function fitArtistImages() { $("ul.artists img").each(function() { $(this).wrap("
"); divWidth = 147, divHeight = 94; // use this instead of $(this).width(); because .width() of hidden images is zero! width = this.width; height = this.height; if( width < divWidth ) { scaleRatio = width / divWidth; width = divWidth; height /= scaleRatio; } if ( height < divHeight ) { scaleRatio = height / divHeight; height = divHeight; width /= scaleRatio; } posX = - (width - divWidth) / 2; posY = - (height - divHeight) / 8; $(this).css({ "position" : "absolute", "width" : width, "height" : height, "top" : posY, "left" : posX }); }); } // search dropdown function initSearchDropdown() { $("div[dropping]").hoverIntent(function(){ $(this).children(".box").fadeIn(500); }, function(){ $(this).children(".box").fadeOut(300); }); $("div[dropping] .box").live("click", function(){ $(this).children(".box").fadeOut(300); }); $("div[dropping] .box li").live("click", function(){ $("div[dropping] > span").html($(this).html()); $("div[dropping] #category").attr("value", $(this).html().toLowerCase()); }); } // list fixes function fixLists() { $(".artists li:nth-child(6n)").css("marginRight", 0); $(".songs.tab li:nth-child(2n)").css("marginRight", 0); } // set positions for navigation elements function initNavigation() { // add positions and hash control $(".navigation").each(function(){ $i = 0; $(this).children().each(function(){ $(this).attr("position", $i); $(this).attr("hashcontrol", $(this).text().replace(" ","+").toLowerCase()); $i++; }); }); // add actives $str = $.deparam.fragment(window.location.href); $active = $(".navigation li[hashcontrol="+$str.category+"]"); if($active.text() == "" || $active == null) $id = 0; else $id = $active.parent().children().index($active); $('.navigation li:eq('+$id+')').addClass('active'); $('div[wheel] > div:eq('+$id+')').addClass('active').css("opacity", 1.0).show(); } // order if predefined category function orderNavigation(){ $str = $.deparam.fragment(window.location.href); $active = $(".navigation li[hashcontrol="+$str.category+"]"); if($active==null) return; $id = $active.parent().children().index($active); $size = $(".navigation li").size(); for($i=0;$i<$id;$i++){ $element = $(".navigation li:eq("+$i+")"); $(".navigation").append("