if ( window.console == undefined || window.console.log == undefined ) {	window.console = { log:function(msg){ /* msg */ } } }

/**
 * 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;

	// 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.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()
	{	   
		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);
			  }
			  return false;
		 });

		$("#search-input").keypress(function(e){
			if (e.which == 13){
				$("#search-form").submit();
			}
		});		

		$("#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();		

		// start application
		if ( billboard.history.hash != billboard.history.defaultHash ) {
			me.load( billboard.history.hash );
		}
		else {
			me.setupPage();
		}
	};
	
	/**
	 * 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" ) {
			/* direction is reversed */
			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"));

			$(".feature-image-list-container").jCarouselLite({
				btnPrev: "#homepage-main .next",
				btnNext: "#homepage-main .previous",
				vertical: true,
				auto: 5000,
				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: 5000,
				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();
				}
			});
		}
		
		$("#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"
		});
		$(".the-feed .jCarouselLite").jCarouselLite({
			btnNext: ".the-feed .next",
			btnPrev: ".the-feed .prev",
			start: 0,
			visible: 4.54,
			speed: 500,
			circular: false,
			scroll: 4,
			easing: "easeinout"
		});
		$('.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).parent().addClass("active");
				$(".select-none").parent().removeClass("active");
			}
			return false;
        });
        $(".select-none").click( function() {
			var el = $(this).attr('rel').split("_");
			for(var i=0;i<el.length;i++){
				billboard.log("!!!"+el[i]);
				$("#" + el[i] + " INPUT[type='checkbox']").attr('checked', false);
				$(this).parent().addClass("active");
				$(".select-all").parent().removeClass("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 .daily-noise-header").click( function(){
			billboard.navigateToUrl("/column/dailynoise");
		});
		$(".news .chart-beat-header").click( function(){
			billboard.navigateToUrl("/column/chartbeat");
		});

		

		/**************************************************************************
		 *
		 * 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 );
	};

	/**
	 * 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).click( function(){
            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 ) {
				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 ) 
	{
		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();
							
                            }
                        }
                    }
			    });
			} 
			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();
        });		

		/**************************************************************************
		 *
		 * 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");		
});

