/*!
 * jQuery UI Widget 1.8.11
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Widget
 */
(function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)b(d).triggerHandler("remove");k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){b(this).triggerHandler("remove")});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,
a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.charAt(0)==="_")return h;
e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=b.extend(true,{},this.options,
this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},
widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},
enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);




$.fn.valign = function(val) {
    // should be called with right this!!!
    var doValign = function() {
        var ph = $(this).parent().height(),
            h = $(this).height(),
            mt;
        
        switch (val) {
            case "top":
                mt = 0;
                break;
            case "middle":
                mt = (ph - h)/2;
                break; 
            case "bottom":
                mt = ph - h;
                break; 
        }

        $(this).css("marginTop", mt);
    }

    return this.each(function(){
        if (this.tagName.toLowerCase() == 'img')
            $(this).onImageLoad(doValign);
        else
            doValign.call(this);
    });
}


$.fn.onImageLoad = function(cback) {
    return this.each(function(){
        if (this.complete || this.readyState === 4 || this.readyState === 'complete') {
            cback.call(this);
        } else {
            $(this).bind('load', function(){    
                cback.call(this);
            });
        }
    });
}



$.widget("ui.hscroll", {
    options: {
        scrollLeftButton: null,
        scrollRightButton: null,
        selector: null,
        minX: 0,
        maxX: 0
    },
    _create: function() {
        var o = this.options,
            e = this.element,
            _this = this;

        o.wrapper = e.css("overflow", "hidden").wrapInner('<div />').children().css({ margin: 0, padding: 0, "float": "left" });
        
        var wd = 0;
        o.wrapper.find(o.selector).each(function() {
            wd += $(this).outerWidth(true);
        }).end().width(wd);
        
        o.scrollLeftButton.addClass("ui-hscroll-left");
        o.scrollRightButton.addClass("ui-hscroll-right");
        
        o.minX = e.width() - wd;
        o.maxX = 0;
        
        var md = function(){
            var dir = $(this).hasClass('ui-hscroll-left') ? 30 : -30;
            _this.options.scrollIntervalId = setInterval(function() {_this.doScroll(dir)}, 100);
            return false;
        }

        o.scrollLeftButton.add(o.scrollRightButton)
            .bind("mousedown", md)
            .bind("mouseup", function(){ _this.stopScroll(); })
            .bind("mouseleave", function(){_this.stopScroll(); })
            .bind("click", function(){ return false; });
            
        this.doScroll(0);
    },
    stopScroll: function() {
        clearInterval(this.options.scrollIntervalId);
    },
    doScroll: function(dx) {
        var o = this.options,
            d = parseInt(o.wrapper.css("marginLeft"), 10) + dx;

        if (o.minX >= d) {
            d = o.minX;    
            o.scrollRightButton.removeClass("active");
        } else {
            o.scrollRightButton.addClass("active");
        }
        if (o.maxX <= d) {
            d = o.maxX;
            o.scrollLeftButton.removeClass("active");
        } else {
            o.scrollLeftButton.addClass("active");
        }

        o.wrapper.css("marginLeft", d);
    }
});


$.widget("ui.hscrollClicker", {
    options: {
        scrollLeftButton: null,
        scrollRightButton: null,
        selector: null,
        animationProcess: false
    },
    _create: function() {
        var o = this.options,
            e = this.element,
            _this = this;

        o.wrapper = e.css("overflow", "hidden").wrapInner('<div />').children().css({ margin: 0, padding: 0, "float": "left" });
        
        var wd = 0;
        o.count = 1;
        o.wrapper.find(o.selector).each(function() {
            wd += $(this).outerWidth(true);
            o.count++;
        }).end().width(wd);
        
        o.scrollLeftButton.addClass("ui-hscroll-left");
        o.scrollRightButton.addClass("ui-hscroll-right");
        
        o.minX = e.width() - wd;
        o.maxX = 0;
        
        o.currentIndex = 0;
        this.updateButtons();
        
        o.scrollLeftButton.add(o.scrollRightButton)
            .bind("click", function(){
                if (_this.options.animationProcess) return false;
                
                var el, sign;
                if ($(this).hasClass("ui-hscroll-left")) {
                    el = _this.getPrev();
                    if (el.size()) _this.options.currentIndex--;
                    sign = '+';
                } else {
                    el = _this.getNext();
                    if (el.size()) _this.options.currentIndex++;
                    sign = '-';                    
                }
                
                if (el.size()) {
                    _this.options.animationProcess = true;
                    _this.options.wrapper.animate({
                        marginLeft: sign+'='+el.width()+'px'
                    },
                    "normal",
                    function(){
                        _this.options.animationProcess = false;
                    });
                    _this.updateButtons();
                }
            
                return false;
            });
    },
    updateButtons: function() {
        if (this.getPrev().size())
            this.options.scrollLeftButton.addClass("active");
        else
            this.options.scrollLeftButton.removeClass("active");
    
        if (this.getNext().size())
            this.options.scrollRightButton.addClass("active");
        else
            this.options.scrollRightButton.removeClass("active");
    },
    getNext: function() {
        var o = this.options, i = o.currentIndex+1;
        
        return o.wrapper.find(o.selector+':eq('+i+')');
    },
    getPrev: function() {
        var o = this.options, i = o.currentIndex-1;
        
        return (i < 0) ? $('#_bbma_empty_id_here') : o.wrapper.find(o.selector+':eq('+i+')');
    }
    
});





/**
 * ad loading, refreshing... this is the object that will be the layer between the Billboard
 * framework and the Ad Serving vendor. Currently that vendor is DART.
 */
billboard.ads = new ( function ($)
{
    var me = this;
    me.init = function () 
    {
        billboard.info("Ads.init()");
        // listen for page changes to refresh the ads
        billboard.broadcaster.addListener( "pageLoaded", function () 
        {
            me.onPageLoaded() 
        } );
    }
    /**
     */
    me.onPageLoaded = function () 
    {
        billboard.info("Ads.onPageLoaded()");
        me.updateAdInfo();
                /*Image crop script*/
                $(document).ready(function() {                    
                    $('img#image_crop').imageCrop({
                        selectionWidth : 370,
                        selectionHeight : 484,
                        allowResize : true,
                        allowSelect : false,
                        displayPreview : true,
                        displaySize : true,
                        overlayOpacity : 0.5,
                        onSelect : updateForm
                    });
                });
                
        var bbma_check = $("#unique-id").html();
        var artist_check = $("#unique-id").html();
        var split_bbma_check = bbma_check.split("/");
        var bbma = split_bbma_check[0];
        if (bbma == 'bbma')
        {
            $("body").css("background", "url('/images/bbma/bbma-background-gradient.gif') repeat-x scroll left top #373737");
            $("#bbma-header, #bbma-header-fill").css("display", "block");
            $(".article-pagination, #news-header, .feature-abstract, #dynamic-content").css("display", "none");
            $(".module-top-small").css("background", "");
            $(".article-wrapper").css("background-color", "#232323");
            $(".outbrainContainer").remove();
            $(".ad-unit-top").html('');
            $("#dynamic-bbma-share").html('');
            $("#bbma-header-fill").html('<div id="bbma-header"><div id="bbma-countdown"><div id="bbma-timer" ></div><div></div></div><div id="bbma-logo"><img src="http://www.billboard.com/images/bbma/bbma-logo.png"></div><div id="bbma-sponsors"><img src="http://www.billboard.com/images/bbma/bbma-sponsors.png"></div><div style="float: left; font-size: 14px; font-weight: bold; color: rgb(255, 255, 255); font-family: arial; margin-top: -55px;"><img width="215" src="http://www.billboard.com/images/bbma/abc-date-time-image.png" style="float: left;"></div>');
            /////IE 7 CSS FIXES///////
            if($.browser.msie && $.browser.version=="7.0")
            {
                $('#bbma-video-all-button').css("margin-top","-23px");
                $('#bbma-video-holder').css("margin-top","15px");
                $('#BBMA-Nav-holder').css("margin-left","40px");
                $('#BBMA-Nav-holder').css("margin-top","-38px");
                $('#photoLeftArrow').css("left","325px");
                $('#bbma-main-image-caption').css("margin-top","7px");
                $('#finalist-cat').css("margin-top","-5px");
                $('#bbma-small-photo-holder').css("height","268px");
                
            }
            /////////////////////////
            
            
            if ($("#bbma-photos-page, #bbma-finalist-page").size()) {
                $("#bbma-photos-page, #bbma-finalist-page").parent().css("width", "100%");
            }
            if ($("#twitter_right_block").size()) 
            {
                new TWTR.Widget(
                {
                    version : 2, type : 'search', search : 'billboard', id : "twitter_right_block", 
                    interval : 5000, title : 'Billboard', subject : 'Billboard Music Awards', width : 300, 
                    height : 200, theme : 
                    {
                        shell : {
                            background : '#1d1d1d', color : '#ffffff' 
                        },
                        tweets : {
                            background : '#1d1d1d', color : '#ffffff', links : '#b39419' 
                        }
                    },
                    features : 
                    {
                        scrollbar : true, loop : true, live : true, hashtags : true, timestamp : true, 
                        avatars : false, toptweets : false, behavior : 'default' 
                    }
                }).render().start();
            }
            ///BBMA SHARE/////
            var URL = location.href;
            URL = URL.replace('/#/', '/');
            $("#dynamic-bbma-share").css({
                'display' : 'block', 'top' : 'auto', 'z-index' : '1000','bottom' : '52%' 
            });
            $("#dynamic-bbma-share").html('<div style="width:75px; background: url("/images/bbma/bbma-share-background.png") repeat scroll 0% 0% transparent; height: 131px; left: 0px; position: fixed; bottom: 52%;" id="bbma-social-buttons"><iframe scrolling="no" frameborder="0" allowtransparency="true" id="fb_like_btn" style="height: 20px; width: 75px; margin-top: 5px; margin-left: 5px; border: medium none;" src="http://www.facebook.com/widgets/like.php?href=' + URL + '&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;height=20&amp;action=like&amp;"></iframe><div style="margin-top:12px; margin-left:5px;"><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="margin-top:12px; margin-left:5px;"><a addthis:title="Billboad Music Awards | Billboard.com/bbma" addthis:url="' + URL + '" class="addthis_button_facebook at300b" href="http://www.addthis.com/bookmark.php?v=250&amp;winname=addthis&amp;pub=billboardcom&amp;source=tbx-250&amp;lng=en-US&amp;s=facebook&amp;url=' + escape(URL) + '&amp;title=Billboard Music Awards&amp;ate=AT-billboardcom/-/-/4da49447dbb72e8b/1&amp;uid=4da494474f425c02&amp;tt=0" style="font-size: 14px; font-weight: bold; color: rgb(255, 255, 255); text-decoration:none;" target="_blank" title="Send to Facebook"><span style="float: left;" class="at300bs at15t_facebook"></span><span style="margin-left: 5px;">share</span></a></div><div style="margin-top: 20px; margin-left: 5px;"><a style="font-size: 14px; font-weight: bold; color: rgb(255, 255, 255); text-decoration: none;" addthis:title="Billboard Music Awards | Billboard.com/bbma" addthis:url="' + URL + '" class="addthis_button_digg at300b" href="http://www.addthis.com/bookmark.php?v=250&amp;winname=addthis&amp;pub=billboardcom&amp;source=tbx-250&amp;lng=en-US&amp;s=digg&amp;url=' + escape(URL) + '&amp;title=Billboard Music Awards&amp;ate=AT-billboardcom/-/-/4da4995f3d62f4ec/2&amp;uid=4da4995f751689e8&amp;tt=0" target="_blank" title="Digg This"><img height="20" width="20" style="float: left;" alt="Digg" src="http://static.machoarts.com/images/digg_32.png"><span style="margin-left: 5px; float: left;">digg</span></a></div></div>');
                        
            ////BBMA LANDING PAGE HIDE AD////
            if (bbma_check == "bbma/home") 
            {
                var bbma_landing = "yes";
                $('#bbma-ad-top').html('');
                $("#bbma-ad-top, #bbma-h1-header").css("display", "none");
            }
            else 
            {
                var bbma_landing = "no";
                $('#bbma-ad-top').html('');
                $("#bbma-ad-top, #bbma-h1-header").css("display", "block");
            };
            
            
            /************************/
            var $cur_bbma_page = $(".bbma-page-wrapper");
            if ($cur_bbma_page.size()) {
                var $p = $cur_bbma_page.parent().css({
                    width: "960px",
                    margin: "0"
                })
                $p = $p.parent();
                if ($p.hasClass("article-wrapper")) {
                    $p.css("background", "transparent")  /*.article-wrapper*/
                      .parent().css("background", "transparent")  /*.module-middle*/
                      .parent().css("background", "transparent")  /*.module-bottom*/
                      .parent().css("background", "transparent"); /*.module-top-small*/
                } else if ($p.hasClass("main-article")) {
                    $p.css("position", "relative");
                }

            
            
                $("#bbma-home-news-holder").hscroll({
                    scrollLeftButton: $("#bbma-home-news-moveleft"),
                    scrollRightButton: $("#bbma-home-news-moveright"),
                    selector: ".bbma-home-news-item"
                });
                
                $("#bbma-home-finalists-holder").hscrollClicker({
                    scrollLeftButton: $("#bbma-home-finalists-moveleft"),
                    scrollRightButton: $("#bbma-home-finalists-moveright"),
                    selector: ".bbma-home-finalists-catitem"
                }).find(".bbma-home-finalists-item img").onImageLoad(function(){
                    $(this).next().valign("middle");
                });
                
                $("#bbma-home-photo-holder").hscrollClicker({
                    scrollLeftButton: $("#bbma-home-photo-moveleft"),
                    scrollRightButton: $("#bbma-home-photo-moveright"),
                    selector: "img"
                });


                if ($cur_bbma_page.attr('id') == 'bbma-finalists-page')
                    $cur_bbma_page
                        .find(".bbma-finalists-item.winner")
                        .append('<span class="trophy" />');
            }
            
            
            
        }
        else 
        {
            $("body").css("background", "url('/images/backgrounds/body.gif') repeat-x scroll left top #D8D6D7");
            $(".article-pagination, #news-header, .feature-abstract, #dynamic-content").css("display", "block");
            $("#bbma-header-fill").css("display", "none");
            $(".article-wrapper").css("background-color", "#ffffff");
			 $(".ad-unit-top").html('');
            setTimeout(function (){ $("#bbma-ad-top, #dynamic-bbma-share").css("display", "none");}, 0);
                        
                        
                        

                        
                        
        
        }
        
     
        $(document).ready(function () 
        {
                        
            $(function ()
            {
                var austDay = new Date();
                austDay = new Date(austDay.getFullYear() + 1, 0 - 8, 22, 21);
                $('#bbma-timer').countdown(
                {
                    until : austDay, format : 'DHMS', layout : '<div id="timer_days" class="timer_numbers">{dnn}</div>' + '<div id="timer_hours" class="timer_numbers">{hnn}</div>' + '<div id="timer_mins" class="timer_numbers">{mnn}</div>' 
                });
                                
            });
                        
                        
                        var autoscrollTime = 5000;

                // Universal Photo Gallery////
                 $("#main-rotate-bonnaroo2011").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow-bonnaroo2011", btnNext : "#mainRightArrow-bonnaroo2011", vertical : false, auto : autoscrollTime, 
                visible : 1, afterEnd : function (o) {}
            });
             
                         
                         $("#main-image-caption-bonnaroo2011").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow-bonnaroo2011", btnNext : "#mainRightArrow-bonnaroo2011", vertical : true, auto : autoscrollTime, 
                visible : 1, afterEnd : function (o) {}
            });  
                          
         // Universal Photo Gallery////     
		 
			var flashboxspeed = parseInt($("#flashBoxSpeed").text());
            $("#bbflashbox-main-rotate").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow", btnNext : "#mainRightArrow", vertical : false, auto : flashboxspeed, 
                visible : 1, afterEnd : function (o) {}
            });
			
            $("#bbflashbox-main-image-caption").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow", btnNext : "#mainRightArrow", vertical : true, auto : flashboxspeed, 
                visible : 1, afterEnd : function (o) {}
            });		 
		 
		   // Jessie Photo Gallery////
               $("#main-rotate-Jessie").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow-Jessie", btnNext : "#mainRightArrow-Jessie", vertical : false, auto : 100000000, 
                visible : 1, afterEnd : function (o) {}
            });
             
                         
                         $("#main-image-caption-Jessie").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow-Jessie", btnNext : "#mainRightArrow-Jessie", vertical : true, auto : 100000000, 
                visible : 1, afterEnd : function (o) {}
            });             
         // Jessie Photo Gallery////     
                          
                          
           $("#bbma-main-rotate").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow", btnNext : "#mainRightArrow", vertical : false, auto : autoscrollTime, 
                visible : 1, afterEnd : function (o) {}
            });
            
            
            $("#bbbma-small-photo-gallery").jCarouselLite(
            {
                btnPrev : "#photoLeftArrow", btnNext : "#photoRightArrow", vertical : false, auto : 0, 
                visible : 1, afterEnd : function (o) {}
            });
            
            
            $("#bbma-main-image-caption").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow", btnNext : "#mainRightArrow", vertical : true, auto : autoscrollTime, 
                visible : 1, afterEnd : function (o) {}
            });
            
                                                

                        $("#bbma-main-rotate-pp").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow", btnNext : "#mainRightArrow", vertical : false, auto : 0, 
                visible : 1, afterEnd : function (o) {/*refreshBBMA();*/}
            });
            
            $("#bbma-main-image-caption-pp").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow", btnNext : "#mainRightArrow", vertical : true, auto : 0, 
                visible : 1, afterEnd : function (o) {}
            });

            $("#bbcomph-main-rotate-pp").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow", btnNext : "#mainRightArrow", vertical : false, auto : 0, 
                visible : 1, afterEnd : function (o) {$("#bbcgallery-photo-counter #current-img-index").text($(o[0]).attr("id"));}
            });
            
            $("#bbcomph-main-image-caption-pp").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow", btnNext : "#mainRightArrow", vertical : true, auto : 0, 
                visible : 1, afterEnd : function (o) {}
            });
			
			
			 $("#bbcomph-credits").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow", btnNext : "#mainRightArrow", vertical : true, auto : 0, 
                visible : 1, afterEnd : function (o) {}
            });
            
			
			
			
			 $("#jessie-j-photo-holder").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow-jess", btnNext : "#mainRightArrow-jess", vertical : true, auto : 0, 
                visible : 1, afterEnd : function (o) {}
            });
			
			 $("#jess-j-photo-captions").jCarouselLite(
            {
                btnPrev : "#mainLeftArrow-jess", btnNext : "#mainRightArrow-jess", vertical : true, auto : 0, 
                visible : 1, afterEnd : function (o) {}
            });
			
						
			
			
            
            $("#catLeftArrow").live('click', function () 
            {
                var text = $("#bbma-finalist-cat-title img").attr("alt");
                if (text == "TOP ARTIST")
                {
                    $("#bbma-top-touring-artist").css("display", "block");
                    $("#bbma-top-artist").css("display", "none");
                    $("#bbma-finalist-cat-title img").attr("alt", 'TOP TOURING ARTIST');
                    $("#bbma-finalist-cat-title img").attr("src", '/images/bbma/bbma-top-touring-artist.png');
                }
                else if (text == "TOP NEW ARTIST")
                {
                    $("#bbma-top-artist").css("display", "block");
                    $("#bbma-top-new-artist").css("display", "none");
                    $("#bbma-finalist-cat-title img").attr("alt", 'TOP ARTIST');
                    $("#bbma-finalist-cat-title img").attr("src", '/images/bbma/bbma-top-artist.png');
                }
                else if (text == "TOP BILLBOARD 200 ALBUM")
                {
                    $("#bbma-top-new-artist").css("display", "block");
                    $("#bbma-top-billboard-200-album").css("display", "none");
                    $("#bbma-finalist-cat-title img").attr("alt", 'TOP NEW ARTIST');
                    $("#bbma-finalist-cat-title img").attr("src", '/images/bbma/bbma-top-new-artist.png');
                }
                else if (text == "TOP HOT 100 SONG")
                {
                    $("#bbma-top-billboard-200-album").css("display", "block");
                    $("#bbma-top-hot-100-song").css("display", "none");
                    $("#bbma-finalist-cat-title img").attr("alt", 'TOP BILLBOARD 200 ALBUM');
                    $("#bbma-finalist-cat-title img").attr("src", '/images/bbma/bbma-top-billboard-200-album.png');
                }
                else if (text == "TOP TOURING ARTIST")
                {
                    $("#bbma-top-hot-100-song").css("display", "block");
                    $("#bbma-top-touring-artist").css("display", "none");
                    $("#bbma-finalist-cat-title img").attr("alt", 'TOP HOT 100 SONG');
                    $("#bbma-finalist-cat-title img").attr("src", '/images/bbma/bbma-top-hot-100-song.png');
                }
            });
            
            
            
            $("#catRightArrow").live('click', function () 
            {
                var text = $("#bbma-finalist-cat-title img").attr("alt");
                if (text == "TOP ARTIST")
                {
                    $("#bbma-top-new-artist").css("display", "block");
                    $("#bbma-top-artist").css("display", "none");
                    $("#bbma-finalist-cat-title img").attr("alt", 'TOP NEW ARTIST');
                    $("#bbma-finalist-cat-title img").attr("src", '/images/bbma/bbma-top-new-artist.png');
                }
                else if (text == "TOP NEW ARTIST")
                {
                    $("#bbma-top-billboard-200-album").css("display", "block");
                    $("#bbma-top-new-artist").css("display", "none");
                    $("#bbma-finalist-cat-title img").attr("alt", 'TOP BILLBOARD 200 ALBUM');
                    $("#bbma-finalist-cat-title img").attr("src", '/images/bbma/bbma-top-billboard-200-album.png');
                }
                else if (text == "TOP BILLBOARD 200 ALBUM")
                {
                    $("#bbma-top-hot-100-song").css("display", "block");
                    $("#bbma-top-billboard-200-album").css("display", "none");
                    $("#bbma-finalist-cat-title img").attr("alt", 'TOP HOT 100 SONG');
                    $("#bbma-finalist-cat-title img").attr("src", '/images/bbma/bbma-top-hot-100-song.png');
                }
                else if (text == "TOP HOT 100 SONG")
                {
                    $("#bbma-top-touring-artist").css("display", "block");
                    $("#bbma-top-hot-100-song").css("display", "none");
                    $("#bbma-finalist-cat-title img").attr("alt", 'TOP TOURING ARTIST');
                    $("#bbma-finalist-cat-title img").attr("src", '/images/bbma/bbma-top-touring-artist.png');
                }
                else if (text == "TOP TOURING ARTIST")
                {
                    $("#bbma-top-artist").css("display", "block");
                    $("#bbma-top-touring-artist").css("display", "none");
                    $("#bbma-finalist-cat-title img").attr("alt", 'TOP ARTIST');
                    $("#bbma-finalist-cat-title img").attr("src", '/images/bbma/bbma-top-artist.png');
                }
            });
        });
        
        
                
        $(".ad-unit-top").html('');
        $(".ad-unit-hp_top").empty();
        $(".ad-unit-top,#resizableIframeTOP, #resizableIframeHPTOP, #Top_AD, #HPTop_AD,#middle1,#resizableIframeM1,#middle2,#resizableIframeM2,#Anchor_AD,#resizableIframeAnchor").css(
        {
            'height' : '', 'width' : '', 'min-height' : '', 'min-width' : '', 'max-height' : '', 'max-width' : ''
        });
        /// Needed to refresh background if previous had background image added by DART ////////
        
        
        me.dartAds();
        ////// DART   
    }
    /**
     */
    me.updateAdInfo = function () 
    {
        billboard.info( "Ads.onPageLoaded()" );
        // update ad serving properties
        // locate the new values, from div, or script and 
        var prof = $("#cm8 .profile").text();
        var cat = $("#cm8 .category").text();
    }
    /* resize iframe */
    me.resizeFrame = function (h, w, id) 
    {
        if (id == "resizableIframeBBMAM2")
        {
            $("#resizableIframeBBMAM2").height(h + "px" ).attr("height", h + "px" );
            if(h != "250"){var h = "620";} else{var h = "270";}
            $("#bbmaAdMid2").parent().css("height", h + "px" );
        }
                 else if (id == "resizableIframeTOP" || id == "resizableIframeHPTOP")
        {
         $("#" + id).height(h + "px" );
        $("#" + id).width(w + "px" );
        $("#" + id).attr("height", h + "px" );
        $("#" + id).attr("width", w + "px" );
        $("#" + id).css("height", h + "px" );
        $("#" + id).css("width", w + "px" );
        $("#" + id).css("max-height", h + "px" );
        $("#" + id).css("max-width", w + "px" );
                 $(".ad-unit-top").css("height", h + "px" );
        $(".ad-unit-top").css("width", w + "px" );
        }
        else
        {
        $("#" + id).height(h + "px" );
        $("#" + id).width(w + "px" );
        $("#" + id).attr("height", h + "px" );
        $("#" + id).attr("width", w + "px" );
        $("#" + id).css("height", h + "px" );
        $("#" + id).css("width", w + "px" );
        $("#" + id).css("max-height", h + "px" );
        $("#" + id).css("max-width", w + "px" );
        }
    }
    /////////// DART    
    me.dartAds = function () 
    {
        ///Generates random number needed for DART "ORD" parameter      
        var axel = Math.random() + "";
        var num = axel * 9000000000000000000;
        // Gets the category/section/subsection/profile id of page currently on
        var cat = $("#cm8 .category").text();
        var sect = $("#section").html();
        var subSect = $("#subsection").html();
        var profile = $("#unique-id").html();
        // checks whether or not current page is an Article/Artist page/Album so Profile ID can be passed in paparmeters for DART
        if (sect == 'news' && profile != "unknown")
        {
            if (subSect != "column-article") {
                var profile_id = "ar=" + profile + ";";
                //// article
            }
            else 
            {
                var newProfile = profile.replace('/', '_');
                ///////////// NEEDED TO CHANGE HYPEN TO UNDERSCORE WITH CHART SECTION    
                var profile_id = "ar=" + newProfile + ";";
                //// article  
            }
        }
        else if (sect == 'artists' && profile != "unknown" && subSect == "album") {
            var profile_id = "album=" + profile + ";";
            //// album
        }
        else if (sect == 'slideshow' || sect == 'PHOTOS')
        {
            //// slideshow/gallery

                var slide = $("#cm8 .profile").html();
                var profile = slide.replace('content=', '');
                var profile_id = "ar=" + profile + ";";
                //// artist

        }
        else if (sect == 'artists' && profile != "unknown" && subSect != "album") {
            var profile_id = "artist=" + profile + ";";
            //// artist
        }
        else if (sect == 'video' && subSect == "video-play")
        {
            var video = $("#cm8 .profile").html();
            var profile = video.replace('content=', '');
            var profile_id = "vid=" + profile + ";";
            //// video id
        }
        else {
            var profile_id = "";
            //// other 
        }
        // if section is charts, the specifty chart is appended to the Category
        if (sect == "charts")
        {
            var chartSection = $("#chart-target").text();
            var newChartSection = chartSection.replace('-', '_');
            ///////////// NEEDED TO CHANGE HYPEN TO UNDERSCORE WITH CHART SECTION
            if (subSect == "year-dec-end") {
                var cat = "billboard.charts_year_end";
                var cat = cat + "/" + newChartSection;
            }
            else {
                var cat = cat + "/" + newChartSection;
                        
            }
                        
                        
        }
        if (sect == "charts-landing") 
        {
            if ( $('#chart-year-end-dart').length > 0) {
                var cat = splitCat[0] + "." + splitCat[1] + "_year_end";
                var cat = cat + "/index";
            }
            else {
                var cat = cat + "/index";
            }
        }
        ///////////CHECKS ENVIRONMENT AND APPENDS "_TEST" IF ON LOCAL OR STAGE/QA///////////////////////
        var environment = $("#environment").html();
        if (environment != "prod") {
    var splitCat = cat.split(".");
  var cat = splitCat[0] + "_test." + splitCat[1];
        }
        ///////////Needed because local directory different then other environments///////////////////////
        if (environment == "local") {
            var slash = "";
        }
        else {
            var slash = "/";
        }
        
    
/////////////Legolas///////

         var axel = Math.random() + "";
     var num = axel * 9000000000000000000;

        var tracking_tag = "http://ad.doubleclick.net/ad/N5664.1274.BILLBOARDONLINE/B4871376.6;sz=1x1;ord="+num+"?";
        var sect = $("#section").html();
        if (sect == "events" ) { $("#vegasAdTracker").attr("src",tracking_tag);}

////Legolas tracking to dart/////
var lsg_cookie = getCookie('lsg'); //getCookie('lsg');
var dart = '';

if (lsg_cookie) {
var cookie_tokens = lsg_cookie.split('s');
for(var i=0;i<cookie_tokens.length;i++) {  dart+= ('dartLegolas='+cookie_tokens[i]+';'); }
}
////Legolas tracking to dart/////
        

        //// checks if on the Home Page, If so the DIV with the class="ad-unit-top" is used 
        if (sect != 'home')  
        {

            if (sect == "charts-landing") {$(".ad-unit-top").css({'margin' : ' 15px auto 5px'});}
            else {$(".ad-unit-top").css({'margin' : ' 20px auto 8px'});}
            
                    var bbma_check = $("#unique-id").html();
                    var artist_check = $("#unique-id").html();
                    var split_bbma_check = bbma_check.split("/");
                    var bbma = split_bbma_check[0];
                    var bbma_section = split_bbma_check[1];
                    
             if (bbma == 'bbma' && bbma_check == "bbma/home")
                {
      							if(bbma_check == "bbma/photogalleries" ){var cat = 'billboard.news/bbma_photogalleries'; var position = "";}
                         else if(bbma_check == "bbma/photogalleries/gallery" ){{var cat = 'billboard.news/bbma_photogalleries_gallery'; var position = "";}}
             else if(bbma_check == "bbma/home"){var cat = 'billboard.news/bbma_landing';}
             else{var cat = 'billboard.news/bbma'; var position = ""; }
                        
                              if(cat != 'billboard.news/bbma_landing')
                                                          {
                        var dart_url = 'http://ad.doubleclick.net/adj/' + cat + ';pos=t;sz=728x90,962x250,961x30;tile=1;dcopt=ist;' + profile_id + '' + dart + 'ord=' + num + '?';
                        $("#bbma-ad-top").html('<center><iframe src="' + slash + 'html/adIframeTop.html?src=' + escape(dart_url) + '" id="resizableIframeTOP" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" WIDTH=728 HEIGHT=0 style="margin-top:6px;"></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript></center>');
                                                $(".ad-unit-top").css("height", "0px");
                                                          }
                                                          else
                                                          {
                                                         $("#bbma-ad-top").html('');  
                                                          }
                    }
                    else
                    {
                                                $(".ad-unit-top").css("min-height", "90px");
                                                
                        var dart_url = 'http://ad.doubleclick.net/adj/' + cat + ';pos=t;sz=728x90,962x250,961x30;dcopt=ist;tile=1;' + profile_id + '' + dart + 'ord=' + num + '?';
                        $(".ad-unit-top").html('<iframe src="' + slash + 'html/adIframeTop.html?src=' + escape(dart_url) + '" id="resizableIframeTOP" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" WIDTH=728 ></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript>');
                                                 if($.browser.msie && $.browser.version == '7.0'){$("#resizableIframeTOP").css("margin-top", "7px");}
                        
                    }
        }
        else if (sect == 'home') 
        {
                    //////Home Page TOP
                    $(".ad-unit-top").css({'margin' : '2px auto 0pt 0px'});
                    $(".ad-unit-top, #resizableIframeHPTOP, #HPTop_AD").css({'position' : 'relative'});
                    $("#resizableIframeHPTOP, #HPTop_AD").css({'height' : '0px'});
                    $("#resizableIframeHPTOP, #HPTop_AD").height("0");
                    $("#resizableIframeHPTOP, #HPTop_AD").attr("height", "0px" );
                    
                    var dart_url = 'http://ad.doubleclick.net/adj/'+ cat +';pos=t;sz=728x90,962x250,961x30;tile=1;' + profile_id + '' + dart + 'ord='+ num +'?';      
$(".ad-unit-top").html('<iframe src="'+ slash +'html/adIframeHPTop.html?src=' + escape(dart_url) + '" id="resizableIframeHPTOP" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" WIDTH=0 HEIGHT=0></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript>'); 

            
        }

        ////BBMA AD SECTION////
        var bbma_check = $("#unique-id").html();
        var split_bbma_check = bbma_check.split("/");
        var bbma = split_bbma_check[0];
        var bbma_section = split_bbma_check[1];
        if (bbma == 'bbma') 
        {
             if(bbma_check == "bbma/photogalleries" ){var cat = 'billboard.news/bbma_photogalleries'; var position = "";}
                         else if(bbma_check == "bbma/photogalleries/gallery" ){{var cat = 'billboard.news/bbma_photogalleries_gallery'; var position = "";}}
             else if(bbma_check == "bbma/home"){var cat = 'billboard.news/bbma_landing'; var position = "dcopt=ist;";}
             else{var cat = 'billboard.news/bbma'; var position = ""; }
                         
                         
             
          
     setTimeout(function (){
             var dart_url = 'http://ad.doubleclick.net/adj/' + cat + ';pos=m1;sz=300x250;' + position + 'tile=2;' + profile_id + '' + dart + 'ord=' + num + '?';
        $("#bbmaAdMid1").html('<iframe src="' + slash + 'html/adIframeM1.html?src=' + escape(dart_url) + '" id="resizableIframeM1" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" HEIGHT=250 ></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript>');}, 200);
     
     //middle2   
      setTimeout(function (){
        var dart_url = 'http://ad.doubleclick.net/adj/' + cat + ';pos=m2;sz=300x250,300x600;tile=3;' + profile_id + '' + dart + 'ord=' + num + '?';
        $("#bbmaAdMid2").html('<iframe src="' + slash + 'html/adIframeBBMAM2.html?src=' + escape(dart_url) + '" id="resizableIframeBBMAM2" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" HEIGHT=250></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript>');}, 200);
      
      
             setTimeout(function (){
        var dart_url = 'http://ad.doubleclick.net/adj/' + cat + ';pos=a;sz=728x90,962x250;tile=4;' + profile_id + '' + dart + 'ord=' + num + '?';
        $(".ad-unit-anchor").html('<iframe src="' + slash + 'html/adIframeAnchor.html?src=' + escape(dart_url) + '" id="resizableIframeAnchor" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" style="min-width:728px; max-width:962px; min-height:90px; max-height:90px;"></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript>');}, 200);
       $(".ad-unit-anchor").css({"max-height" : "90px"});
       
        ////// needed so anchor div doesnt have extra white space
        /// Here the DIVS are populated with the javascript code needed for DART ////
        
         setTimeout(function (){
        //WALLPAPER
        $(".wallpaper-ad").html('<script type="text/javascript" SRC="http://ad.doubleclick.net/jump/' + cat + ';pos=wallpaper;sz=2000x2000;tile=5;' + profile_id + '' + dart + 'ord=' + num + '?"></script><noscript><A HREF="http://ad.doubleclick.net/jump/' + cat + ';pos=wallpaper;sz=2000x2000;tile=5;' + profile_id + '' + dart + 'ord=' + num + '?"><IMG SRC="http://ad.doubleclick.net/ad/' + cat + ';pos=wallpaper;sz=2000x2000;tile=5;' + profile_id + '' + dart + 'ord=' + num + '?" BORDER=0  ALT="Click Here!"></A></noscript>');
        }, 200);
      
      
        
        }
        else
        {            
                ///HOME PAGE MIDDLE ONE NEEDS SPECIAL POSITION////
        if (sect == "home") {var position = "dcopt=ist;";}
        else { var position = "";}
        
        setTimeout(function (){
           var dart_url = 'http://ad.doubleclick.net/adj/' + cat + ';pos=m1;'+ position +'sz=300x250,300x600;' + profile_id + '' + dart + 'tile=2;' + profile_id + 'ord=' + num + '?';
        $("#adMid1").html('<iframe src="' + slash + 'html/adIframeM1.html?src=' + escape(dart_url) + '" id="resizableIframeM1" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" HEIGHT=250 ></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript>');}, 200);
        
        //middle2   
         setTimeout(function (){
        var dart_url = 'http://ad.doubleclick.net/adj/' + cat + ';pos=m2;sz=300x250,300x600;tile=3;' + profile_id + '' + dart + 'ord=' + num + '?';
        $("#adMid2").html('<iframe src="' + slash + 'html/adIframeM2.html?src=' + escape(dart_url) + '" id="resizableIframeM2" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" HEIGHT=250></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript>');}, 200);
        
        
             setTimeout(function (){
        var dart_url = 'http://ad.doubleclick.net/adj/' + cat + ';pos=a;sz=728x90,962x250;tile=4;' + profile_id + '' + dart + 'ord=' + num + '?';
        $(".ad-unit-anchor").html('<iframe src="' + slash + 'html/adIframeAnchor.html?src=' + escape(dart_url) + '" id="resizableIframeAnchor" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" style="min-width:728px; max-width:962px; min-height:90px; max-height:90px;"></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript>');}, 200);
       $(".ad-unit-anchor").css({"max-height" : "90px"});
       
        ////// needed so anchor div doesnt have extra white space
        /// Here the DIVS are populated with the javascript code needed for DART ////
        
         setTimeout(function (){
        //WALLPAPER
        $(".wallpaper-ad").html('<script type="text/javascript" SRC="http://ad.doubleclick.net/jump/' + cat + ';pos=wallpaper;sz=2000x2000;tile=5;' + profile_id + '' + dart + 'ord=' + num + '?"></script><noscript><A HREF="http://ad.doubleclick.net/jump/' + cat + ';pos=wallpaper;sz=2000x2000;tile=5;' + profile_id + '' + dart + 'ord=' + num + '?"><IMG SRC="http://ad.doubleclick.net/ad/' + cat + ';pos=wallpaper;sz=2000x2000;tile=5;' + profile_id + '' + dart + 'ord=' + num + '?" BORDER=0  ALT="Click Here!"></A></noscript>');
        }, 200);
        
        
        }
  
        
        if (cat == 'billboard/homepage' || cat == 'billboard.gallery')
        {
            $("#noise-maker-module").css({
                "paddingTop" : "-6px"
            });
            $("#adMid1,#middle1,#resizableIframeM1").css(
            {
                'height' : '250px', 'width' : '300px', 'min-height' : '250px', 'min-width' : '300px', 
                'max-height' : '250px', 'max-width' : '300px'
            });
        }
    }
        
        



///// Legolas string for DART tag ///
function getCookie(name)

{
              var cookies = document.cookie;

                if (cookies.indexOf(name) != -1)

                {

                                var startpos = cookies.indexOf(name)+name.length+1;

                                var endpos = cookies.indexOf(";",startpos)-1;

                                if (endpos == -2) endpos = cookies.length;

                                return unescape(cookies.substring(startpos,endpos));

                }

                else

                {

                                return false; // the cookie couldn't be found! it was never set before, or it expired.

                }

}



      
 /// NEEDED TO REFRESH ADS ON CLICK IN THE BBMA PHOTO GALLERIES///         
                function refreshBBMA()
{
        
        
        
  $("#bbma-ad-top").html('');
                 $("#bbmaAdMid1").html('');
                 $("#bbmaAdMid2").html('');
             $(".ad-unit-anchor").html('');
             $(".wallpaper-ad").html('');
                                                          
                 ////BBMA AD SECTION////
        var bbma_check = $("#unique-id").html();
        var split_bbma_check = bbma_check.split("/");
        var bbma = split_bbma_check[0];
        var bbma_section = split_bbma_check[1]; 
                
                var axel = Math.random() + "";
        var num = axel * 9000000000000000000;
                
if(bbma_check = 'bbma/photogalleries/gallery'){         
                 
                 var cat = 'billboard.news/bbma_photogalleries_gallery';
                 var position = "";
         var profile_id = "";  
                 
                 ///////////CHECKS ENVIRONMENT AND APPENDS "_TEST" IF ON LOCAL OR STAGE/QA///////////////////////
        var environment = $("#environment").html();
        if (environment != "prod") {
                var splitCat = cat.split(".");
                var cat = splitCat[0] + "_test." + splitCat[1];
        }
        ///////////Needed because local directory different then other environments///////////////////////
        if (environment == "local") {
            var slash = "";
        }
        else {
            var slash = "/";
        }
                
        ////Legolas tracking to dart/////       
var lsg_cookie = getCookie('lsg');
var dart = '';

if (lsg_cookie) {
var cookie_tokens = lsg_cookie.split('s');
for(var i=0;i<cookie_tokens.length;i++) {  dart+= ('dartLegolas='+cookie_tokens[i]+';'); }
}

////Legolas tracking to dart/////               
        

   var dart_url = 'http://ad.doubleclick.net/adj/' + cat + ';pos=t;sz=728x90,962x250,961x30;tile=1;dcopt=ist;' + profile_id + '' + dart + 'ord=' + num + '?';
                        $("#bbma-ad-top").html('<center><iframe src="' + slash + 'html/adIframeTop.html?src=' + escape(dart_url) + '" id="resizableIframeTOP" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" WIDTH=728 HEIGHT=0 style="margin-top:6px;"></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript></center>');

         //middle1  
     setTimeout(function (){
             var dart_url = 'http://ad.doubleclick.net/adj/' + cat + ';pos=m1;sz=300x250;' + position + 'tile=2;' + profile_id + '' + dart + 'ord=' + num + '?';
        $("#bbmaAdMid1").html('<iframe src="' + slash + 'html/adIframeM1.html?src=' + escape(dart_url) + '" id="resizableIframeM1" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" HEIGHT=250 ></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript>');}, 300);
     
     //middle2   
      setTimeout(function (){
        var dart_url = 'http://ad.doubleclick.net/adj/' + cat + ';pos=m2;sz=300x250,300x600;tile=3;' + profile_id + '' + dart + 'ord=' + num + '?';
        $("#bbmaAdMid2").html('<iframe src="' + slash + 'html/adIframeBBMAM2.html?src=' + escape(dart_url) + '" id="resizableIframeM2" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" HEIGHT=250></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript>');}, 300);
      
      //anchor
             setTimeout(function (){
        var dart_url = 'http://ad.doubleclick.net/adj/' + cat + ';pos=a;sz=728x90,962x250;tile=4;' + profile_id + '' + dart + 'ord=' + num + '?';
        $(".ad-unit-anchor").html('<iframe src="' + slash + 'html/adIframeAnchor.html?src=' + escape(dart_url) + '" id="resizableIframeAnchor" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" style="min-width:728px; max-width:962px; min-height:90px; max-height:90px;"></iframe><noscript><A HREF="' + escape(dart_url) + '"><IMG SRC="' + escape(dart_url) + '" BORDER=0  ALT="Click Here!"></A></noscript>');}, 300);
       $(".ad-unit-anchor").css({"max-height" : "90px"});
       
        ////// needed so anchor div doesnt have extra white space
        /// Here the DIVS are populated with the javascript code needed for DART ////
        
         setTimeout(function (){
        //WALLPAPER
        $(".wallpaper-ad").html('<script type="text/javascript" SRC="http://ad.doubleclick.net/jump/' + cat + ';pos=wallpaper;sz=2000x2000;tile=5;' + profile_id + 'ord=' + num + '?"></script><noscript><A HREF="http://ad.doubleclick.net/jump/' + cat + ';pos=wallpaper;sz=2000x2000;tile=5;' + profile_id + '' + dart + 'ord=' + num + '?"><IMG SRC="http://ad.doubleclick.net/ad/' + cat + ';pos=wallpaper;sz=2000x2000;tile=5;' + profile_id + '' + dart + 'ord=' + num + '?" BORDER=0  ALT="Click Here!"></A></noscript>');
        }, 300);

}



}
        
        
    //// end of dartAds function
})(jQuery);
