if ( window.console == undefined || window.console.log == undefined ) { window.console = { log:function(msg){ /* msg */ } } }

function parseUri (str) {
    var o   = {
                    strictMode: false,
                    key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
                    q:   {
                        name:   "queryKey",
                        parser: /(?:^|&)([^&=]*)=?([^&]*)/g
                    },
                    parser: {
                        strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
                        loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
                    }
                },
        m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
        uri = {},
        i   = 14;

    while (i--) uri[o.key[i]] = m[i] || "";

    uri[o.q.name] = {};
    uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
        if ($1) uri[o.q.name][$1] = $2;
    });

    return uri;
};



/**
 * Billboard Core
 * create the core javascript namespace for this site 'billboard'
 */
var billboard = new ( function($) 
{     
    var LOGGING_NONE = "noLogging";
    var LOGGING_INFO = "infoLogging";
    var LOGGING_VERBOSE = "verboseLogging";

    var ie = $.browser.msie;
    var ie6 = ie && parseInt($.browser.version) == 6;

    var me = this;

 	//me.flashBoxSpeed;
    // debug console for IE
    me.debug;
    me.useDebug = false;
    me.forceDebug = (window.location.href.indexOf("debug=true")>=0)?true:false;
    me.debugOdd = true;
    me.logging = LOGGING_VERBOSE;
    me.loggingOverride = false;

    /**
     * maintain past,present and future URLs
     */
    me.lastUrl = window.location;
    me.currentUrl = window.location.protocol+'//'+window.location.host+'/';
    /*(window.location.hash.length>0)?
                    (window.location.href.substr(0,window.location.href.indexOf("#"))):
                    (window.location.href);*/

    me.nextUrl = me.currentUrl;
    me.cacheBust = false;

    // CF and other props, sepecific to environment
    me.properties;

    // set a few defaults
    me.section = 'home';
    me.subsection = '';
    me.publicUser = '';
    me.entityId = '';
    

    // prepare a timer for performance auditing
    me.time = (new Date()).getTime();

    /**
     * central event dispatcher, through which all objects listen/broadcast
     */
    me.broadcaster = new EventBroadcaster();

    /**
     * reports a user specified message and the time difference between now and 
     * the last call of this method
     */
    me.timer = function( msg )
    {
        var newtime = (new Date()).getTime();
        billboard.log( "Timer: "+msg+" - " + ((newtime-me.time)/1000) + "sec" );
        me.time = newtime;
    };

    /**
     *
     */
    me.init = function()
    {    
    
                 
     $(".northEast").hover(
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_small_map_northeast.gif");},
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_small_map_northwest.gif");
     });
     
      $(".southEast").hover(
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_small_map_southeast.gif");},
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_small_map_northwest.gif");
     });
      
       $(".southWest").hover(
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_small_map_southwest.gif");},
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_small_map_northwest.gif");
     });
      $(".midWest").hover(
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_small_map_midwest.gif");},
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_small_map_northwest.gif");
     });
   /*   $(".northWest").hover(
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_small_map_northwest.gif");},
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_small_map_northwest.gif");
     });*/
    $(".west").hover(
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_small_map_west.gif");},
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_small_map_northwest.gif");
     });
    
    
      $(".northEastBig").hover(
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_big_map_northeast.gif");},
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_big_map_dead.gif");
     });
     
      $(".southEastBig").hover(
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_big_map_southeast.gif");},
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_big_map_dead.gif");
     });
      
       $(".southWestBig").hover(
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_big_map_southwest.gif");},
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_big_map_dead.gif");
     });
      $(".midWestBig").hover(
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_big_map_midwest.gif");},
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_big_map_dead.gif");
     });
      $(".northWestBig").hover(
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_big_map_northwest.gif");},
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_big_map_dead.gif");
     });
    $(".westBig").hover(
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_big_map_west.gif");},
          function(){$('#chevyMap').attr("src","http://skitillidie.com/images/sxsw/battle_of_the_bands_big_map_dead.gif");
     }); 
    
    
    /*    CHEVY */
    
    
    
    
    
        if ( ( $.browser.msie && me.useDebug ) || me.forceDebug ) { 
            billboard.createDebug();
        }

        billboard.info("billboard.init()");
        me.timer( "Core init" );
        
        /**
         * add className-s to <html> indicating
         * 1. that javascript is enabled (jsEnabled)
         * 2. if we are in IE, that we are (ie)
         * 3. if we are in IE, what version (ie6 or ie7 or..)
         */
        if ($.browser.safari) { 
            $.browser.version = navigator.userAgent.replace(/.*?Version.([0-9]).*/,'$1');
        }       
        $('html').addClass((($.browser.msie ? ' ie ie': $.browser.safari ? ' safari safari' : ' other') + parseInt($.browser.version)) );
        
        me.broadcaster.addListener( "hashChanged", function(hash) { me.onHashChanged(hash); } );

        // history needs to be inited immediately
        billboard.history.init();
        

        // check if there is an existing hash (possibly from a bookmark)
        billboard.info ( billboard.history.hash +" ?= " + billboard.history.defaultHash );
        if ( billboard.history.hash != billboard.history.defaultHash ) {
            billboard.info("=== clearing existing content ===");
            $("#content-container").empty();
        }

        // load the billboard properties
        $.getJSON( "/properties.json", function(data) {
            me.properties = data.response.body.IntegrationPropertiesView;
            me.properties.cfQuery = "subscriber="+me.properties.cfSubscriberId+
                "&product="+me.properties.cfProductId+
                "&topcommunity="+me.properties.cfTopCommunityId;
            me.properties.cfCategoryMap=data.response.body.map; 
            billboard.info( "- properties retrieved -" );
            me.initSubSystems();
        });

        me.initGlobalSearch();
    };


    /**
     * global search, this must happen ONLY ONCE, since the search box will not
     * get reloaded with new page loads and attaching multiple submit handlers will
     * eventually crash IE
     */
    me.initGlobalSearch = function()
    {
        $("#search-input").focus( function() {
            if($(this).val() == 'Find artists and music') $(this).val('');
            $("#header .search-field-container").css({backgroundPosition:"0 -29px"});
        });

        $("#search-input").blur( function() {
            $("#header .search-field-container").css({backgroundPosition:"0 0"});
        });

        $("#search-form").submit( function() { 
              var keyword = $("#search-input").val();
              if(keyword!="" && keyword!= "Find artists and music") {
                  newKeyord = keyword.replace(/[\/]/g, " "); // Added for BBRED09-1044
                  hash = "/search/"+newKeyord;
                  billboard.navigateToUrl( hash );
                  $("#search-input").blur();
                  setTimeout( function() {$("#search-input").val("Find artists and music");}, 1000);
                googleA.trackEvent(5, "Main Search", keyword);
              }
              
              return false;
         });

        $("#search-input").keypress(function(e){
            if (e.which == 13){
                $("#search-form").submit();
                return false;
            }
    
        });     

        $("#search-input").autocomplete(
                                        "/search-suggest.json",
                                        { 
                                            delay:500,  
                                            minChars:3, 
                                            matchContains:1,
                                            cacheLength:10,width:'319',
                                            json:true,
                                            jsonLocation: 'response.body.list',
                                            formatItem:formatItem,                                          
                                            jsonKey: 'name', 
                                            onItemSelect:function(){$("#search-form").submit();
                                        }
                                        });
                                        
         function formatItem(row) {
                //alert('row = '+decode(row[0]));
                return unescape(row[0],"ISO-8859-1");
        }
                                        
    };

    /**
     * 
     */
    me.initSubSystems = function()
    {
        me.timer("Core Init Complete");

        billboard.modules.init();
        billboard.metrics.init();              
        billboard.visualizer.init();               
        billboard.player.init();
        billboard.user.init();
        billboard.comments.init();
        billboard.grab.init();
        billboard.charts.init();
        billboard.tourFinder.init();
        billboard.profile.init();
        billboard.share.init();
        billboard.social.init();
        billboard.ads.init();
        billboard.sort.init();      
        billboard.artists.init();   
        billboard.siteConfig.init();
        billboard.video.init();

        // start application
        if ( billboard.history.hash != billboard.history.defaultHash ) {
            me.load( billboard.history.hash );
        }
        else {
            me.setupPage();
        }
    };

    me.reloadSlideshow = function()
    {
    	billboard.ads.dartAds();
    	billboard.metrics.trackPageView();
        COMSCORE.beacon({ 
          c1:2, 
          c2:7395269, 
          c3:"", 
          c4:"", 
          c5:"", 
          c6:"", 
          c15:"" 
        }); 

    };
    
    /**
     * builds a popup window with the debug (console.log) information for browser that dont 
     * support console.log()
     */
    me.createDebug = function()
    {       
        me.debug = window.open("about:blank", "debug","resizable=yes,scrollbars=yes,width=650,height=600"  );
        var debug = me.debug;
    };

    me.error = function( msg, suppressAlert ) 
    {
        me.log( "ERROR: "+msg );
        if ( !suppressAlert ) { 
            billboard.modal.show( "<div class='error-modal'><h4>Error</h4>"+msg+"</div>", true );
        }
    };

    me.alert = function( msg )
    {
        billboard.modal.show( "<div class='error-modal'><h4>Alert</h4>"+msg+"</div>", true );
    };

    me.info = function( msg )  
    {
        me.log( (typeof(msg)=="string")?("INFO: "+msg):(msg) );
    }

    me.log = function( msg ) 
    {
        if ( me.logging == LOGGING_NONE && !me.loggingOverride ) { 
            return;
        }
        if ( ( $.browser.msie && me.useDebug ) || me.forceDebug ) { 
            me.debugOdd = !me.debugOdd;
            var style = (me.debugOdd)?(""):("background-color: #efefef;");
            if ( me.debug ) {
                var div = "<div style='"+style+"font-size:10px;'>"                      
                    +"<pre style='margin:0 2px 0 2px;font-family:arial,sans-serif;font-size:12px;'>"
                    +msg+"</pre></div>";
                $(me.debug.document).find("body").append(div);
            }
        }
        else {
            console.log( msg );
        }
    };

    /**
     * recursively log all properties of an object - 
     *
     * NOTE: this is best suited for debugging in IE as firebug 
     * console has a good object explorer - use sparingly
     */
    me.logObject = function( obj, spaces ) 
    {
        spaces = spaces?spaces:"..";
        for ( var prop in obj ) {
            if ( typeof obj[prop] == "string" ) { 
                me.log( spaces + prop +" = " + obj[prop] );
            }
            else if ( typeof obj[prop] == "array" ) {
                me.log( spaces + prop +" = " + obj[prop] );
            }
            else {
                me.log( spaces + prop +":");
                me.logObject( obj[prop], spaces +".." );
            }
        }
    };

    /**
     * setupPage()
     *
     * all the contents of the current page have been loaded, and the system
     * will need to extract and update any page level properties, many of which
     * are set inside display:none <div>s
     */
    me.setupPage = function() 
    {

        billboard.info("billboard.setupPage()");

        me.timer("Setup Page Started");

        me.hideLoadingScreen();

        // get classes that need to be assigned to the body 
        var bodyClass = $("#body-class").text();       

        // pull and store the dynamic page properties for later user
        me.section = $("#section").text();
        me.subsection = $("#subsection").text();
        me.publicUser = $("#publicUser").text();
        me.entityId = $("#entity-id").text();
        me.title = $("#page-title").text();
        me.footerNote = $("#footer-note").text();
        me.logging = ($("#environment").text()=="prod")?(LOGGING_NONE):(LOGGING_VERBOSE);

        // set the window title on each page change
        document.title = me.title;  

        // assign the body level classes
        if (bodyClass != ""){
            $("body").removeClass();
            $("body").addClass(bodyClass);
        }

        // update footer copy
        $("#footer .footnote").text(me.footerNote);

        // show some debug info
        billboard.info( "section: "+me.section );
        billboard.info( "subsection: "+me.subsection );
        billboard.info( "publicUser: "+me.publicUser );

        // replace href's with click handlers to intercept and make ajax load instead
        // by default it will start at the root and traverse the whole DOM
        me.hijackLinks();

        // track the urls, 
        // Q. does this need to be fully qualified url?
        if ( me.nextUrl.indexOf("#") >= 0 ) {
            me.nextUrl = window.location.protocol + "//" + window.location.host + "/" + me.nextUrl.substr( me.nextUrl.indexOf("#") + 1 );
        }
        me.lastUrl = me.currentUrl;
        me.currentUrl = me.nextUrl;

        var evalScripts = $(".eval-script script");
        if ( evalScripts.length > 0 ){
            $.each(evalScripts,function(i,v){
               var evalScript = $(v).html();
/*
               var regEx = new RegExp(/([\s][^"\w+:,{}='"])/g);
               var regEx = new RegExp(/([\s\t\r\n][^"\w+:,{}='"])/g);
*/
               var regEx = new RegExp(/\s+/g);
               var regEx2 = new RegExp(/[\t\r\n]/g);
               evalScript = evalScript.replace(regEx,' ');
               evalScript = evalScript.replace(regEx2,'');   
           evalScript = $.trim(evalScript);
               //billboard.info("EVAL : " + evalScript);
               eval(evalScript);
            }); 
            billboard.info("END of evaling billboard on page scripts");
        }
        
        /**************************************************************************
         *
         * START REMOVE - All of the calls between the comment blocks must be moved
         *
         **************************************************************************/
        
        /* carousels -- temp place for this */
        if ( billboard.section == "home" ) {

//Grabs Speed For Flash Box ////
// /promo/speed-of-flash-box.json
$.ajax({
  url: '/promo/speed-of-flash-box.json',
  success: function(data) {
	var src =data;
	src = src.substring(110); 
	src = src.substring(-3, 9);
	var newSplit = src.split('"');

	var autoscrollTime = parseInt(newSplit[1]);

            var total = $(".feature-image-list-container ul li").length;
            var imgCount =  1;
            
            $('#homepage-main .count').text(imgCount+'/'+total);
            var s = new Scroller($(".noise-maker-holder"),$(".noise-maker-list"));
            s.makeDraggable($(".noise-maker-holder").find(".scroll-thumb"));

		//  if(billboard.siteConfig.autoscroll =='true'){ autoscrollTime = 7000;}

            $(".feature-image-list-container").jCarouselLite({
                btnPrev: "#homepage-main .next",
                btnNext: "#homepage-main .previous",
                vertical: true,
                auto: autoscrollTime,
                visible: 1,
                afterEnd: function(o){
                    $('#homepage-main .count').text(o.attr("id")+'/'+total);
                }
                
            });
            $(".feature-text-list-container").jCarouselLite({
                btnPrev: "#homepage-main .next",
                btnNext: "#homepage-main .previous",
                vertical: true,
                auto: autoscrollTime,
                visible: 1
            });
	  }});


        }
        else if (billboard.section == 'charts'){
            $("body").click(function(e){
                if($("#calendar").is(':visible')){
                    var top = $("#calendar").offset().top;
                    var left = $("#calendar").offset().left;
                    var right = left + $("#calendar").width();
                    var bottom = top + $("#calendar").height() + 50;
                    billboard.log("top:"+top+",left:"+left+",right:"+right+",bottom:"+bottom+",pagex:"+e.pageX+",pagey:"+e.pageY);
                    if((e.pageX < left || e.pageX > right)  || (e.pageY < top || e.pageY > bottom))
                        $("#calendar").hide();
                }
            });
        }
        else if(billboard.section == 'search'){
            if(billboard.user.isLoggedIn()){
                $('.search-users').attr('href', '/user/' + billboard.user.username + '/find');
            }
        }

        $("#related-artist-module .jCarouselLite").jCarouselLite({
            btnNext: ".related-artists .next",
            btnPrev: ".related-artists .prev",
            start: 0,
            visible: 3.54,
            speed: 500,
            circular: false,
            scroll: 2,
            easing: "easeinout",
            afterEnd: function(){$("#related-artist-module .prev").css("visibility","visible"); $("#related-artist-module .next").css("visibility","visible");}
        });
        $("#other-albums-module .jCarouselLite").jCarouselLite({
            btnNext: "#other-albums-module .next",
            btnPrev: "#other-albums-module .prev",
            start: 0,
            visible: 3.54,
            speed: 500,
            circular: false,
            scroll: 2,
            easing: "easeinout"
        });

        var theFeedPage = 3;
		var pageNumberLocal = -1;

		$.fn.updateCarouselPrevContent = function() {
			pageNumberLocal += -1;
			$(this).startCarouselPrev(-1);
		}

		$.fn.updateCarouselNextContent = function() {
			$.getJSON('/the-feed-next-page?pageNo=' + theFeedPage, function(data) {

				var articlesTotal = data.response.body.articlesNextPage.length;
				var articlesID = data.response.body.articlesNextPage;

				var resString = "";

				for( i=0; i < articlesTotal; i++){

				  var currentArticle = articlesID[i];
				  var currentInd = i+1;
				  var articleLIString = "";

				  if (currentArticle.articleId == "0"){
					continue;
				  }

				  var articleDate = new Date(currentArticle.issueDate.$.substring(0,10));
				  var articleDateString = "";

				  var month_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");	
				  var current_date = articleDate.getDate();
				  var current_month = articleDate.getMonth();
				  var current_year = articleDate.getFullYear();
				
				  articleDateString = current_date + " " + month_names[current_month] 	+ " " + current_year;

				  var indexPD = currentArticle.primaryDisplay.indexOf("/");
				  var storySection = currentArticle.primaryDisplay.substring(indexPD + 1);
					
				  if (storySection.indexOf("events") > -1) {
					 storySection = "live";
				  }

				  articleLIString = "<li class=\"feed-item\" style=\"overflow-x: hidden; overflow-y: hidden; float: left; width: 190px; height: 60px\">"
				  articleLIString += "<p class=\"title charts-text\">";
				  articleLIString += storySection;
				  articleLIString += "</p>";
				  articleLIString += "<p class=\"blurb\">";
				  articleLIString += "<a href =\"/" + currentArticle.primaryDisplay + "/" + currentArticle.titleInUrl + "-" + currentArticle.articleId + ".story\">";
				  articleLIString += currentArticle.title.substring(0, 57);
				  articleLIString += "</a>";
				  articleLIString += "</p>";
				  articleLIString += "<p class=\"post-date\">";
				  articleLIString += articleDateString;
				  articleLIString += "</p>";
				  articleLIString += "</li>";

				  resString += articleLIString;
				}
				$(".feed-items")[0].innerHTML += resString;
				var feedWidth = $(".feed-items")[0].style.width;
				var newFeedWidth = parseInt(feedWidth.substring(0, feedWidth.indexOf("px"))) + 190*5 + "px";
				$(".feed-items")[0].style.width = newFeedWidth;
			});
			pageNumberLocal += 1;
			$(this).startCarousel(1);
			theFeedPage += 1;
		}

		$.fn.startCarouselPrev = function(pageflag) {
			$(".the-feed .jCarouselLite").jCarouselLite({
				btnNext: ".the-feed .next",
				btnPrev: ".the-feed .prev",
				visible: 4.54,
				circular: false,
				speed: 1,
				scroll: 4,
				easing: "easeinout"
			});
	    };

		$.fn.startCarousel = function(pageflag) {
			$(".the-feed .jCarouselLite").jCarouselLite({
				btnNext: ".the-feed .next",
				btnPrev: ".the-feed .prev",
				start: (pageNumberLocal<0)?0:(pageNumberLocal)*4,
				visible: 4.54,
				speed: 1,
				circular: false,
				scroll: 4,
				easing: "easeinout"
			});
	    };

		$(this).startCarousel(0);

        $('.carousel-item').mouseover(function(){           
            var altAlbum = $(this).attr('desc');
            $(this).css("border", "2px solid #e1f3f8"); 
            $('.carousel-album-name div').toggle();
            $('.carousel-album-name div').text(altAlbum);           
            return false;
        });
        $('.carousel-item').mouseout(function(){            
            $(this).css("border", "2px solid #ffffff"); 
            $('.carousel-album-name div').toggle();
            $('.carousel-album-name div').text();
            return false;
        });
        
        $(".select-all").click( function() {
            var el = $(this).attr('rel').split("_");
            for(var i=0;i<el.length;i++){
                $("#" + el[i] + " INPUT[type='checkbox']").attr('checked', true);
                $(this).parents("ul").find(".active").removeClass("active");
                $(this).parent().addClass("active");
            }
            return false;
        });
        $(".select-none").click( function() {
            var el = $(this).attr('rel').split("_");
            for(var i=0;i<el.length;i++){
                $("#" + el[i] + " INPUT[type='checkbox']").attr('checked', false);
                $(this).parents("ul").find(".active").removeClass("active");
                $(this).parent().addClass("active");
            }
            return false;
        });
        
        /** top features background highlight **/
        $("#top-features .other-story, #top-story").mouseover( function(){
            bClass = $(this).find(".text").attr("class");
            bClass = bClass.split(' ');         
            $(this).addClass(bClass[bClass.length - 1]);
        });
        $("#top-features .other-story, #top-story").mouseout( function(){
            bClass = $(this).find(".text").attr("class");
            bClass = bClass.split(' ');         
            $(this).removeClass(bClass[bClass.length - 1]);
        });
        /** features background highlight **/
        $("#news-features .module, #other-features-wrapper .module").mouseover( function() {
            bClass = $(this).find(".text").attr("class").split(' ');
            bClass = bClass[bClass.length-1].split("-")[0];
            $(this).addClass(bClass+"-module-top");
            $(this).find('.unit').addClass(bClass+"-background");
        });
        $("#news-features .module,#other-features-wrapper .module").mouseout( function() {
            bClass = $(this).find(".text").attr("class").split(' ');
            bClass = bClass[bClass.length-1].split("-")[0];
            $(this).removeClass(bClass+"-module-top");
            $(this).find('.unit').removeClass(bClass+"-background");
        });
        $(".comment-jump").click (function() {
            var goToComments = billboard.history.hash+"#comment-container";
            billboard.history.setHash(goToComments);
        });
        /** entire tout linkable 
            <div class="ajax">
                <div class="toutLink">URL HERE</div>
            ...
            </div>
        **/
        
        $("#wrapper div.ajax").mouseover( function(){
            var hash = $(this).find("div.toutLink").text();
            if(hash && hash!="") $(this).addClass('clickable');

        });
        $("#wrapper div.ajax").click( function(){
            var hash = $(this).find("div.toutLink").text();
            if ( hash && hash.length > 0 && hash.indexOf("http") == -1 ) {
                billboard.navigateToUrl( hash );
            }
            else if(hash && hash.indexOf("http") > -1) {
                window.location = hash;
            }
        });
        
        $("#wrapper div.ajax a").click( function(e){
            if (!e) var e = window.event;
            e.cancelBubble = true;
            if (e.stopPropagation) e.stopPropagation();

        });
        /** touts that highlight on hover + heart and bubble highlight **/
        $("#wrapper div.highlight-me").mouseover(function(){
            $(this).addClass("tout-highlight");
        });
        $("#wrapper div.highlight-me").mouseout(function(){
            $(this).removeClass("tout-highlight");
        });

        /** for AOL highglight **/
        $("#wrapper .right-col-wrapper .aol-highlighting").mouseover(function(){
            $(this).addClass("aol-highlight");
        });
        $("#wrapper .right-col-wrapper .aol-highlighting").mouseout(function(){
            $(this).removeClass("aol-highlight");
        });

        //select box change
        $("#chart-history-select").change(onSelectChange);
        function onSelectChange(){ 
            var selected = $("#chart-history-select option:selected");        
            var output = "";   
            if(selected.val() != 0){
                output = selected.val();   
            }
            billboard.navigateToUrl(output);
        }  

        // column headers 
        $(".news .bb-underground-header").click( function(){
            billboard.navigateToUrl("/column/underground");
        });
     
      $(".news .tweets-of-the-week-header").click( function(){
            billboard.navigateToUrl("/column/tweets-of-the-week");
        });
      
        
        $(".news .chart-beat-header").click( function(){
            billboard.navigateToUrl("/column/chartbeat");
        });
        $(".news .photo-week-header").click( function(){
            billboard.navigateToUrl("/column/photo-of-the-week");
        });
        $(".news .viral-video-header").click( function(){
            billboard.navigateToUrl("/column/viralvideos");
        });
        $(".news .mashup-header").click( function(){
            billboard.navigateToUrl("/column/mashupmondays");
        });
        
        $(".news .the-juice-header").click( function(){
            billboard.navigateToUrl("/column/the-juice");
        });
        
        $(".news .tastemakers-header").click( function(){
            billboard.navigateToUrl("/column/tastemakers");
        });
        
		
		 $(".news .blogtalk-header").click( function(){
            billboard.navigateToUrl("/column/blogtalk-radio");
        });
		
		
		
        $('.artist-info-slideshow, .article-slideshow').mouseover(function(){
            if($(this).find(".slideshow-url").length!=0) $(this).find('img').addClass('hvr-bdr');
            $(this).find('.amount-btn').hide();
            $(this).find('.slideshow-btn').show();
            return false;
        });
        $('.artist-info-slideshow, .article-slideshow').mouseout(function(){
            if($(this).find(".slideshow-url").length!=0) $(this).find('img').removeClass('hvr-bdr');
            $(this).find('.amount-btn').show();
            $(this).find('.slideshow-btn').hide();
            return false;
        });
        $('.article-slideshow, .artist-info-slideshow').click(function(){
            var iframeSrc = $(this).parent().find(".slideshow-url").text();
            if(iframeSrc && iframeSrc != "")
                billboard.modal.show( "<iframe src='"+ iframeSrc +"?decorator=slideshow&confirm=true' scrolling='no' frameborder=0 width='961' height='800' id='slideshow-display'/>" );
        });


        /**************************************************************************
         *
         * END REMOVE - All of the calls between the comment blocks must be moved
         *
         **************************************************************************/
        

        me.timer("Page Loaded");

        me.broadcaster.dispatchEvent( "pageLoaded" );
    };
    
    /**
     * Billboard core is the only object that should listen to the hash changes
     * and afterwhich will trigger the private function loadPage()
     */
    me.onHashChanged = function( hash ) 
    {
        billboard.info("billboard.onHashChanged("+hash+")");

        // load page ajax-ey
        me.load( hash );

        try{
            if(pSUPERFLY)
                pSUPERFLY.virtualPage(hash); 
            else billboard.log("Chartbeat Error: pSUPERFLY is undefined");
        }
        catch(err) {
            billboard.log("Chartbeat Error: " + err);
        }
        
        // Begin comScore Tag 
        COMSCORE.beacon({ 
          c1:2, 
          c2:7395269, 
          c3:"", 
          c4:"", 
          c5:"", 
          c6:"", 
          c15:"" 
        }); 
    };

    /**
     * hijack all <a> nodes that do not have the 'no-ajax' class
     */
    me.hijackLinks = function( root ) 
    {
        root = (root)?(root):("#wrapper");
        // since we dont have control iver the facebook link (ie we cant add the no-ajax class
        // we will add it to the ignored links for hujackungf
        var selection = $(root).find("a:not(.no-ajax,#RES_ID_fb_login)");

        //billboard.info("Billboard.hijackLinks("+root+")");
        //billboard.info( "["+selection.length+"] links to hijack");
        $(selection).bind("mousedown", function(e){
            var url = parseUri($(this).attr("href")),
                new_href = '';
                
            if ((url.host == '' || url.host == window.location.host) && !url.anchor) {
                new_href = window.location.protocol+'//'+window.location.host+'#'+url.directory+url.file;
                if (url.query) new_href += '?'+url.query;
                $(this).attr("href", new_href);
            }
        });
        
        $(selection).bind("click", function(e){
            me.cacheBust = false;
            me.cacheBust = $(this).hasClass("cache-bust") ? true : false;
            var hash = $(this).attr("href");
            var before = hash;
            var after = "";
            if ( hash.indexOf("?") >= 0 ) {
                before = (hash.substr( 0, hash.indexOf("?") )).toLowerCase();
                after = hash.substr( hash.indexOf("?") );
            }
            hash = before + after;

            // sometimes the href comes in w/ absolute path (usually IE), strip it out to be cleaner
            if ( hash.indexOf(location.host) >= 0 ) {
                hash = hash.substr( hash.indexOf(location.host) + ( location.host.length ) );
            }

            if ( hash && hash.length > 0 && hash.indexOf("javascript") == -1 && 
                 hash.indexOf("http") == -1 ) {
                hash = hash.replace('#/', '/');
                billboard.info( "hijacked link clicked: "+hash );
                
                // trigger the call to navigate to the new hash/url
                billboard.navigateToUrl( hash );
                return false;
            }
            billboard.info("not hijacked: ["+hash+"]");
            return true;
        });
    };
    
    /**
     *
     */
    me.navigateToUrl = function( url ) 
    {
	if(typeof jpUnloadUnits != "undefined") { jpUnloadUnits(); }
        billboard.history.setHash( url );
    };

    me.goToUrl = function( url )
    {
        billboard.history.setHash( url );
    };

    /**
     * PRIVATE - NEVER CALL THIS DIRECTLY - instead call billboard.navigateToUrl();
     */
    me.load = function(url)
    {
        billboard.info("billboard.load("+url+")");

        // clear any existing modals, good for when an error is display
        // and the user clicks the 'back' button
        billboard.modal.hide();

        me.timer( "Showing Load Screen" );

        // show loading screen
        me.showLoadingScreen(url);
    };

    /**
     * PRIVATE - NEVER CALL THIS DIRECTLY - instead call billboard.navigateToUrl();
     */
    me.loadPage = function(url)
    {
        billboard.info("billboard.loadPage("+url+")");

        // clear any existing modals
        billboard.modal.hide();

        me.timer( "Load Page Start" );

        if ( url ) { 
            var qs = url.indexOf("?") > -1 ? "&" : "?"; 
            /* clean the url of an anchor that originall had a hash, save it off
               then scroll to it after succesful response */ 
            var cleanUrl = url;
            var scrollTo = '#content';
            if ( url.indexOf("#") > -1 ) {
                cleanUrl = url.substring(0,url.indexOf("#"));
                scrollTo = url.substring(url.indexOf("#"));
            } else if (url.indexOf("/HASH/") > -1) {
                cleanUrl = url.substring(0,url.indexOf("/HASH/"));
                scrollTo = "#" + url.substring(url.indexOf("/HASH/")+6);
            }
            me.nextUrl = location.protocol + "//" + location.host + url;
            var loadUrl = cleanUrl + qs + "decorator=service&confirm=true" + (me.cacheBust ? "&cachebust=" + (new Date()).getTime() : "");
            billboard.info( "url: " + loadUrl );
            try { 
                $.ajax({
                    type: "GET"
                    ,url: loadUrl
                    ,contentType: "text/html; charset=utf-8"
                    ,error:function(XMLHttpRequest, textStatus, errorThrown ) {
                        billboard.info("Page load 'error'");
                        billboard.error( "Page Loading Error" );
                    }
                    ,success:function(response, textStatus){
                        billboard.info("Page load 'complete: '"+textStatus);
                        me.timer("Page Data Loaded");
                        if ( textStatus=="success" ) { 
                            // its possible several requests are made, we only want the results of the last
                            // so compare against the hash which will always show current page
                            billboard.info( url +":" + billboard.history.hash );
                            if ( url == billboard.history.hash ) {
                                
                                // inject into the content-container <div>
                                $("#content-container")[0].innerHTML = (response);
                                
                                if(url.indexOf("#") > -1 || url.indexOf("/HASH/") > -1){
                                    setTimeout( function() {
                                        var jump =  $(scrollTo).offset().top;
                                        billboard.info("jump to " + scrollTo + " position = " + jump);
                                        $('html,body').animate( {scrollTop: jump }, 1000 );
                                    }, 1000);
                                }
                                else $('html,body').animate( {scrollTop: 0 }, 1000 );
                                
                                me.setupPage();
if ($("#billboard-article-author").length>0)
	window.pSUPERFLY.a.authors = $("#billboard-article-author")[0].innerHTML;
else
	window.pSUPERFLY.a.authors = "";
if ($("#billboard-article-section").length>0)
	window.pSUPERFLY.a.sections = $("#billboard-article-section")[0].innerHTML;
else
	window.pSUPERFLY.a.sections = "";

                            
                            }
                        }
                    }
                });
            } 
            catch ( er ) { 
                billboard.error("Page Loading Error");
            }
        }
    };

    /**
     * makes the content visible then fades the loading screen cover out
     */
    me.hideLoadingScreen = function()
    {
        $("#content-container").css("visibility","visible");
        $("#load-screen-container").fadeOut("fast");
    };

    /**
     * showLoadingScreen
     *
     * This modal screen covers the page while the new/next page is loading 
     *
     */
    me.showLoadingScreen = function( url )
    {
        var h = $('#load-container');  
        var docSize = {  
            width: (h.width()>0)?(h.width()):969
            ,height: h.height()
        };
        $("#load-message").html(
            '<img src="/images/icons/ajax-loader.gif" />'
            + '<p>Getting info...</p>'
        );
        $("#load-screen").css({
            "width" : docSize.width - 7
            , "height" : docSize.height + 119
        });
        $("#load-screen-container").fadeIn("fast", function() { 
            if ( url ) me.loadPage( url );
        });
    };

    /**
     * pull down an object's information from a given type and id
     * data returned will typically consist of, depending on type,
     * artists, title, paths to related images
     *
     * 1)   http://localhost:7001/favorite-song.json?id=3424094
     * 2)   http://localhost:7001/favorite-album.json?id=3421
     * 3)   http://localhost:7001/favorite-artist.json?id=1006
     * 4)   http://localhost:7001/favorite-news.json?id=xxxx
     */
    me.getItemDetails = function( id, type, callback ) 
    {
        if ( typeof(id)=="undefined" || typeof(type)=="undefined" || typeof(callback)=="undefined" ) { 
            billboard.error( "getItemDetails() -  a required parameter was null", true );
            return;
        }
        if(type != "song" && type != "album" && type != "artist"){
            type="article";
        }

        if ( type == "news" ) type = "article";
        var url = "/favorite-"+type+".json?id="+id;
        $.getJSON( url, function(data,status) {
            //billboard.info( "getItemDetails result: "+status );
            /**
             * check the net status and the message status. The message status will be either
             * "success", or "error" (typically when item is not found)
             */
            if ( status == "success" && data.response.head.status != "error" ) { 
                data.response.body.FavoriteItemView.type = type;
                callback( data);
            }
            else {
                callback( {} );
            }
        });
    };


    /**
     * onload... any script placed within this block will be executed 
     * onLoad event of the initial page only
     */
    $( function() 
    {       
        //billboard.log("billboard onLoad");
        billboard.init();

        /**************************************************************************
         *
         * START REMOVE - All of the calls between the comment blocks must be moved
         *
         **************************************************************************/
        /* toggled heart from grey to gold for blue row hovers */
        $('.track-row,.news-row,.hot-album,.hot-artist,.song-row').mouseover(function(){
            $(this).find('span.percent-like').css({backgroundPosition: '0px -14px'});
            $(this).find('a.total-comments').css({backgroundPosition: '0px -15px'});
            return false;
        });     
        $('.track-row,.news-row,.hot-album,.hot-artist,.song-row').mouseout(function(){
            $(this).find('span.percent-like').css({backgroundPosition: '0px 0px'});
            $(this).find('a.total-comments').css({backgroundPosition: '0px 0px'});
            return false;
        });
        /* toggling edit boxes */
        $('.setting-row .setting-edit').click(function(){       
            $(this).parent().parent().find('.change-fields').toggle();
            return false;
        });
        /* artist section launch visualizer top link */
        $('.artist .visualizer-launch').mouseover(function(){
            /* $(this).css({backgroundPosition: '0px 0px'}); */
            return false;
        });     
        $('.artist .visualizer-launch').mouseout(function(){
            /* $(this).css({backgroundPosition: '0px -45px'}); */
            return false;
        });
        /* select all / none toggling */
        
        $(".conversation-comments .add-comment").click(function(){
            $('.new-comment').show();
        });
        $(".conversation-comments .cancel").click(function(){
            $('.new-comment').hide();
        });
        $("#artist-conversations .start-new-convo").click(function(){
            $('.new-conversation').show();
        });
        $(".new-conversation .cancel").click(function(){
            $('.new-conversation').hide();
        });     
        
        
         /// NEEDED TO REFRESH ADS ON CLICK IN THE BBMA PHOTO GALLERIES///         
                function flashBoxSpeed(src)
{
/*
		$.getJSON('/conf/speed.js', function(data) { 
								   
		  	me.flashBoxSpeed  = data.response.body.speed;
		 
	alert("inside"+me.flashBoxSpeed);
		  	//$('#flash_box_speed').html(autoscrollTimeJSON);
		 
		 
		 }); ///JSON call for Speed of Flash box on home page/////
*/

alert("src =" +src);

	
var autoscrollTime = src;

 
			alert("the new scroll time is: " +autoscrollTime);

            var total = $(".feature-image-list-container ul li").length;
            var imgCount =  1;
            
            $('#homepage-main .count').text(imgCount+'/'+total);
            var s = new Scroller($(".noise-maker-holder"),$(".noise-maker-list"));
            s.makeDraggable($(".noise-maker-holder").find(".scroll-thumb"));

		//  if(billboard.siteConfig.autoscroll =='true'){ autoscrollTime = 7000;}
			
			
			
            $(".feature-image-list-container").jCarouselLite({
                btnPrev: "#homepage-main .next",
                btnNext: "#homepage-main .previous",
                vertical: true,
                auto: autoscrollTime,
                visible: 1,
                afterEnd: function(o){
                    $('#homepage-main .count').text(o.attr("id")+'/'+total);
                }
                
            });
            $(".feature-text-list-container").jCarouselLite({
                btnPrev: "#homepage-main .next",
                btnNext: "#homepage-main .previous",
                vertical: true,
                auto: autoscrollTime,
                visible: 1
            });
   
}
        
    

        /**************************************************************************
         *
         * END REMOVE - All of the calls between these comment blocks must be moved
         *
         **************************************************************************/

    });//end onload
})(jQuery);

/**
 * DO NOT USE THIS - use the frmework's event broadcasting.. pageloaded
 */
$(document).ready( function() { 
    billboard.log("document ready");
});    

/**
 * window loaded functionality here
 */
$(window).load( function() {        
    billboard.log("window onload");     
});


