/**
 *
 */
billboard.modules = new (function($)
{
        var me = this;

        billboard.broadcaster.addListener( "pageLoaded", function() { me.onPageLoaded(); } );

        me.init = function()
        {
        };

        /**
         * check content of the page to determine which modules need to be initialized
         */
                me.onPageLoaded = function()
        {
                
               
               
               
                me.quantcast();
                me.media6degrees();
         
                ///Clears Chevy tracking///
                $('.ad-unit-floating').html('');
                
                if ( billboard.section == "home" ) {
                        me.initBuzz();
                }
                if ( $(".hot-news-features").length>0 ) {
                        me.initHotNews();
                }
                if ( $("#hot-container").length > 0 ) { 
                        me.initHotModule();
                }               
                if ( $(".hot-conversations").length > 0 ) {
                        me.initHotConversations();
                }

                if ( $(".main-article").length > 0 ) {
                        
                        me.chevy();
                        me.dylan();
                        
                }
                if ( $(".main-article").length > 0 ) {
                        me.outbrain();
                }       
               
                //CSS FIX BASED ON BROWSER TYPE////
                me.browserCSSAdjustment();
                
        
                ///TYPE KIT FONTS //////
         if ($(".typekit-article").length > 0 ){me.typeKit();}
        ///TYPE KIT  FONTS//////   
                
                
                
                
        };
                
                
                
                  me.typeKit = function()
        {
billboard.log("Billboard.typeKit()");
                  $("head").append('<script type="text/javascript">try{Typekit.load();}catch(e){}</script>'); 
}      
                
                
                
        /**
         * pull all the most popular conversations with the most replies
         */
        me.initHotConversations = function()
        {
                billboard.log("Module.initHotConversations()");
                var elem;
                var contentId = billboard.entityId; // page level unique id 
                var board;
                billboard.social.getMessageBoards( contentId, {order:"MostCommented",start:0,count:15}, function(response) { 
                        billboard.log( response );
                        if ( response.numBoards > 0 ) { 
                                billboard.log(" showing hot conversation module");
                                $("#hot-conversations-container").show();
                                for ( var i=0;i<response.boards.length;i++ ) {
                                        board = response.boards[i];
                                        elem = $("#hot-convo-template").clone();
                                        elem.removeAttr("id");
                                        elem.find(".num-replies").html( board.numReplies );
                                        elem.find(".convo-topic a").html( decodeURI(board.title) );
                                        var url = updateQueryParams( $("a.view-all").attr("href"),{cid:board.id});
                                        elem.find(".convo-topic a").attr( "href", url );
                                        $("#hot-conversation-list").append( elem.show() );
                                        billboard.hijackLinks( elem );
                                }
                        }
                });

                /*
                billboard.social.getComments( contentId, {start:0,count:15,sort:"MostRecentFirst"}, function( data ) {
                        billboard.log( data );
                        if ( data && data.comments ) { 
                                billboard.log(" showing hot conversation module");
                                $("#hot-conversations-container").show();
                                for ( var i=0;i<data.comments.length;i++ ) {
                                        elem = $("#hot-convo-template").clone();
                                        elem.removeAttr("id");
                                        elem.find(".num-replies").html( data.comments[i].num_child_comments );
                                        elem.find(".convo-topic a").html( data.comments[i].subject );
                                        var url = updateQueryParams( $("a.view-all").attr("href"),{cid:data.comments[i].id});
                                        elem.find(".convo-topic a").attr( "href", url );
                                        elem.insertAfter( $("#hot-convo-template") ).show();
                                        billboard.hijackLinks( elem );
                                }
                        }
                });
                */
        };

        me.initBuzz = function()
        {

		$(function() {
		    $(".tabs-billboard").tabs({ ajaxOptions: { async: true },
						cache: true,
		    load: function(event, ui) {
				var features = {     //Features mapping
					"bbma/features":{section:"BBMA NEWS", url:"/bbma/news"},
					"bbma/photogalleries":{section:"BBMA PHOTOGALLERIES", url:"/bbma/photogalleries"},
					"column/chartbeat":{section:"CHARTBEAT", url:"/column/chartbeat"},
					"column/mashupmondays":{section:"MASHUP MONDAYS", url:"/column/mashupmondays"},
					"column/photo-of-the-week":{section:"PHOTO OF THE WEEK", url:"/column/photo-of-the-week"},
					"column/photos-of-the-week":{section:"PHOTOS OF THE WEEK", url:"/column/photos-of-the-week"},
					"column/tastemakers":{section:"TASTEMAKERS", url:"/column/tastemakers"},
					"column/the-615":{section:"THE 615", url:"/column/the-615"},
					"column/the-hook":{section:"THE HOOK", url:"/column/the-hook"},
					"column/the-juice":{section:"THE JUICE", url:"/column/the-juice"},
					"column/tweets-of-the-week":{section:"TWEETS OF THE WEEK", url:"/column/tweets-of-the-week"},
					"column/uncharted-territory":{section:"UNCHARTED TERRITORY", url:"/column/uncharted-territory"},
					"column/viralvideos":{section:"VIRAL VIDEOS", url:"/column/viralvideos"},
					"events":{section:"EVENTS", url:"/events"},
					"features":{section:"FEATURES", url:"/features"},
					"new-releases":{section:"NEW RELEASES", url:"/new-releases"},
					"Album Reviews":{section:"ALBUM REVIEWS", url:"/new-releases"},
					"Song Reviews":{section:"SONG REVIEWS", url:"/new-releases"},
					"news":{section:"NEWS", url:"/news"},
					"photogalleries":{section:"PHOTOGALLERIES", url:"/photogalleries"}
				}
				var metrics = ["most_recent", "most_popular", "latest_reviews"];
				ui.panel.hidden=true;
				var obj = eval('(' + ui.panel.innerHTML + ')');
				var content="<div class='tab'>";
				for (var i=0; i<obj.length; i++) {
					var title, url;		
					if (typeof features[obj[i].primary_display] != 'undefined') {
						section = features[obj[i].primary_display].section;
						url = features[obj[i].primary_display].url;
					} else {
						features_arr = obj[i].primary_display.split("/");
						section = features_arr[features_arr.length-1].toUpperCase();
						url = "/" + obj[i].primary_display;
					}
					content = content + "<div class='tab-item'><div class='item-header'><a href='" + url + "'>" + section + "</a></div><div class='item-body'><a href=/#" + url + "/" + obj[i].url + "-" + obj[i].id + ".story?utm_source="+metrics[ui["index"]]+">" + obj[i].title + "</a></div></div></div>";
				}
				if (ui["index"] == 2)
					content=content+"<a class='see-all' href='/new-releases?utm_source=most_recent' title='See all stories'>See all stories</a>";
				else
					content=content+"<a class='see-all' href='/news?utm_source=most_recent' title='See all stories'>See all stories</a>";
				content=content+"</div>";
				ui.panel.innerHTML = content;
				ui.panel.hidden=false;
		    },
		    select: function(event, ui) {
					switch (ui["index"]) {
					case 0 : $("#bb-tabs-ul")["0"].style.backgroundImage="url(/images/headers/most-recent.png)"; break;
					case 1 : $("#bb-tabs-ul")["0"].style.backgroundImage="url(/images/headers/most-popular.png)"; break;
					case 2 : $("#bb-tabs-ul")["0"].style.backgroundImage="url(/images/headers/reviews.png)"; break;
				}                                                    
		    }
		 });
		});


                billboard.log("Modules.initBuzz");
                billboard.social.getHotItems( "song", {count:10,numDays:7}, function( song ) { 
                        //billboard.log( "initBuzz result" );
                        //billboard.log( song  );
                        var id = song.id.split("-")[1];
                        billboard.getItemDetails( id, "song", function( result ) {
                                if ( !result || typeof(result.response) == "undefined" ) { return; }
                                var result = result.response.body.FavoriteItemView;
                                result.name = result.title;
                                
                                // determine url to image
                                var photo = "/images/defaults/artist-94.gif";
                                if ( result.photoUrl && result.photoUrl.length>0) { 
                                        photo = result.photoUrl;
                                }
                                
                                for ( var p in result ) {
                                        song[p] = result[p];
                                }
                                
                                // create dom object
                                elem = $("#noise-maker-template").clone();
                                elem.removeAttr("id");
                                elem.find(".rank").text( $(".noise-maker-list li").length );
                                elem.find(".pic img").attr("src",photo);
                        //      elem.find(".info .song").text( song.name );
                                elem.find(".info .song").append("<a href='"+ result.url + "'> "+ result.title + "</a>");
                                //elem.find(".info .artist").text( song.artist );
                                //elem.find(".info").attr("href",song.url );
                                var links = new Array();
                                var artistNm = "undefined";
                                if(result.artists){
                                        for(i=0; i < result.artists.length; i++){
                                                links.push("<a href='"+         result.artists[i].link + "'> "+ result.artists[i].name + "</a>");
                                        }
                                        elem.find(".info .artist").append( links.join(", ") );
                                }
                                if(result.artists) artistNm = result.artists[0].name;
                                if ( result.song_url && result.song_url.length > 0 ) {
                                        elem.find(".play-btn a").click( function() { 
                                        javascript:billboard.player.playMSSong(result.song_url);

                                                googleA.trackEvent (1, 'Song', artistNm, result.title, photo, result.url );
                                        //      billboard.facebook.publishPlay(result.title,artistNm,photo,result.url);
                                        });
                                }
                                else {
                                        elem.find(".play-btn a").hide();
                                }

                                billboard.hijackLinks( elem );
                                
                                // add the element to the module
                                $(".noise-maker-list").append( elem.show() );
                        });
                });
        };

        me.initHotNews = function()
        {
                billboard.log("Modules.initHotNews");
                billboard.social.getHotItems( "article", {numDays:1}, function(item){ 
                        var elem;
                        var item;
                        item.id = item.id.split("-")[1];
                        
                        billboard.getItemDetails( item.id, item.type, function(result){
                                if ( result && result.response ) { 
                                        var result = result.response.body.FavoriteItemView;
                                        result.name = result.title;
                                        
                                        // determine url to image
                                        var photo = "";
                                        if ( result.photoUrl && result.photoUrl.length>0) { 
                                                photo = result.photoUrl;
                                        }

                                        for ( var p in result ) {
                                                item[p] = result[p];
                                        }
                                        billboard.log( item );
                                        
                                        // create dom object
                                        elem = $("#hot-news-template").clone();
                                        elem.removeAttr("id");
                                        if(photo!="") elem.find(".pic img").attr("src",photo);
                                        else elem.find(".pic").hide();
                                        elem.find(".news-name").text( item.title );
                                        elem.find(".percent-like").text( item.loveHatePercentage+"%" );
                                        elem.find(".total-comments").text( item.numComments );
                                        elem.find(".total-comments").attr( "href", item.url+"#comment-container" );
                                        elem.click( function() {
                                                if(item.url!="") billboard.navigateToUrl( item.url );
                                                return false;
                                        });
                                        elem.mouseover( function(){
                                                $(this).addClass("tout-highlight");
                                                if(item.url!="") $(this).addClass('clickable');
                                        });
                                        elem.mouseout( function(){
                                                $(this).removeClass("tout-highlight");
                                        });
                                        billboard.hijackLinks( elem );
                                        
                                        if ( result.lalaId && result.lalaId.length > 0 ) {
                                                elem.find(".play-btn a").click( function() { 
                                                        javascript:billboard.player.play(result.lalaId);
                                                });
                                        }
                                        else {
                                                elem.find(".play-btn a").hide();
                                        }
                                        // add the element to the module
                                        $(".hot-news-features").append( elem.show() );
                                }
                        });
                });
        };
        
        me.outbrain = function()
        {
billboard.log("Billboard.outbrain()");

var environment = $("#environment").html();
///////////Needed because local directory different then other environments///////////////////////
if(environment == "local")
{
var slash = "";
}
else
{
var slash = "/";        
}

$(".outbrainContainer").html('<iframe src="'+ slash +'html/outbrain.html" id="outbrainIframe" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" height=600 width=427 ></iframe>');

var main =$('.main-article-wide').length;
if (main > 0)
{
$('#outbrainIframe').width('610px');
$('.outbrainContainer').css('width','610px');
}


}


        me.dylan = function()
        {
billboard.log("Billboard.dylan()");

var dylan =$('#dylan_article').length;
if (dylan > 0)
{
$("html").append('<script>$(function(){$(".Ballad-Of-A-Thin-Man").hover(function(){var val = $("#dylan_currently_playing").val(); if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115109-dylan-Ballad-Of-A-Thin-Man-no-text.jpg");}}, function(){var val = $("#dylan_currently_playing").val(); if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg"); $("#dylan_current").val("dylan-main"); }});  $(".dont-think-twice").hover(function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115189-dylan-dont-think-twice-no-text.jpg");}},function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg");$("#dylan_current").val("dylan-main");}});$(".Brownsville-Girl").hover(function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115149-dylan-Brownsville-Girl-no-text.jpg");}},function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg");$("#dylan_current").val("dylan-main");}});$(".desolation-row").hover(function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115169-dylan-desolation-row-no-text.jpg");}},function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg");$("#dylan_current").val("dylan-main");}});$(".Subterranean").hover(function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115259-dylan-Subterranean-no-text.jpg");}},function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg"); $("#dylan_current").val("dylan-main");}});$(".A-Hard-Rain").hover(function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115089-dylan-A-Hard-Rain-no-text.jpg");}},function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg");$("#dylan_current").val("dylan-main");}});                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   $(".blowin-in-the-wind").hover(function(){var val = $("#dylan_currently_playing").val();        if(val == "none"){                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      $("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115129-dylan-blowin-in-the-wind-no-text.jpg");}},function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg");$("#dylan_current").val("dylan-main");}});$(".the-man-in-me").hover(function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115069-dylan-the-man-in-me-no-text.jpg");}},function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg");$("#dylan_current").val("dylan-main");}});$(".Song-To-Woody").hover(function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115239-dylan-Song-To-Woody-no-text.jpg");}},function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg");}});$(".like-a-rolling-stone").hover(function(){                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115219-dylan-like-a-rolling-stone-no-text.jpg");}},function(){var val = $("#dylan_currently_playing").val();if(val == "none"){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg");$("#dylan_current").val("dylan-main");}});});</script>');   

$("html").append('<script>$(".A-Hard-Rain").live("click", function(){$("#player").html("");$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115079-dylan-A-Hard-Rain.jpg");$("#player").html(\'<embed src="http://www.billboard.com/photos/stylus//1115349-A-Hard-Rain.mp3" autostart="true" hidden="true" loop="false">\');$("#dylan_currently_playing").val("none"); $("#dylan_currently_playing").val(this.title);setTimeout(function (){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg"); $("#dylan_currently_playing").val("none");}, 15000);});$(".Ballad-Of-A-Thin-Man").live("click",function(){$("#player").html("");$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115099-dylan-Ballad-Of-A-Thin-Man.jpg");                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    $("#player").html(\'<embed src="http://www.billboard.com/photos/stylus//1115359-Ballad-Of-A-Thin-Man.mp3" autostart="true" hidden="true" loop="false">\');$("#dylan_currently_playing").val("none");$("#dylan_currently_playing").val(this.title);setTimeout(function (){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg"); $("#dylan_currently_playing").val("none");}, 25000);});$(".blowin-in-the-wind").live("click",function(){$("#player").html("");$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115119-dylan-blowin-in-the-wind.jpg");                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      $("#player").html(\'<embed src="http://www.billboard.com/photos/stylus//1115369-blowin-in-the-wind.mp3" autostart="true" hidden="true" loop="false">\');$("#dylan_currently_playing").val("none");$("#dylan_currently_playing").val(this.title);setTimeout(function (){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg"); $("#dylan_currently_playing").val("none");}, 28000);});$(".Brownsville-Girl").live("click",function(){$("#player").html("");$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115139-dylan-Brownsville-Girl.jpg");$("#player").html(\'<embed src="http://www.billboard.com/photos/stylus//1115379-Brownsville-Girl.mp3" autostart="true" hidden="true" loop="false">\');$("#dylan_currently_playing").val("none");$("#dylan_currently_playing").val(this.title);setTimeout(function (){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg"); $("#dylan_currently_playing").val("none");}, 7000);});$(".desolation-row").live("click",function(){$("#player").html("");$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115159-dylan-desolation-row.jpg");$("#player").html(\'<embed src="http://www.billboard.com/photos/stylus//1115389-desolation-row.mp3" autostart="true" hidden="true" loop="false">\') ;$("#dylan_currently_playing").val("none");$("#dylan_currently_playing").val(this.title); setTimeout(function (){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg"); $("#dylan_currently_playing").val("none");}, 10000);});$(".dont-think-twice").live("click",function(){$("#player").html("");$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115179-dylan-dont-think-twice.jpg");$("#player").html(\'<embed src="http://www.billboard.com/photos/stylus//1115399-dont-think-twice.mp3" autostart="true" hidden="true" loop="false">\');$("#dylan_currently_playing").val("none");$("#dylan_currently_playing").val(this.title);setTimeout(function (){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg"); $("#dylan_currently_playing").val("none");}, 25000);});$(".like-a-rolling-stone").live("click",function(){$("#player").html("");$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115209-dylan-like-a-rolling-stone.jpg");$("#player").html(\'<embed src="http://www.billboard.com/photos/stylus//1115409-like-a-rolling-stone.mp3" autostart="true" hidden="true" loop="false">\'); $("#dylan_currently_playing").val("none");$("#dylan_currently_playing").val(this.title);setTimeout(function (){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg"); $("#dylan_currently_playing").val("none");}, 5000);});$(".Song-To-Woody").live("click",function(){$("#player").html("");$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115229-dylan-Song-To-Woody.jpg");$("#player").html(\'<embed src="http://www.billboard.com/photos/stylus//1115419-Song-To-Woody.mp3" autostart="true" hidden="true" loop="false">\');$("#dylan_currently_playing").val("none");$("#dylan_currently_playing").val(this.title); setTimeout(function (){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg"); $("#dylan_currently_playing").val("none");}, 27000);});$(".Subterranean").live("click",function(){$("#player").html("");$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115249-dylan-Subterranean.jpg");$("#player").html(\'<embed src="http://www.billboard.com/photos/stylus//1115429-Subterranean.mp3" autostart="true" hidden="true" loop="false">\');$("#dylan_currently_playing").val("none");$("#dylan_currently_playing").val(this.title); setTimeout(function (){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg"); $("#dylan_currently_playing").val("none");}, 4000);});$(".the-man-in-me").live("click",function(){$("#player").html("");$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115269-dylan-the-man-in-me.jpg");$("#player").html(\'<embed src="http://www.billboard.com/photos/stylus//1115339-the-man-in-me.mp3" autostart="true" hidden="true" loop="false">\');$("#dylan_currently_playing").val("none");$("#dylan_currently_playing").val(this.title);setTimeout(function (){$("#dylan-main").attr("src","http://www.billboard.com/photos/stylus//1115199-Dylan-full-image.jpg"); $("#dylan_currently_playing").val("none");}, 13000);});</script>');

}

}

        me.quantcast = function()
        {
billboard.log("Billboard.quantcast()");




$("body").append('<script type="text/javascript">_qoptions={qacct:"p-8aHotZzEC0HeY",event:"refresh"};</script><script type="text/javascript" src="http://edge.quantserve.com/quant.js"></script><noscript><img src="http://pixel.quantserve.com/pixel/p-5brcU0D8uyWP6.gif" style="display: none;" border="0" height="1" width="1" alt="Quantcast"/></noscript>');

}
        me.media6degrees = function()
        {
                billboard.log("Billboard.media6degrees()");
                $("body").append('<script type="text/javascript" src="http://cdn.media6degrees.com/static/gm6840.js"></script>');
        }

        me.legolas  = function()
        {
billboard.log("Billboard.legolas()");

$("body").append('<script type="text/javascript" src="http://rt.legolas-media.com/lgrt?ci=2&ti=1200&pbi=10805"></script>');

}


me.chevy = function()
        {
billboard.log("Billboard.chevy()");

if($("#hide-related").length > 0)
{
$(".outbrainContainer").remove();
var region = $("#hide-related").html();
}
else
{
var region = '';        
}

$('.chevyFacebook').live('click', function() {                                                                                                                     
        var u = document.URL;
        var t = 'I just voted for my favorite '+region+' region band for Billboard’s Battle of the Bands. Cast your vote now!';
        window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
        return false;
});

$('.chevyTwitter').live('click', function() {
        var u = document.URL;
        var t = 'I just voted for my favorite '+region+' region band for Billboard’s Battle of the Bands. Cast your vote now!';
        window.open('http://twitter.com/share?url='+encodeURIComponent(u)+'&text='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
        return false;
});


if(region == "Chevy Landing Page")
{
var axel = Math.random() + "";
var a = axel * 10000000000000;

$('.ad-unit-floating').html('<!-- Start of DoubleClick Spotlight Tag: Please do not remove--><SCRIPT SRC="http://fls.doubleclick.net/activityj;src=1139856;type=phome596;cat=billb999;ord='+ a + '?" type="text/javascript"></SCRIPT><NOSCRIPT><IMG SRC="http://ad.doubleclick.net/activity;src=1139856;type=phome596;cat=billb999;ord='+ a + '?" WIDTH=1 HEIGHT=1 BORDER=0 ALT=""/></NOSCRIPT><!-- End of DoubleClick Spotlight Tag:  Please do not remove-->');       //
}


////Landing Page////
$('html').append('<script>$(function(){$(".northEastBig").hover(function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035179-battle_of_the_bands_big_map_northeast.gif");},function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035159-battle_of_the_bands_big_map_dead.gif");});$(".southEastBig").hover(function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035199-battle_of_the_bands_big_map_southeast.gif");},function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035159-battle_of_the_bands_big_map_dead.gif");});$(".southWestBig").hover(function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035209-battle_of_the_bands_big_map_southwest.gif");},function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035159-battle_of_the_bands_big_map_dead.gif");});$(".midWestBig").hover(function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035169-battle_of_the_bands_big_map_midwest.gif");},function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035159-battle_of_the_bands_big_map_dead.gif");});$(".northWestBig").hover(function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035189-battle_of_the_bands_big_map_northwest.gif");},function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035159-battle_of_the_bands_big_map_dead.gif");});$(".westBig").hover(function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035219-battle_of_the_bands_big_map_west.gif");},function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035159-battle_of_the_bands_big_map_dead.gif");});});</script>');

////North West Page////
$('html').append('<script>$(function(){$(".northEast").hover(function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035279-battle_of_the_bands_small_map_northeast.gif");},function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035289-battle_of_the_bands_small_map_northwest.gif");});$(".southEast").hover(function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035299-battle_of_the_bands_small_map_southeast.gif");},function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035289-battle_of_the_bands_small_map_northwest.gif");});$(".southWest").hover(function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035309-battle_of_the_bands_small_map_southwest.gif");},function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035289-battle_of_the_bands_small_map_northwest.gif");});$(".midWest").hover(function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035269-battle_of_the_bands_small_map_midwest.gif");},function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035289-battle_of_the_bands_small_map_northwest.gif");});/*$(".northWest").hover(function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035289-battle_of_the_bands_small_map_northwest.gif");},function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035289-battle_of_the_bands_small_map_northwest.gif");});*/$(".west").hover(function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035149-battle_of_the_bands_small_map_west.gif");},function(){$("#chevyMap").attr("src","http://www.billboard.com/photos/stylus/1035289-battle_of_the_bands_small_map_northwest.gif");});});</script>');

////Midwest Page////
$('html').append('<script>$(function(){$(".northEast").hover(function(){$("#chevyMapMW").attr("src","http://www.billboard.com/photos/stylus/1035279-battle_of_the_bands_small_map_northeast.gif");},function(){$("#chevyMapMW").attr("src","http://www.billboard.com/photos/stylus/1035269-battle_of_the_bands_small_map_midwest.gif");});$(".southEast").hover(function(){$("#chevyMapMW").attr("src","http://www.billboard.com/photos/stylus/1035299-battle_of_the_bands_small_map_southeast.gif");},function(){$("#chevyMapMW").attr("src","http://www.billboard.com/photos/stylus/1035269-battle_of_the_bands_small_map_midwest.gif");});$(".southWest").hover(function(){$("#chevyMapMW").attr("src","http://www.billboard.com/photos/stylus/1035309-battle_of_the_bands_small_map_southwest.gif");},function(){$("#chevyMapMW").attr("src","http://www.billboard.com/photos/stylus/1035269-battle_of_the_bands_small_map_midwest.gif");});/*$(".midWest").hover(function(){$("#chevyMapMW").attr("src","http://www.billboard.com/photos/stylus/1035269-battle_of_the_bands_small_map_midwest.gif");},function(){$("#chevyMapMW").attr("src","http://www.billboard.com/photos/stylus/1035269-battle_of_the_bands_small_map_midwest.gif");});*/$(".northWest").hover(function(){$("#chevyMapMW").attr("src","http://www.billboard.com/photos/stylus/1035289-battle_of_the_bands_small_map_northwest.gif");},function(){$("#chevyMapMW").attr("src","http://www.billboard.com/photos/stylus/1035269-battle_of_the_bands_small_map_midwest.gif");});$(".west").hover(function(){$("#chevyMapMW").attr("src","http://www.billboard.com/photos/stylus/1035149-battle_of_the_bands_small_map_west.gif");},function(){$("#chevyMapMW").attr("src","http://www.billboard.com/photos/stylus/1035269-battle_of_the_bands_small_map_midwest.gif");});});</script>');

//// West Page////
$('html').append('<script>$(function(){$(".northEast").hover(function(){$("#chevyMapW").attr("src","http://www.billboard.com/photos/stylus/1035279-battle_of_the_bands_small_map_northeast.gif");},function(){$("#chevyMapW").attr("src","http://www.billboard.com/photos/stylus/1035149-battle_of_the_bands_small_map_west.gif");});$(".southEast").hover(function(){$("#chevyMapW").attr("src","http://www.billboard.com/photos/stylus/1035299-battle_of_the_bands_small_map_southeast.gif");},function(){$("#chevyMapW").attr("src","http://www.billboard.com/photos/stylus/1035149-battle_of_the_bands_small_map_west.gif");});$(".southWest").hover(function(){$("#chevyMapW").attr("src","http://www.billboard.com/photos/stylus/1035309-battle_of_the_bands_small_map_southwest.gif");},function(){$("#chevyMapW").attr("src","http://www.billboard.com/photos/stylus/1035149-battle_of_the_bands_small_map_west.gif");});$(".midWest").hover(function(){$("#chevyMapW").attr("src","http://www.billboard.com/photos/stylus/1035269-battle_of_the_bands_small_map_midwest.gif");},function(){$("#chevyMapW").attr("src","http://www.billboard.com/photos/stylus/1035149-battle_of_the_bands_small_map_west.gif");});$(".northWest").hover(function(){$("#chevyMapW").attr("src","http://www.billboard.com/photos/stylus/1035289-battle_of_the_bands_small_map_northwest.gif");},function(){$("#chevyMapW").attr("src","http://www.billboard.com/photos/stylus/1035149-battle_of_the_bands_small_map_west.gif");})/*$(".west").hover(function(){$("#chevyMapW").attr("src","http://www.billboard.com/photos/stylus/1035149-battle_of_the_bands_small_map_west.gif");},function(){$("#chevyMapW").attr("src","http://www.billboard.com/photos/stylus/1035149-battle_of_the_bands_small_map_west.gif");});*/});</script>');

////South West Page////
$('html').append('<script>$(function(){$(".northEast").hover(function(){$("#chevyMapSW").attr("src","http://www.billboard.com/photos/stylus/1035279-battle_of_the_bands_small_map_northeast.gif");},function(){$("#chevyMapSW").attr("src","http://www.billboard.com/photos/stylus/1035309-battle_of_the_bands_small_map_southwest.gif");});$(".southEast").hover(function(){$("#chevyMapSW").attr("src","http://www.billboard.com/photos/stylus/1035299-battle_of_the_bands_small_map_southeast.gif");},function(){$("#chevyMapSW").attr("src","http://www.billboard.com/photos/stylus/1035309-battle_of_the_bands_small_map_southwest.gif");});/*$(".southWest").hover(function(){$("#chevyMapSW").attr("src","http://www.billboard.com/photos/stylus/1035309-battle_of_the_bands_small_map_southwest.gif");},function(){$("#chevyMapSW").attr("src","http://www.billboard.com/photos/stylus/1035309-battle_of_the_bands_small_map_southwest.gif");});*/$(".midWest").hover(function(){$("#chevyMapSW").attr("src","http://www.billboard.com/photos/stylus/1035269-battle_of_the_bands_small_map_midwest.gif");},function(){$("#chevyMapSW").attr("src","http://www.billboard.com/photos/stylus/1035309-battle_of_the_bands_small_map_southwest.gif");});$(".northWest").hover(function(){$("#chevyMapSW").attr("src","http://www.billboard.com/photos/stylus/1035289-battle_of_the_bands_small_map_northwest.gif");},function(){$("#chevyMapSW").attr("src","http://www.billboard.com/photos/stylus/1035309-battle_of_the_bands_small_map_southwest.gif");});$(".west").hover(function(){$("#chevyMapSW").attr("src","http://www.billboard.com/photos/stylus/1035149-battle_of_the_bands_small_map_west.gif");},function(){$("#chevyMapSW").attr("src","http://www.billboard.com/photos/stylus/1035309-battle_of_the_bands_small_map_southwest.gif");});});</script>');

////South East Page////
$('html').append('<script>$(function(){$(".northEast").hover(function(){$("#chevyMapSE").attr("src","http://www.billboard.com/photos/stylus/1035279-battle_of_the_bands_small_map_northeast.gif");},function(){$("#chevyMapSE").attr("src","http://www.billboard.com/photos/stylus/1035299-battle_of_the_bands_small_map_southeast.gif");});/*$(".southEast").hover(function(){$("#chevyMapSE").attr("src","http://www.billboard.com/photos/stylus/1035299-battle_of_the_bands_small_map_southeast.gif");},function(){$("#chevyMapSE").attr("src","http://www.billboard.com/photos/stylus/1035299-battle_of_the_bands_small_map_southeast.gif");});*/$(".southWest").hover(function(){$("#chevyMapSE").attr("src","http://www.billboard.com/photos/stylus/1035309-battle_of_the_bands_small_map_southwest.gif");},function(){$("#chevyMapSE").attr("src","http://www.billboard.com/photos/stylus/1035299-battle_of_the_bands_small_map_southeast.gif");});$(".midWest").hover(function(){$("#chevyMapSE").attr("src","http://www.billboard.com/photos/stylus/1035269-battle_of_the_bands_small_map_midwest.gif");},function(){$("#chevyMapSE").attr("src","http://www.billboard.com/photos/stylus/1035299-battle_of_the_bands_small_map_southeast.gif");});$(".northWest").hover(function(){$("#chevyMapSE").attr("src","http://www.billboard.com/photos/stylus/1035289-battle_of_the_bands_small_map_northwest.gif");},function(){$("#chevyMapSE").attr("src","http://www.billboard.com/photos/stylus/1035299-battle_of_the_bands_small_map_southeast.gif");});$(".west").hover(function(){$("#chevyMapSE").attr("src","http://www.billboard.com/photos/stylus/1035149-battle_of_the_bands_small_map_west.gif");},function(){$("#chevyMapSE").attr("src","http://www.billboard.com/photos/stylus/1035299-battle_of_the_bands_small_map_southeast.gif");});});</script>');

////North East Page////
$('html').append('<script>$(function(){/*$(".northEast").hover(function(){$("#chevyMapNE").attr("src","http://www.billboard.com/photos/stylus/1035279-battle_of_the_bands_small_map_northeast.gif");},function(){$("#chevyMapNE").attr("src","http://www.billboard.com/photos/stylus/1035279-battle_of_the_bands_small_map_northeast.gif");});*/$(".southEast").hover(function(){$("#chevyMapNE").attr("src","http://www.billboard.com/photos/stylus/1035299-battle_of_the_bands_small_map_southeast.gif");},function(){$("#chevyMapNE").attr("src","http://www.billboard.com/photos/stylus/1035279-battle_of_the_bands_small_map_northeast.gif");});$(".southWest").hover(function(){$("#chevyMapNE").attr("src","http://www.billboard.com/photos/stylus/1035309-battle_of_the_bands_small_map_southwest.gif");},function(){$("#chevyMapNE").attr("src","http://www.billboard.com/photos/stylus/1035279-battle_of_the_bands_small_map_northeast.gif");});$(".midWest").hover(function(){$("#chevyMapNE").attr("src","http://www.billboard.com/photos/stylus/1035269-battle_of_the_bands_small_map_midwest.gif");},function(){$("#chevyMapNE").attr("src","http://www.billboard.com/photos/stylus/1035279-battle_of_the_bands_small_map_northeast.gif");});$(".northWest").hover(function(){$("#chevyMapNE").attr("src","http://www.billboard.com/photos/stylus/1035289-battle_of_the_bands_small_map_northwest.gif");},function(){$("#chevyMapNE").attr("src","http://www.billboard.com/photos/stylus/1035279-battle_of_the_bands_small_map_northeast.gif");});$(".west").hover(function(){$("#chevyMapNE").attr("src","http://www.billboard.com/photos/stylus/1035149-battle_of_the_bands_small_map_west.gif");},function(){$("#chevyMapNE").attr("src","http://www.billboard.com/photos/stylus/1035279-battle_of_the_bands_small_map_northeast.gif");});});</script>');


}


me.browserCSSAdjustment = function()
{
billboard.log("Billboard.browserCSSAdjustment()");



 if(navigator.userAgent.indexOf('Mac') > 0 && navigator.userAgent.indexOf('Firefox') > 0)
 {
$("#mainRightArrow").css("left","590px !important");
 }

//IE 7 FIX///
if($.browser.msie && $.browser.version =="7.0"){$("#wrapper").css("margin-top","-13px");}       
//IE 7 FIX///

                ////BB Pro Landing Page ///
if (jQuery.browser.opera) {$(".bb_pro_uncharted_item_img").css("margin-left","32px");}

if($.browser.msie && $.browser.version =="7.0"){$(".bb_pro_uncharted_item_divider").css("margin-left","97px");$(".bb_pro_uncharted_item_details p").css("margin-left","-15px");$(".bb_pro_uncharted_item_details_divider").css("left","-15px");$(".bb_pro_uncharted_item_play").css("margin-left","-13px");
$("#bb_pro_uncharted_header").css("margin-left","-255px");$("#bb_pro_uncharted_rankings").css("margin-top","22px");}
                ////BB Pro Landing Page ///     
                
////BBMA Photo Gallery CSS Fix ///              
if (jQuery.browser.opera) {$("#bbma-main-rotate-pp ul").css("max-width","32765px !important"); $("#bbma-main-rotate-pp ul").css("max-height","420px"); $("#bbma-main-rotate-pp ul").css("height","420px"); $("#bbma-main-rotate-pp ul").css("overflow","hidden");}              
////BBMA Photo Gallery CSS Fix ///                      

////BBCOM Photo Gallery CSS Fix ///             
if (jQuery.browser.opera)
	{
	$("#bbcomph-main-rotate-pp ul").css("max-width","32765px !important"); $("#bbcomph-main-rotate-pp ul").css("max-height","420px"); $("#bbcomph-main-rotate-pp ul").css("height","420px"); $("#bbcomph-main-rotate-pp ul").css("overflow","hidden");
	}          

$.browser.safari = ( $.browser.safari && /chrome/.test(navigator.userAgent.toLowerCase()) ) ? chrome = true : chrome = false ; 
if(chrome == true)
{
$("#bbcomph-credits").css("left","0px");
}
////BBCOM Photo Gallery CSS Fix ///    

// 
}




        /**
         *
         */
        me.initHotModule = function()
        {
                billboard.log("Billboard.initHotModule()");

                // show the proper container, based on random type
                var types = ["artist","album","song"];
                var type = types[Math.floor(Math.random()*3)];
                var count= 0;
                var module = $("#hot-"+type+"-container");
                var artistNm = "undefined";
                module.show();
                
                billboard.social.getHotItems( type, {numDays:1}, function(item){ 
                        var item;
                        var link;

                        item.id = item.id.split("-")[1];

                        billboard.getItemDetails( item.id, item.type, function(result){
                                count++; 

                                var result = typeof(result.response) != 'undefined' ? result.response.body.FavoriteItemView : '';
                                result.name = result.title;
                                
                                // determine url to image
                                var photo;
                                if(type == "song") {
                                        photo = "/images/defaults/"+type+"-69.gif";
                                }       else {
                                        photo = "/images/defaults/"+type+"-94.gif";
                                }

                                if ( result.photoUrl && result.photoUrl.length>0) { 
                                        photo = result.photoUrl;
                                }

                                for ( var p in result ) {
                                        item[p] = result[p];
                                }
                                
                                // create dom object
                                var elem = $("#hot-"+type+"-template").clone();
                                elem.removeAttr("id");
                                if(type== "song" && count==3) elem.addClass("last-song");
                                elem.find(".pic img").attr("src",photo);
                                elem.find(".pic a").attr("href",item.url);
                                if( type == "song" ){
                                        var links = new Array();
                                        if(result.artists && result.artists.length > 0){
                                                for(i=0; i < result.artists.length; i++){
                                                        links.push("<a href='"+         result.artists[i].link + "'> "+ result.artists[i].name + "</a> &nbsp;");
                                                }
                                                elem.find(".artist-name a").append(links.join(", "));
                                        }
                                }
                                else{
                                        elem.find(".artist-name a").text( (item.artist)?(item.artist):(item.title) );
                                        elem.find(".artist-name a").attr( "href", item.url );
                                }                               


                                
                                elem.find(".name a").text( item.name );
                                elem.find(".name a").attr( "href", item.url);
                                elem.find(".percent-like").text( item.loveHatePercentage+"%" );
                                elem.find(".total-comments").text( item.numComments );
                                elem.find(".total-comments").attr( "href", item.url+"#comment-container" );
                                elem.mouseover( function(){$(this).addClass("tout-highlight");});
                                elem.mouseout( function(){      $(this).removeClass("tout-highlight");});
                                //elem.append( $("<div class='lala-id' style='display:none'>"+result.lalaId+"</div>") );
                                //elem.append( $("<div class='lala-title' style='display:none'>"+result.name+"</div>") );
                                
                                // activate the play button
                                if ( type == "song" && result.song_url && result.song_url.length>0 ) {
                                        billboard.log( "<--song -->" );
                                        billboard.log( item );
                                        elem.find(".action").show();
                                        elem.find(".play-btn a").click( function() { 
                                                javascript:billboard.player.playMSSong(result.song_url);
                                                artistNm = $.trim($(this).parents(".song-row").find(".track-details .artist-name").text());
                                                googleA.trackEvent (1, 'Song', artistNm, item.name, photo, item.url);
                                                //billboard.facebook.publishPlay(item.name,artistNm,photo,item.url);
                                        });
                                        
                                }
                                else {
                                        elem.find(".play-btn a").hide(); 
                                }
                                elem.find(".action a").click( function() { 
                                        billboard.log("click");
                                        var id = $(this).parent().parent().find(".lala-id").text();
                                        var title = $(this).parent().parent().find(".lala-title").text();
                                        
                                        if ( id && title ) { 
                                        
                                        
                                        //var url = 'testing';
                                        
                                        //javascript:billboard.player.playMSSong(url);
                                        
                                        
                                        billboard.player.setQueue( [ {id:id,title:title} ] );
                                        //      googleA.trackEvent ( 1, 'Song', title, $(this).parents(".song-row").find(".track-details .artist-name").text() );
                                        }
                                });

                                elem.show();
                                
                                // add the element to the module
                                $(".hot-"+type+"s").append( elem );
                                billboard.hijackLinks( elem );
                        });
                });
        };
})(jQuery);

