/* 
 * Jquery browser detect plugin to identify browser/os detection.
 * jQuery Browser Plugin - http://jquery.thewikies.com/browser/
 */
(function($){
    $.browserTest = function(a, z){
        var u = 'unknown', x = 'X', m = function(r, h){
            for (var i = 0; i < h.length; i = i + 1) {
                r = r.replace(h[i][0], h[i][1]);
            }
            return r;
        }, c = function(i, a, b, c){
            var r = {
                name: m((a.exec(i) || [u, u])[1], b)
            };
            r[r.name] = true;
            r.version = (c.exec(i) || [x, x, x, x])[3];
            if (r.name.match(/safari/) && r.version > 400) {
                r.version = '2.0';
            }
            if (r.name === 'presto') {
                r.version = ($.browser.version > 9.27) ? 'futhark' : 'linear_b';
            }
            r.versionNumber = parseFloat(r.version, 10) || 0;
            r.versionX = (r.version !== x) ? (r.version + '').substr(0, 1) : x;
            r.className = r.name + r.versionX;
            return r;
        };
        a = (a.match(/Opera|Navigator|Minefield|KHTML|Chrome/) ? m(a, [[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/, ''], ['Chrome Safari', 'Chrome'], ['KHTML', 'Konqueror'], ['Minefield', 'Firefox'], ['Navigator', 'Netscape']]) : a).toLowerCase();
        $.browser = $.extend((!z) ? $.browser : {}, c(a, /(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/, [], /(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));
        $.layout = c(a, /(gecko|konqueror|msie|opera|webkit)/, [['konqueror', 'khtml'], ['msie', 'trident'], ['opera', 'presto']], /(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);
        $.os = {
            name: (/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase()) || [u])[0].replace('sunos', 'solaris')
        };
        if (!z) {
            $('html').addClass([$.os.name, $.browser.name, $.browser.className, $.layout.name, $.layout.className].join(' '));
        }
    };
    $.browserTest(navigator.userAgent, true);
})(jQuery);
var prvteCont = "<i class='prText'>&nbsp;&nbsp;</i>";

/*
 * Jquery Plugin - opens external links in a new window.
 * Checks if the links are relative, and are of the same domain.
 * Sampe Usage - $("#someDiv a").makeLinksExternal();
 */
jQuery.fn.makeLinksExternal = function(){
    return this.each(function(){
        var a = $(this).attr("href");
        if (a.indexOf(location.host) == -1 && a.indexOf("/") != 0) {
            $(this).attr("target", "_blank")
        }
    })
};

var mtDefaultOptOutText = "Don't show me this alert again";
var mtDefaultBuyButtonText = "Go to store";
var cafraGlbNav = {
    "Home": "Accueil",
    "News": "Nouvelles",
    "Music": "Musique",
    "Videos": "Vidéos",
    "Photos": "Photos",
    "Bio": "Bio",
    "Tour_Dates": "Spectacles",
    "Community": "Communauté",
    "Store": "Magasin",
    "Fanclub": "Fanclub",
    "Fans": "Fans",
    "cellstream": "Le Flux",
    "videoTitle": "Videos",
    "forumTitle": "Forum",
    "shows": "Spectacles",
    "upcomingShowsText": "Voir les prochains concerts",
    "discussions": "Forum",
    "upcoming": "à Venir",
    "past": "Passé",
    "viewMore": "Voir plus",
    "nowplaying": "EN LECTURE",
    "launchplayer": "Lancer le player",
    "moremusic": "plus de musique",
    "spmemories": "#spmemories"
};
var braGlbNav = {
    "Home": "Home",
    "News": "Notícias",
    "Music": "Música",
    "Videos": "Vídeos",
    "Photos": "Fotos",
    "Bio": "Biografia",
    "Tour_Dates": "Shows",
    "Community": "Comunidade",
    "Store": "Loja",
    "Fanclub": "Fã-clube",
    "Fans": "Fãs",
    "cellstream": "Streaming por celular",
    "videoTitle": "Videos",
    "forumTitle": "Forum",
    "shows": "Shows",
    "upcomingShowsText": "Voir les prochains concerts",
    "discussions": "Forum",
    "upcoming": "à Venir",
    "past": "Passé",
    "viewMore": "Veja mais",
    "nowplaying": "EN LECTURE",
    "launchplayer": "Lancer le player",
    "moremusic": "plus de musique",
    "spmemories": "#SPmemórias"
};
var gerGlbNav = {
    "Home": "Home",
    "News": "News",
    "Music": "Musik",
    "Videos": "Videos",
    "Photos": "Fotos",
    "Bio": "Biografie",
    "Tour_Dates": "Termine",
    "Community": "Community",
    "Store": "Shop",
    "Fanclub": "Fanclub",
    "Fans": "Fans",
    "cellstream": "Cell Stream",
    "videoTitle": "Videos",
    "forumTitle": "Forum",
    "shows": "Konzerte",
    "upcomingShowsText": "Nächste Shows anzeigen",
    "discussions": "Diskussionen",
    "upcoming": "Anstehende Konzerte",
    "past": "Vergangene Konzerte",
    "viewMore": "Mehr",
    "nowplaying": "Aktuelle Wiedergabe",
    "launchplayer": "Player starten",
    "moremusic": "mehr musik",
    "spmemories": "#spmemories"
};
var fraGlbNav = {
    "Home": "Accueil",
    "News": "News",
    "Music": "Musique",
    "Videos": "Videos",
    "Photos": "Photos",
    "Bio": "Biographie",
    "Tour_Dates": "Concerts",
    "Community": "Communauté",
    "Store": "Boutique",
    "Fanclub": "Fanclub",
    "Fans": "Fans",
    "cellstream": "Mobile",
    "videoTitle": "Videos",
    "forumTitle": "Forum",
    "shows": "Concerts",
    "upcomingShowsText": "Voir les prochains concerts",
    "discussions": "Forum",
    "upcoming": "Concerts � venir",
    "past": "Concerts pr�c�dents",
    "viewMore": "Voir plus",
    "nowplaying": "EN LECTURE",
    "launchplayer": "Lancer le player",
    "moremusic": "plus de musique",
    "spmemories": "#SouvenirsSP"
};



$(document).ready(function(){

    /* Official Twitter Button & fLike Button implementation */
    var listing = 'moduleListing';
    var detail = 'moduleDetail';
    var detailPageValue = window.location.href;
    if (detailPageValue.indexOf('.wmg') != -1) {
        var len = detailPageValue.length;
        var dot = detailPageValue.indexOf('.com/');
        var detailPageValue = detailPageValue.substring(dot + 5, len);
        detailPageValue = 'http://www.simpleplan.com/' + detailPageValue;
    }
    
    /* Implementation of the buttons in home */
    if ($('body').attr('id') == "home" || $('body').attr('id') == "blog" || $('body').attr('id') == "group_detail_7330" || $('body').hasClass('international')) {
        var twitterObj = {
            blockSelector: '.articles li.article',
            insertionSelector: '.activity a.comment',
            urlSelector: '.title h4 a',
            siteUrl: 'http://www.simpleplan.com',
            viaParam: '&amp;via=simpleplan',
            relatedParam: '&amp;related=simpleplan,simpleplan',
            fanclubviaParam: '&amp;via=simpleplan',
            fanclubrelatedParam: '&amp;related=simpleplan,simpleplan'
        }
        var fbLikeObj = {
            blockSelector: '.articles li.article',
            insertionSelector: '.activity a.comment',
            urlSelector: '.title h4 a',
            siteUrl: 'http://www.simpleplan.com'
        }
        $.wmgfeature.twttrButton(twitterObj, listing);
        $.wmgfeature.fbLike(fbLikeObj, listing);
    }/* Implementation of the buttons in blog page */
    /* Implementation of the buttons in blog detail */
    else 
        if (($('body').attr('id') == "blog_detail")) {
            var twitterObj = {
                blockSelector: '.blog_entry .body .article .meta',
                detailPageUrl: detailPageValue,
                insertionSelector: '.activity a.comment',
                siteUrl: 'http://www.simpleplan.com',
                viaParam: '&amp;via=simpleplan',
                relatedParam: '&amp;related=simpleplan,simpleplan',
                fanclubviaParam: '&amp;via=simpleplan',
                fanclubrelatedParam: '&amp;related=simpleplan,simpleplan',
                detailPageName: 'blogDetail'
            }
            var fbLikeObj = {
                blockSelector: '.blog_entry .body .article .meta',
                detailPageUrl: detailPageValue,
                insertionSelector: '.activity a.comment',
                siteUrl: 'http://www.simpleplan.com'
            }
            $.wmgfeature.twttrButton(twitterObj, detail);
            $.wmgfeature.fbLike(fbLikeObj, detail);
            /* Implementation of the vertical button in blog detail */
            var twitterObj = {
                blockSelector: '#html-699302 .content .body .description',
                insertionSelector: '.#blogTweetmeme',
                detailPageUrl: detailPageValue,
                buttonPosition: 'vertical',
                siteUrl: 'http://www.simpleplan.com',
                viaParam: '&amp;via=simpleplan',
                relatedParam: '&amp;related=simpleplan,simpleplan',
                fanclubviaParam: '&amp;via=simpleplan',
                fanclubrelatedParam: '&amp;related=simpleplan,simpleplan',
                detailPageName: 'blogDetail'
            }
            var fbLikeObj = {
                blockSelector: '#html-699302 .content .body .description',
                insertionSelector: '#blogTweetmeme',
                detailPageUrl: detailPageValue,
                fblikePosition: 'vertical',
                siteUrl: 'http://www.simpleplan.com'
            }
            $.wmgfeature.twttrButton(twitterObj, detail);
            $.wmgfeature.fbLike(fbLikeObj, detail);
        /* Implementation of the vertical button in blog detail */
        }/* Implementation of the buttons in Photo detail */
        else 
            if (($('body').attr('id') == "photo_detail")) {
                var twitterObj = {
                    blockSelector: '.photo_viewer .body .photo',
                    detailPageUrl: detailPageValue,
                    insertionSelector: '.rating',
                    siteUrl: 'http://www.simpleplan.com',
                    viaParam: '&amp;via=simpleplan',
                    relatedParam: '&amp;related=simpleplan,simpleplan',
                    detailPageName: 'photoDetail'
                }
                var fbLikeObj = {
                    blockSelector: '.photo_viewer .body .photo',
                    detailPageUrl: detailPageValue,
                    insertionSelector: '.rating',
                    siteUrl: 'http://www.simpleplan.com'
                }
                $.wmgfeature.twttrButton(twitterObj, detail);
                $.wmgfeature.fbLike(fbLikeObj, detail);
                
            }/* Implementation of the buttons in video detail */
            else 
                if (($('body').attr('id') == "video_detail")) {
                    var twitterObj = {
                        blockSelector: '.video_player .body .video',
                        detailPageUrl: detailPageValue,
                        insertionSelector: '.rating',
                        siteUrl: 'http://www.simpleplan.com',
                        viaParam: '&amp;via=simpleplan',
                        relatedParam: '&amp;related=simpleplan,simpleplan',
                        fanclubviaParam: '&amp;via=simpleplan',
                        fanclubrelatedParam: '&amp;related=simpleplan,simpleplan',
                        detailPageName: 'videoDetail'
                    }
                    var fbLikeObj = {
                        blockSelector: '.video_player .body .video',
                        detailPageUrl: detailPageValue,
                        insertionSelector: '.rating',
                        siteUrl: 'http://www.simpleplan.com'
                    }
                    $.wmgfeature.twttrButton(twitterObj, detail);
                    $.wmgfeature.fbLike(fbLikeObj, detail);
                    
                }
    
    
    if (($('body').attr('id') == "album_detail")) {
        var twitterObj = {
            blockSelector: '.album_info .body .album',
            detailPageUrl: detailPageValue,
            insertionSelector: '.txt',
            siteUrl: 'http://www.simpleplan.com',
            viaParam: '&amp;via=simpleplan',
            relatedParam: '&amp;related=simpleplan,simpleplan',
            detailPageName: 'albumDetail'
        }
        var fbLikeObj = {
            blockSelector: '.album_info .body .album',
            detailPageUrl: detailPageValue,
            insertionSelector: '.txt',
            siteUrl: 'http://www.simpleplan.com'
        }
        $.wmgfeature.twttrButton(twitterObj, detail);
        $.wmgfeature.fbLike(fbLikeObj, detail);
    }
    
    /*Twitter and Fblike button in Event detail */
    
    /* Merch container FLike */
    
    var fbLikeObj = {
        blockSelector: '#merchContainer li.merch',
        insertionSelector: '.merchDetail .merchBuy',
        urlSelector: '.merchName a',
        siteUrl: 'http://www.simpleplan.com'
    }
    $.wmgfeature.fbLike(fbLikeObj, listing);
    
    /*event coding*/
    var memberGoing = " Fans Going ";
    
    if (('#blog').length > 0) {
        var currenturllocation = location.href;
        if (currenturllocation.indexOf("/news/category/deutschland/") != -1) {
            $('#blog_listing-294510').css("display", "none");
            $('#blog #rss_in-5438802').css("display", "block");
            
        }
    }
    
    $('#event_listing-5216724.event_listing ul.cal_events li.cal_event').each(function(){
        var attendeeCount = $(this).find('.attendee_count').html();
        var eventPath = $(this).find('.txt .date h4 a').attr('href');
        
        $(this).find('.attendee_count').remove();
        if (attendeeCount != "") {
            if (attendeeCount == null) {
                attendeeCount = 0
            }
            else {
                attendeeCount = attendeeCount.substring((attendeeCount.lastIndexOf(":") + 1), attendeeCount.length).trim();
            }
            if (attendeeCount == 1) {
                memberGoing = " Fan Going";
            }
            else {
                memberGoing = " Fans Going";
            }
            var member_det = '<div class="member_details"><div class="membrGoing"><a href="' + eventPath + '" >' + attendeeCount + memberGoing + '</a></div></div><div class="moreinfo"><a class="viewmoreinfo" href="' + eventPath + '">More info</a></div>';
            $(this).find('.txt').append(member_det);
            
        }
        else {
            var member_det = '<div class="moreinfo" style="padding-left:0px;"><a class="viewmoreinfo"  href="' + eventPath + '">More info</a></div>';
            $(this).find('.txt').append(member_det);
        }
        
    });
    
    
    
    $('#event_listing-5206070.event_listing ul.cal_events li.cal_event').each(function(){
        var attendeeCount = $(this).find('.attendee_count').html();
        var eventPath = $(this).find('.txt .date h4 a').attr('href');
        
        $(this).find('.attendee_count').remove()
        if (attendeeCount != "") {
            if (attendeeCount == null) {
                attendeeCount = 0
            }
            else {
                attendeeCount = attendeeCount.substring((attendeeCount.lastIndexOf(":") + 1), attendeeCount.length).trim();
            }
            if (attendeeCount == 1) {
                memberGoing = " Fan Going";
            }
            else {
                memberGoing = " Fans Going";
            }
            var member_det = '<div class="member_details"><div class="membrGoing"><a href="' + eventPath + '" >' + attendeeCount + memberGoing + '</a></div></div><div class="moreinfo"><a class="viewmoreinfo" href="' + eventPath + '">More info</a></div>';
            $(this).find('.txt').append(member_det);
            
        }
        else {
            var member_det = '<div class="moreinfo" style="padding-left:0px;"><a class="viewmoreinfo"  href="' + eventPath + '">More info</a></div>';
            $(this).find('.txt').append(member_det);
        }
        
    });
    
    
    $('#event_listing-5216726.event_listing ul.cal_events li.cal_event').each(function(){
        var attendeeCount = $(this).find('.attendee_count').html();
        var eventPath = $(this).find('.txt .date h4 a').attr('href');
        
        $(this).find('.attendee_count').remove()
        if (attendeeCount != "") {
            if (attendeeCount == null) {
                attendeeCount = 0
            }
            else {
                attendeeCount = attendeeCount.substring((attendeeCount.lastIndexOf(":") + 1), attendeeCount.length).trim();
            }
            if (attendeeCount == 1) {
                memberGoing = " Fan Going";
            }
            else {
                memberGoing = " Fans Going";
            }
            var member_det = '<div class="member_details"><div class="membrGoing"><a href="' + eventPath + '" >' + attendeeCount + memberGoing + '</a></div></div><div class="moreinfo"><a class="viewmoreinfo" href="' + eventPath + '">More info</a></div>';
            $(this).find('.txt').append(member_det);
            
        }
        else {
            var member_det = '<div class="moreinfo" style="padding-left:0px;"><a class="viewmoreinfo"  href="' + eventPath + '">More info</a></div>';
            $(this).find('.txt').append(member_det);
        }
        
    });
    
    
    
    
    
    
    $('#event_listing-5216725.event_listing ul.cal_events li.cal_event').each(function(){
        var memberGoing = " Fans Went";
        var eventPath = $(this).find('.txt .date h4 a').attr('href');
        eventPath = eventPath + "?show=archive";
        $(this).find('.txt .date h4 a').attr('href', eventPath);
        var attendeeCount = $(this).find('.attendee_count').html();
        $(this).find('.attendee_count').remove();
        if (attendeeCount != "") {
            if (attendeeCount == null) {
                attendeeCount = 0
            }
            else {
                attendeeCount = attendeeCount.substring((attendeeCount.lastIndexOf(":") + 1), attendeeCount.length).trim();
            }
            if (attendeeCount == 1) {
                memberGoing = " Fan Went";
            }
            
            var member_det = '<div class="member_details"><div class="membrGoing"><a href="' + eventPath + '" >' + attendeeCount + memberGoing + '</a></div></div>';
            $(this).find('.txt').append(member_det);
        }
    });
    $('#event_listing-5216725.event_listing ul.cal_events li.cal_event').each(function(){
        var eventPath = $(this).find('.txt .date h4 a').attr('href');
        var member_det = '<div class="moreinfo" style="padding-left:0px;"><a class="viewmoreinfo"   href="' + eventPath + '">More Info</a></div>';
        $(this).find('.txt').append(member_det);
        
    });
    
    $('#event_listing-5216725.event_listing .module .content .body ul.cal_events li.cal_event').each(function(){
        var viewhref = $(this).find('.txt .date h4 a').attr("href");
        $(this).append('<div class="viewEvent"><a href="' + viewhref + '">View Photos & Videos</a></div>');
    });
    
    
    $('#event_listing-5216727.event_listing ul.cal_events li.cal_event').each(function(){
        var memberGoing = " Fans Went";
        var eventPath = $(this).find('.txt .date h4 a').attr('href');
        eventPath = eventPath + "?show=archive";
        $(this).find('.txt .date h4 a').attr('href', eventPath);
        var attendeeCount = $(this).find('.attendee_count').html();
        $(this).find('.attendee_count').remove();
        
        if (attendeeCount != "") {
            if (attendeeCount == null) {
                attendeeCount = 0
            }
            else {
                attendeeCount = attendeeCount.substring((attendeeCount.lastIndexOf(":") + 1), attendeeCount.length).trim();
            }
            if (attendeeCount == 1) {
                memberGoing = " Fan Went";
            }
            
            var member_det = '<div class="member_details"><div class="membrGoing"><a href="' + eventPath + '" >' + attendeeCount + memberGoing + '</a></div></div>';
            $(this).find('.txt').append(member_det);
        }
    });
    $('#event_listing-5216727.event_listing ul.cal_events li.cal_event').each(function(){
        var eventPath = $(this).find('.txt .date h4 a').attr('href');
        var member_det = '<div class="moreinfo" style="padding-left:0px;"><a class="viewmoreinfo"   href="' + eventPath + '">More Info</a></div>';
        $(this).find('.txt').append(member_det);
        
    });
    
    $('#event_listing-5216727.event_listing .module .content .body ul.cal_events li.cal_event').each(function(){
        var viewhref = $(this).find('.txt .date h4 a').attr("href");
        $(this).append('<div class="viewEvent"><a href="' + viewhref + '">View Photos & Videos</a></div>');
    });
    
    
    
    
    var eventdate = $('#event-707479.event .head h3 .date span').text();
    
    
    var eventdateobj = new Date(eventdate);
    currentDate = new Date();
    offset = eventdateobj.getTime() - currentDate.getTime();
    offsetdays = offset / 86400000;
    
    var clearDivEle = '<div class="clear"></div>';
    var horzDivdr = '<div class="hd"></div>';
    var currentPageShowUrl = $.urlParam("show");
    
    if ($('body#event').length > 0 || $('body#event_detail').length > 0) {
        var currentpageshow = $.urlParam("show");
        
        if ($('body').attr('id') == 'event') {
            if (currentpageshow == "archive") {
                $('#event_listing-707476').css("display", "none");
                $('#event_listing-5216723').css("display", "block");
                $('#event_listing-5216724').css("display", "block");
                $('#event_listing-5216725').css("display", "none");
            }
            else {
                $('#event_listing-707476').css("display", "block");
                $('#event_listing-5216723').css("display", "none");
                $('#event_listing-5216724').css("display", "none");
                $('#event_listing-5216725').css("display", "block");
                $('#event_listing-707476 .nav_meta ul li.more a').attr('href', '/past-shows/');
                $('#event_listing-5216725 .nav_meta ul li.more a').attr('href', '/past-shows/');
                
            }
        }
        
        if ($('body').attr('id') == 'event_detail') {
        
            if (currentpageshow == "archive" || offsetdays < -1) {
            
                if ($('#event-707479 .tools .input.going a').length > 0) {
                    $('#event-707479 .tools .input.going a').text("I Went");
                }
                
                $('#photo_thumbnail-5216730').css("display", "block");
                $('#video_thumbnail-5216731').css("display", "block");
                $('#event_listing-5216727').css("display", "block");
                $('#event_listing-5216727 .nav_meta ul li.more a').attr('href', '/past-shows/');
                $('#event_listing-5216726').css("display", "none");
            }
            else {
                if ($('#event-707479 .tools .input.going a').length > 0) {
                    $('#event-707479 .tools .input.going a').text("I am Going");
                }
                $('#photo_thumbnail-5216730').css("display", "none");
                $('#video_thumbnail-5216731').css("display", "none");
                $('#event_listing-5216726').css("display", "block");
                $('#event_listing-5216727').css("display", "none");
                
            }
        }
    }
    
    
    
    if ($('body').attr('id') == 'event_detail') {
        var eventdate = $(this).find('.head h3 .date').text();
        eventdateobj = new Date(eventdate);
        currentDate = new Date();
        offset = eventdateobj.getTime() - currentDate.getTime();
        offsetdays = offset / 86400000
        var maprequesthref = $('.cal_event div.txt .location .maplink a').attr("href");
        
        if (currentPageShowUrl == "archive" || offsetdays < -1) {
            var archiveTitle = "Past shows";
            
            $('#event-707479.event').each(function(){
            
                $(this).find('.content').addClass('archive');
                $(this).find('.head h3').append(archiveTitle);
                var eventDate = $(this).find('.head h3 .date');
                var goingRnot = $(this).find('.cal_event .input.going');
                var txtDiv = $(this).find('.cal_event div.txt');
                var mapEle = $(this).find('.cal_event div.txt .location .maplink');
                var descEle = $(this).find('.cal_event div.txt .description');
                var stateVal = $(this).find('.cal_event div.txt .location .region').html();
                var buyLnk = "<div class='buyLink'>" + $(this).find('.foot .nav_meta ul li.buy').html() + "</div>";
                var toolsData = "<div class='tools'></div>";
                var backtoupcoming = "<div class='nav_meta'><ul><li class='more'><a></a></li></ul></div>";
                var viewarchive = "<div class='viewevents'><a class='viewpix' href='/past-shows/'>View past shows</a></div>";
                $('#event_listing-4109154 .foot').append(viewarchive);
                
                
                $(this).find('.head .title').append(backtoupcoming);
                $(this).find('.nav_meta ul li.more a').html('All past shows');
                $(this).find('.nav_meta ul li.more a').attr("href", "/past-shows/");
                $(eventDate).insertBefore('#event-707479.event .cal_event div.txt .location .city');
                
                $(this).find('.cal_event').append(descEle);
                $(this).find('.cal_event').append(clearDivEle);
                $(clearDivEle).insertAfter('#event-707479.event .cal_event div.txt');
                if (maprequesthref != null) {
                
                    maprequesthrefarry = maprequesthref.split("?q=");
                    var maprequest = "<a href='" + maprequesthref + "' target='_blank'><img src='http://maps.google.com/maps/api/staticmap?center=" + maprequesthrefarry[1] + "&zoom=15&size=300x250&maptype=roadmap&markers=color:red|size:small|" + maprequesthrefarry[1] + "&sensor=false'/></a>";
                    $(this).find('.cal_event').append(maprequest);
                }
                
                $(this).find('.cal_event div.txt .location .city').append(stateVal);
                $(this).find('.cal_event').append(clearDivEle);
                $(this).find('.cal_event').append(horzDivdr);
                $(this).find('.cal_event').append(toolsData);
                $(this).find('.cal_event .tools').append(goingRnot);
                $(this).find('.cal_event').append(clearDivEle);
                
                if ($(this).find('.cal_event .tools .input.going a').attr('onclick') != null) {
                    $(this).find('.cal_event .tools .input.going .button.submit input').hide();
                }
                var eventsuccessmsg = $("#successMsg").text().trim();
                if (($(this).find('.cal_event .tools .input.going a').attr('onclick') != null && eventsuccessmsg.toUpperCase() == "I DIDN'T GO") || ($(this).find('.cal_event .tools .input.going a').attr('onclick') != null && eventsuccessmsg.toUpperCase() == "I'M NOT GOING")) {
                    $(this).find('.cal_event .tools .input.going a').hide();
                    $(this).find('.cal_event .tools .input.going .button.submit input').show();
                }
                
                $(this).find('.head h3 .date').remove();
                $(this).find('.head h3 .time').remove();
                $(this).find('.cal_event div.txt .location .maplink').remove();
                
                $(this).find('.cal_event div.txt .location .address').remove();
                //$(this).find('.cal_event div.txt .location .country').remove();
                $(this).find('.cal_event div.txt .location .region').remove();
                ;
                $(this).find('.cal_event div.txt .title').remove();
                $(this).find('.cal_event div.txt .availability').remove();
                $(this).find('.foot .nav_meta ul li.buy').remove();
                $(this).find('.cal_event div.txt .description').remove();
                
            });
            
            
            
        }
        else {
            var upcomingTitle = "Upcoming Shows";
            $('#event-707479.event').each(function(){
                $(this).find('.content').addClass('upcoming');
                
                $(this).find('.head h3').append(upcomingTitle);
                var eventDate = $(this).find('.head h3 .date');
                var goingRnot = $(this).find('.cal_event .input.going');
                var txtDiv = $(this).find('.cal_event div.txt');
                var mapEle = $(this).find('.cal_event div.txt .location .maplink');
                var stateVal = $(this).find('.cal_event div.txt .location .region').html();
                var buyLnk = "<div class='buyLink'>" + $(this).find('.foot .nav_meta ul li.buy').html() + "</div>";
                var toolsData = "<div class='tools'></div>";
                var backtoarchive = "<div class='nav_meta'><ul><li class='more'><a></a></li></ul></div>";
                var viewupcoming = "<div class='viewevents'><a class='viewpix' href='/event/'>View upcoming shows</a></div>";
                $('#event_listing-4109155 .foot').append(viewupcoming);
                $(this).find('.head .title').append(backtoarchive);
                $(this).find('.nav_meta ul li.more a').html('All upcoming shows');
                $(this).find('.nav_meta ul li.more a').attr("href", "/event/");
                $(eventDate).insertBefore('#event-707479.event .cal_event div.txt .location .city');
                
                $(this).find('.cal_event').append(mapEle);
                $(buyLnk).insertAfter('#event-707479.event .cal_event div.txt .location');
                
                $(this).find('.cal_event div.txt .location .city').append(stateVal);
                $(this).find('.cal_event div.maplink a').html('VIEW MAP');
                $(this).find('.cal_event').append(clearDivEle);
                
                $(this).find('.cal_event').append(horzDivdr);
                $(this).find('.cal_event').append(toolsData);
                $(this).find('.cal_event .tools').append(goingRnot);
                $(this).find('.cal_event').append(clearDivEle);
                
                if ($(this).find('.cal_event .tools .input.going a').attr('onclick') != null) {
                    $(this).find('.cal_event .tools .input.going .button.submit input').hide();
                }
                var eventsuccessmsg = $("#successMsg").text();
                if (($(this).find('.cal_event .tools .input.going a').attr('onclick') != null && eventsuccessmsg.toUpperCase() == "I DIDN'T GO") || ($(this).find('.cal_event .tools .input.going a').attr('onclick') != null && eventsuccessmsg.toUpperCase() == "I'M NOT GOING")) {
                    $(this).find('.cal_event .tools .input.going a').hide();
                    $(this).find('.cal_event .tools .input.going .button.submit input').show();
                }
                var buytckt = $(this).find('.cal_event .buyLink ul li a').html();
                
                if (buytckt == 'buy tickets') {
                    //$(this).find('.cal_event .txt .availability').remove();
                }
                $(this).find('.head h3 .date').remove();
                $(this).find('.head h3 .time').remove();
                $(this).find('.cal_event div.txt .location .maplink').remove();
                
                $(this).find('.cal_event div.txt .location .address').remove();
                $(this).find('.cal_event div.txt .rating').remove();
                //$(this).find('.cal_event div.txt .location .country').remove();
                $(this).find('.cal_event div.txt .location .region').remove();
                ;
                $(this).find('.cal_event div.txt .title').remove();
                $(this).find('.foot .nav_meta ul li.buy').remove();
                if (!($(this).find('.cal_event div.txt .availability').text().trim().length > 0)) {
                    $(this).find('.cal_event div.txt .availability').remove();
                }
                
                var availabilityText = $(this).find('.cal_event div.txt .availability').text().trim();
                if (availabilityText.toUpperCase() == "SOLD OUT") {
                    $(this).find(".cal_event .buyLink").remove();
                }
                
                $(this).find('.cal_event div.txt .availability').remove();
                //$(this).find('.foot .nav_meta ul li.buy').remove();
            });
        }
    }
    
    $('#event_listing-5206070.event_listing').each(function(){
        $(this).find('.cal_event div.txt .event_title .title').remove();
    });
    
    
    ///Fans going or fans went header in event detila page
    var eventdate = $('#event-707479.event .head h3 .date span').text();
    
    
    eventdate = $('#event-707479.event .module .cal_event div.txt div.date').text();
    var eventdateobj = new Date(eventdate);
    currentDate = new Date();
    offset = eventdateobj.getTime() - currentDate.getTime();
    
    offsetdays = offset / 86400000;
    
    var memberCount = $('#member_listing-5219272.member_listing .module .content .head h3 span').text();
    var openparanthesis = memberCount.indexOf("(");
    var closeparanthesis = memberCount.indexOf(")");
    memberCount = memberCount.substring(openparanthesis + 1, closeparanthesis);
    
    var currentpageshowtitle = $.urlParam("show");
    
    if (currentpageshowtitle == "archive" || offsetdays < -1) {
        memberGoing = "Fans Went";
        if (memberCount == '0' || memberCount == "1") {
            memberGoing = "Fan Went";
        }
        var memberClass = '<div class="membersGoing"><span class="membercount"></span>&nbsp;' + memberGoing + '</div>';
        $('#member_listing-5219272.member_listing .module .content .head h3').html(memberGoing + '<span class=\"total\">(' + memberCount + ")</span>");
    }
    else {
        var memberGoing = "Fans Going";
        
        if (memberCount == '0' || memberCount == "1") {
            memberGoing = "Fan Going";
        }
        var memberClass = '<div class="membersGoing"><span class="membercount"></span>&nbsp;' + memberGoing + '</div>';
        $('#member_listing-5219272.member_listing .module .content .head h3').html(memberGoing + '<span class=\"total\">(' + memberCount + ")</span>");
    }
    
    
    $('#member_listing-5219272.member_listing .module .content .head .title').css("display", "block");
    $(memberClass).insertAfter($('#event-707479.event .module .content .body .cal_event .tools .input.going'));
    if (memberCount != null && memberCount != " ") 
        ;
    {
    
        $("#event-707479.event .module .content .body .cal_event .tools .membersGoing span.membercount").text(memberCount);
    }
    var venuetxt = $('#event-707479.event .module .body .cal_event div.txt div.venue span').html();
    var datetxt = $('#event-707479.event .module .body .cal_event div.txt div.date span').html();
    var detailPageValue = window.location.href;
    var listing = 'moduleListing';
    var detail = 'moduleDetail';
    var titleTxt = venuetxt + '-' + datetxt;
    var fbLikeObj = {
        blockSelector: '#event-707479 .body .tools',
        detailPageUrl: detailPageValue,
        insertionSelector: '.membersGoing'
    }
    var detailarchive = detailPageValue.split("?");
    var detailPageValue = detailarchive[0];
    var twitterObj = {
        blockSelector: '#event_detail .event .article',
        detailPageUrl: detailPageValue,
        insertionSelector: '.membersGoing',
        viaParam: '&amp;via=simpleplan',
        detailPageName: 'customPage',
        relatedParam: '&amp;related=simpleplan',
        titletxt: titleTxt
    }
    $.wmgfeature.fbLike(fbLikeObj, detail);
    $.wmgfeature.twttrButton(twitterObj, detail);
    /*Twitter and Fblike button in Event detail */
    
    /*Event related code-end*/
    
    /*		var fbLikeAlbum = "<iframe src='http://www.facebook.com/plugins/like.php?app_id=228812260477731&amp;href=www.simpleplan.com&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=35' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:450px; height:35px;' allowTransparency='true'></iframe>";
     var fbAlbum = "<div class = 'fbAlbum'>" + fbLikeAlbum + "</div>";
     $.("#album_info-383751 .content .body").append(fbAlbum);		*/
    /* Official Twitter Button & fLike Button implementation */
    
    
    
    
    /* disabling the image link in audio player */
    $('.song_playlist .playlist .info li .img a').attr("href", "javascript:void(0);");
    
    
    /* Removing tumblr site's view all link - start */
    if ($('body#home_tumbler')) {
        $('.blog_listing .nav_meta ul li.more').each(function(){
            var linkVal = "";
            var linkVal = $(this).find('a').html();
            if (linkVal == "View All") {
                $(this).css('display', 'none');
            }
        });
    }
    /* Removing tumblr site's view all link ends */
    
    /* Music Player Buy Link - Start*/
    $.each($('.list ul li .buy'), function(index, value){
        var buytrack = $('.list ul li .buy').eq(index).html().replace("Buy", "");
        $('.list ul li .buy').eq(index).html(buytrack);
        $('.list ul li .buy a').eq(index).html("BUY");
    });
    /* Music Player Buy Link - End*/
    
    /* Blog Author Name - Start*/
    
    $.each($('.articles .article .author'), function(index, value){
        var authorName = $('.articles .article .author').eq(index).html().replace("Posted by", "");
        $('.articles .article .author').eq(index).html(authorName);
        
    });
    
    
    $.each($('div.article .author'), function(index, value){
        var authorName = $('div.article .author').eq(index).html().replace("Posted by", "");
        $('div.article .author').eq(index).html(authorName);
        
    });
    
    /* Blog Author Name - End*/
    
    /* Blog Detail Making File Under as span element - Start*/
    
    var fileUnder = $("div.article .category ul li a").text();
    $("div.article .category ul li a").replaceWith("<span>" + fileUnder + "</span>");
    
    /* Blog Detail Making File Under as span element - End*/
    
    /* Suppresses display of empty footers on IE */
    $('.module .foot:empty').addClass('empty');
    $('#join-294550.join .annotation span.private').each(function(){
        var cont = (this).innerHTML;
        (this).innerHTML = prvteCont + cont;
    });
    $('li.input.private').each(function(){
        var liCont = (this).innerHTML;
        (this).innerHTML = liCont + prvteCont;
    });
    $("#accountQuestoins.settings li.input.annotation").each(function(){
        if (($(this).find('span.private')).length == 0) {
            $(this).append('<span class="private">Visible only to site administrators</span>');
        }
    });
    
    $("html").addClass($.os.name);
    $("body").addClass($.browser.className);
    $("body").addClass($.browser.name);
    
    
    //The var "chatEnabled" is declared in navigational links html module
    //Initially this module is set to display:none using css.
    if (chatEnabled.toLowerCase() == "true") {
        $("#html-2052580.html").css("display", "block");
    }
    
    //this inserts the merch module into leftwrap	
    $('#html-2054007.html .module .content .body .description .chatContainer div#leftWrap').append($('#html-327531.html .module .content .body .description div#merchContainer'));
    
    /* START Add "Launch Player" links to footer nav of all audio playlist modules */
    var launchLink = $('<li class="launchPlayer"><a href="/music-player/" class="launchPlayerLink">Launch Player</a></li>');
    $(".song_playlist .module .content .nav_meta ul").prepend(launchLink);
    /* END Add "Launch Player" links to footer nav of all audio playlist modules */
    
    /* add popup onClick handler for audio player links */
    $("a.launchPlayerLink").click(function(){
        window.open("/music-player/", "Window2", "width=368,height=270,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no");
        return false;
    });
    
    /* Make store top nav link open in a new window */
    $('.nav_main ul li.custom a[href*=amazon.com]').attr("rel", "external");
    
    /*START - Fix for truncating author name in the discussions page #698 */
    $('.discussion_listing .topics li .author a').each(function(){
        var trunc = (this).innerHTML;
        if (trunc.length > discussionAuthorLen) {
            trunc = trunc.substring(0, discussionAuthorLen);
            trunc += '<span>' + '...</span>';
            (this).innerHTML = trunc;
        }
    });
    /*END - Fix for truncating author name in the discussions page #698 */
    
    
    $('.nav_main ul li.nav-custom a').each(function(){
        var fanclub = $(this).html().trim();
        if (fanclub == "FanClub") {
            $(this).parent().addClass("fanclub");
        }
    });
    
    /* START: Custom drop-downs for top nav */
    var $customNavs = $('.nav_main ul li.nav-custom a');
    
    $customNavs.filter(function(){
        return (/^Music/i).test($(this).text())
    }).parent().addClass('nav-custom').addClass('nav-music');
    
    $customNavs.filter(function(){
        return (/^Store$/i).test($(this).text())
    }).parent().addClass('nav-custom').addClass('dropdown').addClass('nav-store').append(storeSubNav);
    var communityNavCell = $(".nav_main ul li.nav-community_landing"); //change this selector to target a diffent cell in the top nav
    communityNavCell.addClass('dropdown');
    communityNavCell.append(communitySubNav);
    
    var musicNavCell = $(".nav_main ul li.nav-custom.nav-music");   //change this selector to target a diffent cell in the top nav
	musicNavCell.addClass('dropdown');
	musicNavCell.append(musicSubNav);

	var videoNavCell = $(".nav_main ul li.nav-video");   //change this selector to target a diffent cell in the top nav
	videoNavCell.addClass('dropdown');
	videoNavCell.append(videoSubNav);

	var photoNavCell = $(".nav_main ul li.nav-photo");   //change this selector to target a diffent cell in the top nav
	photoNavCell.addClass('dropdown');
	photoNavCell.append(photoSubNav);
    
    $(".dropdown").hover(function(){
        $(".flyoutMenu", this).show();
    }, function(){
        $(".flyoutMenu", this).hide();
    });
    
    var UKNavCell = $(".nav_main ul li#USNav");
    UKNavCell.addClass('dropdown');
    $("#USNav.dropdown").hover(function(){
        $(".UKCountry", this).show();
    }, function(){
        $(".UKCountry", this).hide();
    });
    
    
    var musicNavcell = $('.nav_main ul li.nav-custom.nav-music');
    var homeNavCell = $('.nav_main ul li.nav-home')
    if (location.href.indexOf("/music/") != -1) {
        musicNavcell.addClass("active");
        homeNavCell.removeClass("active");
    }
    if (location.href.indexOf("/album/") != -1) {
        musicNavcell.addClass("active");
        homeNavCell.removeClass("active");
    }
    
    
    /* END: Custom drop-downs for top nav */
    
    $("a[href^=http://starterfanclub1.wmg.ciscoeos.com]").parent(".custom").addClass("Fanclub");
    
    /* ********** Merch module code ********* */
    $('#merchContainer').parent(".description").parent(".body").siblings(".head").addClass("clearfix");
    $('#merchContainer').parent(".description").parent(".body").siblings(".head").children("h3").css('border', 'none');
    $('#merchContainer').parent(".description").parent(".body").siblings(".head").css({
        'position': 'relative',
        'z-index': '100'
    });
    $('#merchContainer').parent(".description").parent(".body").siblings(".foot").css({
        'z-index': '110',
        'overflow': 'visible'
    });
    $('#merchContainer').parent(".description").parent(".body").css({
        'position': 'relative',
        'clear': 'both'
    });
    
    var visitStorehead = $('#merchContainer').parent(".description").parent(".body").siblings(".head");
    $('#merchContainer .merchHead').appendTo(visitStorehead);
    
    var visitStoreFoot = $('#merchContainer').parent(".description").parent(".body").siblings(".foot");
    $('#merchContainer .merchFoot').appendTo(visitStoreFoot);
    
    $('#merchContainer').parent(".description").parent(".body").siblings(".foot.empty").addClass("emptyfix");
    
    /* START: Merch module drop-downs */
    $(".merchHead .visitStore").hover(function(){
        $(".visitStoreFlyout", this).show();
    }, function(){
        $(".visitStoreFlyout", this).hide();
    });
    $(".merchFoot .visitStore").hover(function(){
        $(".visitStoreFlyout", this).show();
    }, function(){
        $(".visitStoreFlyout", this).hide();
    });
    $(".firstitem .merchBuy").hover(function(){
        $(".merchBuyFlyout", this).show();
    }, function(){
        $(".merchBuyFlyout", this).hide();
    });
    $(".seconditem .merchBuy").hover(function(){
        $(".merchBuyFlyout", this).show();
    }, function(){
        $(".merchBuyFlyout", this).hide();
    });
    $(".thirditem .merchBuy").hover(function(){
        $(".merchBuyFlyout", this).show();
    }, function(){
        $(".merchBuyFlyout", this).hide();
    });
    /* END: Merch module drop-downs */
    
    
    if ($("#sign_up-294578 li.input input").attr('class') == "focused") {
        $descriptionDisplay = $("#sign_up-294578 li.input input.focused").parent().contents().filter(".message").children();
        if ($descriptionDisplay.css("display") == "inline" || $descriptionDisplay.css("display") == "none") {
            $descriptionDisplay.css("display", "block");
        }
    }
    $("#sign_up-294578 li.input input").click(function(){
        // In this check for the corresponding description div. 		
        $descriptionDisplay = $(this).next().filter(".message").children();
        if ($descriptionDisplay.css("display") == "inline") {
            $descriptionDisplay.css("display", "block");
        }
    });
    $("#sign_up-294578 li.select input").click(function(){
        // In this check for the corresponding description div. 
        $descriptionDisplay = $(this).parent().contents().filter(".message").children();
        if ($descriptionDisplay.css("display") == "inline") {
            $descriptionDisplay.css("display", "block");
        }
    });
    
    /* Fixing the target for the myspace link */
    $(".nav_main ul li a[href^=http://www.myspace.com/]").attr("target", "_new");
    
    /* Make rel="external" links open in a new window */
    $("a[rel=external]").attr("target", "_new");
    
    /* external links for fanclub and store - start*/
    /* top-nav */
    $(".nav_main li.nav-custom.fanclub a").attr("target", "_new");
    
    $(".nav_main li.nav-store a").attr("target", "_new");
    
    /* Footer */
    $("#FooterLinks2 .footerBlock3 h4 a").attr("target", "_new");
    $("#FooterLinks2 .footerBlock4 h4 a").attr("target", "_new");
    $("#FooterLinks2 .footerBlock4 ul li a").attr("target", "_new");
    $("#FooterLinks2 .footerBlock4 ul li ul li a").attr("target", "_new");
    
    /* external links for fanclub and store - end*/
    /* Fixing the target for the Street Team link */
    $("#FooterLinks1 ul li a.streetteam").attr("target", "_new");
    
    /* Fixing the target for the digg link */
    $(".shareweb .digg a").attr("target", "_new");
    
    /* Append labels to elements in discussion module */
    $(".topics li.list .category li:first-child").prepend("Category: ");
    $(".topics li.list .activity").prepend("Replies: ");
    $(".topics li.list .date").prepend("Last Reply: ");
    
    /* Add "Close" text to close link in social media sharebox on photo and video detail pages */
    $(".sharebox .sb_head .sb_title a.shareclose").prepend("Close");
    
    var noOfImageDscDtl = $("#discussion_entry-294529 .topic .description img").length;
    for (i = 0; i < noOfImageDscDtl; i++) {
        var discussionImageElement = $("#discussion_entry-294529 .topic .description img:eq(" + i + ")");
        var imgHeight = discussionImageElement.height();
        var imgWidth = discussionImageElement.width();
        if (imgHeight > 200 && imgWidth > 200) {
            var calcheight = (imgHeight / imgWidth) * 200;
            discussionImageElement.css("height", calcheight);
            discussionImageElement.css("width", 200);
        }
    }
    var noOfImageDscDtl = $("#discussion_listing-340654  .topic .description img").length;
    for (i = 0; i < noOfImageDscDtl; i++) {
        var discussionImageElement = $("#discussion_listing-340654 .topic .description img:eq(" + i + ")");
        var imgHeight = discussionImageElement.height();
        var imgWidth = discussionImageElement.width();
        if (imgHeight > 200 && imgWidth > 200) {
            var calcheight = (imgHeight / imgWidth) * 200;
            discussionImageElement.css("height", calcheight);
            discussionImageElement.css("width", 200);
        }
    }
    
    // Functionality for add new blogs.
    $(".blog_listing .nav_meta .more a").bind("click", function(e){
        $.cookie("blog_body", blogTwitterBlurbText, {
            path: "/"
        });
    });
    if ($("body").attr("id") == "add_new_blog") {
        $.cookie("blog_body", blogTwitterBlurbText, {
            path: "/"
        });
    }
    
    /*START- code which obfuscates email addresses #2420*/
    var m_ = "mailto:";
    var a_ = "@";
    var d_ = ".";
    var i = 0;
    var j = 0;
    var q_ = "?";
    var e_ = "=";
    
    $('span.ciReplace').each(function(){
        if (cId[i].format == "") {
            $(this).html('<a href="' + m_ + cId[i].name + a_ + cId[i].domain + d_ + cId[i].tld + '">' + cId[i].name + a_ + cId[i].domain + d_ + cId[i].tld + '</a>');
        }
        else {
            if (cId[i].param == "") {
                $(this).html('<a href="' + m_ + cId[i].name + a_ + cId[i].domain + d_ + cId[i].tld + '">' + cId[i].format + '</a>');
            }
            else {
                $(this).html('<a href="' + m_ + cId[i].name + a_ + cId[i].domain + d_ + cId[i].tld + q_ + 'subject' + e_ + cId[i].param + '">' + cId[i].format + '</a>');
            }
        }
        i++;
    });
    $('span.footReplace').each(function(){
        if (fId[j].format == "") {
            $(this).html('<a href="' + m_ + fId[j].name + a_ + fId[j].domain + d_ + fId[j].tld + '">' + fId[j].name + a_ + fId[j].domain + d_ + fId[j].tld + '</a>');
        }
        else {
            if (fId[j].param == "") {
                $(this).html('<a href="' + m_ + fId[j].name + a_ + fId[j].domain + d_ + fId[j].tld + '">' + fId[j].format + '</a>');
            }
            else {
                $(this).html('<a href="' + m_ + fId[j].name + a_ + fId[j].domain + d_ + fId[j].tld + q_ + 'subject' + e_ + fId[j].param + '">' + fId[j].format + '</a>');
            }
        }
    });
    /*End - code which obfuscates email addresses #2420*/
    
    //Album detail stuff 
    $buylinks = $('#album_info-383751 .foot .nav_meta ul');
    $buylinks.insertBefore('#album_info-383751 .album .txt div.description');
    $('#album_info-383751.album_info .module .content .foot .nav_meta ul').css("display", "block");
    
    //Modifying the legal text in the log in and sign up pages.
    $("body#sign_up #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show();
    $("body#join #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show();
    
    /* drop down functionality - start */
    var photoDropDown = '<div class="photoDropDown"><select id="photoCategory"><option class="recentAdded" value="recentAdded">Recently Added</option><option class="mostViewed" value="mostViewed">Most Viewed</option><option class="highestRated" value="highestRated">Highest Rated</option></select></div>';
    var videoDropDown = '<div class="videoDropDown"><select id="videoCategory"><option class="recentAdded" value="recentAdded">Recently Added</option><option class="mostViewed" value="mostViewed">Most Viewed</option><option class="highestRated" value="highestRated">Highest Rated</option></select></div>';
    $('#photo #rightWrapper .moduleContainer3').append(photoDropDown);
    $('#video #rightWrapper .moduleContainer3').append(videoDropDown);
    
    $('#photoCategory').change(function(){
        var optionSelectedValue = $('#photoCategory option:selected').val();
        switch (optionSelectedValue) {
            case 'recentAdded':
                $("#photoCategory option[value='recentAdded']").attr('selected', 'selected');
                
                $("#photo_thumbnail-294569.photo_thumbnail").css("display", "block");
                $("#photo_thumbnail-3332708.photo_thumbnail").css("display", "none");
                $("#photo_thumbnail-3332709.photo_thumbnail").css("display", "none");
                break;
            case 'mostViewed':
                $("#photoCategory option[value='mostViewed']").attr('selected', 'selected');
                
                $("#photo_thumbnail-3332708.photo_thumbnail").css("display", "block");
                $("#photo_thumbnail-294569.photo_thumbnail").css("display", "none");
                $("#photo_thumbnail-3332709.photo_thumbnail").css("display", "none");
                break;
            case 'highestRated':
                $("#photoCategory option[value='highestRated']").attr('selected', 'selected');
                
                $("#photo_thumbnail-3332709.photo_thumbnail").css("display", "block");
                $("#photo_thumbnail-294569.photo_thumbnail").css("display", "none");
                $("#photo_thumbnail-3332708.photo_thumbnail").css("display", "none");
                break;
        }
    });
    
    $('#videoCategory').change(function(){
        var optionSelectedValue = $('#videoCategory option:selected').val();
        switch (optionSelectedValue) {
            case 'recentAdded':
                $("#videoCategory option[value='recentAdded']").attr('selected', 'selected');
                
                $("#video_thumbnail-890493.video_thumbnail").css("display", "block");
                $("#video_thumbnail-3333688.video_thumbnail").css("display", "none");
                $("#video_thumbnail-3333689.video_thumbnail").css("display", "none");
                break;
            case 'mostViewed':
                $("#videoCategory option[value='mostViewed']").attr('selected', 'selected');
                
                $("#video_thumbnail-3333688.video_thumbnail").css("display", "block");
                $("#video_thumbnail-890493.video_thumbnail").css("display", "none");
                $("#video_thumbnail-3333689.video_thumbnail").css("display", "none");
                break;
            case 'highestRated':
                $("#videoCategory option[value='highestRated']").attr('selected', 'selected');
                
                $("#video_thumbnail-3333689.video_thumbnail").css("display", "block");
                $("#video_thumbnail-890493.video_thumbnail").css("display", "none");
                $("#video_thumbnail-3333688.video_thumbnail").css("display", "none");
                break;
        }
    });
    /* drop down functionality - end */
});


$.urlParam = function(name){
    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
    if (results == null) {
        return 0;
    }
    else {
        return results[1];
    }
}

/* Functions for New Merch.*/

/* Functions for Merch Hover Card */
function bringMerchHCOn(merchImg){
    merchImg.showTimer = window.setTimeout(function(){
        $(merchImg).siblings(".merchHC").fadeIn(350);
        
    }, 300);
}

function killMerchHC(merchImg){
    if (merchImg.showTimer) {
        window.clearTimeout(merchImg.showTimer);
    }
}

function testOmnitureStringPresence(omnitureString){
    var omnitureStrRegex = /intcmp=(.*)(&.*|\/)$/;
    var regExCapture = omnitureString.match(omnitureStrRegex);
    return regExCapture;
}

function getMerchToasterOmnitureArray(omnitureString){
    var omnitureArrayLinks = new Array();
    omnitureString = $.trim(omnitureString);
    if (omnitureString.charAt(omnitureString.length - 1) != "/") {
        omnitureString += "/";
    }
    var regExCapture = testOmnitureStringPresence(omnitureString);
    if (regExCapture != null && regExCapture != "") {
        var regularExpCapture = regExCapture[1];
        omnitureString = omnitureString.replace(/\/$/, '');
        omnitureArrayLinks["alert-title"] = omnitureString.replace(regularExpCapture, regularExpCapture + '');
        omnitureArrayLinks["alert-thumb"] = omnitureString.replace(regularExpCapture, regularExpCapture + '');
        omnitureArrayLinks["alert-button"] = omnitureString.replace(regularExpCapture, regularExpCapture + '');
    }
    else {
        omnitureArrayLinks["alert-title"] = omnitureString.replace(/\/$/, '');
        omnitureArrayLinks["alert-thumb"] = omnitureString.replace(/\/$/, '');
        omnitureArrayLinks["alert-button"] = omnitureString.replace(/\/$/, '');
    }
    return omnitureArrayLinks;
}

/*
 * This function is used to tag store links with different omniture tags,
 * to track them. This will enable us to track which links the user clicked.
 * */
function getMerchOmnitureArray(omnitureString){
    var omnitureArrayLinks = new Array();
    omnitureString = $.trim(omnitureString);
    if (omnitureString.charAt(omnitureString.length - 1) != "/") {
        omnitureString += "/";
    }
    regExCapture = testOmnitureStringPresence(omnitureString);
    if (regExCapture != null && regExCapture != "") {
        var regularExpCapture = regExCapture[1];
        omnitureString = omnitureString.replace(/\/$/, '');
        omnitureArrayLinks["page-title"] = omnitureString.replace(regularExpCapture, regularExpCapture + '');
        omnitureArrayLinks["page-button"] = omnitureString.replace(regularExpCapture, regularExpCapture + '');
        omnitureArrayLinks["page-thumb"] = omnitureString.replace(regularExpCapture, regularExpCapture + '');
        omnitureArrayLinks["hovercard-title"] = omnitureString.replace(regularExpCapture, regularExpCapture + '');
        omnitureArrayLinks["hovercard-thumb"] = omnitureString.replace(regularExpCapture, regularExpCapture + '');
        omnitureArrayLinks["hovercard-button"] = omnitureString.replace(regularExpCapture, regularExpCapture + '');
    }
    else {
        omnitureArrayLinks["page-title"] = omnitureString.replace(/\/$/, '');
        omnitureArrayLinks["page-button"] = omnitureString.replace(/\/$/, '');
        omnitureArrayLinks["page-thumb"] = omnitureString.replace(/\/$/, '');
        omnitureArrayLinks["hovercard-title"] = omnitureString.replace(/\/$/, '');
        omnitureArrayLinks["hovercard-thumb"] = omnitureString.replace(/\/$/, '');
        omnitureArrayLinks["hovercard-button"] = omnitureString.replace(/\/$/, '');
        
    }
    return omnitureArrayLinks;
}

/*
 *
 * This function generates the structure of the merch module.
 * The structure is just a javascript variables interspersed with html.
 */
function generateMerchStructure(){
    var $merchData = $("#merchData");
    var $merchItem = $merchData.children(".merchItems")
    var merchViewAllLink = $merchData.children(".merchViewAll").html();
    var merchHoverCardPresent = $merchData.children(".merchHoverCardPresent").html().trim();
    merchHoverCardPresent = !!merchHoverCardPresent;
    
    /* Code for the Merch Head */
    var merchHead = '<div class="merchHead"><div class="visitStore"><a href="' + merchViewAllLink + '" class="visitStoreLink"  >ALL</a></div></div>'
    var visitStorehead = $('#merchContainer').parent(".description").parent(".body").siblings(".head");
    $(merchHead).appendTo(visitStorehead);
    $(visitStorehead).find("a").makeLinksExternal();
    /* End of Code for Merch Module */
    
    var merchBody = '<ul class="merchItems">';
    $.each($merchItem.children(".merchItem"), function(i){
        var merchImage = $(this).children(".merchImage").html();
        var merchTitle = $(this).children(".merchTitle").html();
        var merchBuyNow = $(this).children(".merchBuyNow").html();
        var merchDesc = $(this).children(".merchDesc").html();
        var merchSizes = $(this).children(".merchSizes").html();
        var merchPrice = $(this).children(".merchPrice").html();
        var omnitureArrayLinks = getMerchOmnitureArray(merchBuyNow);
        merchBody += '<li class="merch small item' + (i + 1) + '">\
			<div class="merchImg"><a href="' +
        omnitureArrayLinks["page-thumb"] +
        '"><img src="' +
        merchImage +
        '"/></a><div class="merchZoomIcon"></div></div>\
			<div class="merchDetail">\
				<div class="merchPriceWrapper"><div class="merchName"><a href="' +
        omnitureArrayLinks["page-title"] +
        '" >' +
        merchTitle +
        '</a></div><div class="merchPrice">' +
        merchPrice +
        '</div></div>\
				<div class="merchBuy"><a href="' +
        omnitureArrayLinks["page-button"] +
        '" class="merchBuyLink">Buy Now</a></div>\
			</div>'
        if (merchHoverCardPresent) {
            merchBody += '<div class="merchHC merchHC' + (i + 1) + '">\
							<div class="merchHCWrapper">\
								<div class="merchHCInnerWrapper">\
									<div class="merchHCHead"><a href="' +
            omnitureArrayLinks["hovercard-title"] +
            '">' +
            merchTitle +
            '</a></div>\
									<div class="merchHCBody">\
										<div class="merchHCLeftCon"><a href="' +
            omnitureArrayLinks["hovercard-thumb"] +
            '"><img src="' +
            merchImage +
            '" width="230px"/></a></div>\
										<div class="merchHCRightCon">\
											<h3 class="merchHCPrice">' +
            merchPrice +
            '</h3>';
            if (merchDesc != "" && merchDesc != null) {
                merchBody += '<h3>Description</h3><div>' + merchDesc + '</div>';
            }
            if (merchSizes != "" && merchSizes != null) {
                merchBody += '<h3>Sizes</h3><div>' + merchSizes + '</div>';
            }
            
            merchBody += '<div class="merchHCBuyNowCon"><a class="merchHCBuyNow" href="' + omnitureArrayLinks["hovercard-button"] + '">Buy Now &raquo;</a></div>\
										</div>\
										<div class="clear"></div>\
									</div>\
									<div class="merchHCFoot"></div>\
								</div>\
							</div>\
						</div>';
        }/* End of the Merch Hovercard Body */
        merchBody += '</li>';
    });
    merchBody += '</ul><div class="clear"></div>';
    
    var merchFoot = '<div class="clear"></div><div class="merchFoot"><div class="visitStore"><div  class="visitStoreLink" ><a>VISIT STORE</a></div></div></div>';
    var visitStoreFoot = $('#merchContainer').parent(".description").parent(".body").siblings(".foot");
    $(merchFoot).appendTo(visitStoreFoot);
    
    return merchBody;
}

/*These functions are used by the merch HC so that casual hovers less than 300 seconds
 * are omitted.
 */
function bringMerchHCOn(merchImg){
    merchImg.showTimer = window.setTimeout(function(){
        $(merchImg).siblings(".merchHC").fadeIn(300);
        /*
         if($(".merchImg").parent().siblings(".merchHC3").isVisible()){
         $(".merch.small.item1").css("z-index","0");
         $(".merch.small.item2").css("z-index","0");
         }
         */
    }, 300);
}

function killMerchHC(merchImg){
    if (merchImg.showTimer) {
        window.clearTimeout(merchImg.showTimer);
        /*
         if(!($(".merchImg").parent().siblings(".merchHC3").isVisible())){
         $(".merch.small.item1").css("z-index","8");
         $(".merch.small.item2").css("z-index","6");
         }
         */
    }
}

/* Registereing the hover events */
function registerMerchHoverEvents(){
    $(".merchImg").hover(function(){
        //bringMerchHCOn(this);
    }, function(){
        //killMerchHC(this);
    });
    $(".merchHC").hover(function(){
    }, function(){
        $(this).fadeOut(300);
    });
}

/* FLike in Merch Module*/

/*
 function merchFLike(fbLikeObj){
 var url;
 var fbLike;
 var fbLikeUrl;
 
 if (fbLikeObj.fblikePosition=="horizontal") {
 var layout = "button_count";
 }
 else if (fbLikeObj.fblikePosition=="vertical"){
 var layout="box_count";
 }
 $(fbLikeObj.blockSelector).each(function(){
 if ($(this).find('.fb_like').length == 0) {
 url = $(this).find(fbLikeObj.urlSelector).attr(fbLikeObj.urlQualifier);
 
 fbLike = '<iframe src="http://www.facebook.com/plugins/like.php?href=' + url + '&amp;layout=' + layout + '&amp;show_faces=false&amp;width=90&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:90px; height:21px"></iframe>';
 $(this).find(fbLikeObj.insertionSelector).after('<div class="fb_like" style="float:left;">' + fbLike + '</div>');
 }
 });
 };
 */
/* The piece of code which generates the merch, adds the dom and registers the events. */
$(document).ready(function(){
    if (($('#html-327531.html').attr('class') == 'html') || ($('#html-5403380.html').attr('class') == 'html') || ($('#html-5403182.html').attr('class') == 'html') || ($('#html-5403389.html').attr('class') == 'html') || ($('#html-5403385.html').attr('class') == 'html') || ($('#html-5403383.html').attr('class') == 'html') || ($('#html-5602858.html').attr('class') == 'html') || ($('#html-5590929.html').attr('class') == 'html') || ($('#html-5591166.html').attr('class') == 'html')) {
        $("#merchContainer").html(generateMerchStructure());
        $("#merchData").empty();
        registerMerchHoverEvents();
        $("#merchContainer a").makeLinksExternal();
        
    }
    
    if (location.href.indexOf("/fr/") != -1) {
        updateNavBar(fraGlbNav);
        updateHomePage(fraGlbNav);
    }
    else 
        if (location.href.indexOf("/de/") != -1) {
            updateNavBar(gerGlbNav);
            updateHomePage(gerGlbNav);
        }
        else 
            if (location.href.indexOf("/br/") != -1) {
                updateNavBar(braGlbNav);
                updateHomePage(braGlbNav);
            }
            else 
                if (location.href.indexOf("/ca-fr/") != -1) {
                    updateNavBar(cafraGlbNav);
                    updateHomePage(cafraGlbNav);
                }
    
    
    
    
    var viewmoretext = $('.international .grid_5 .module .content .foot .nav_meta ul li.more a').text().trim();
    if (viewmoretext.toUpperCase() == "VIEW MORE") {
        $('#canada_france_home .grid_5 .module .content .foot .nav_meta ul li.more a').text("VOIR PLUS");
        $('#germany_home .grid_5 .module .content .foot .nav_meta ul li.more a').text("MEHR");
        $('#brazil_home .grid_5 .module .content .foot .nav_meta ul li.more a').text("VEJA MAIS");
        $('#france_home .grid_5 .module .content .foot .nav_meta ul li.more a').text("VOIR PLUS");
    }
	
	$('.blog_listing .articles li.article').each(function(){
        $(this).find('.description a').each(function(){
            if ($(this).text() == "Read more") {
                $(this).addClass("read_more");
            }
        });
    });
	
    if (($('body').attr('id') == "blog_detail")) {
        if ($('.blog_entry #tumblr_button_abc123').length == 0) {	
			
				var tumblr_link_url = "http://www.simpleplan.com" + window.location.pathname +"?cmpid=simpleplan/tumblr/share-on-tumblr/blog-detail/";
            	var tumblr_link_name = $('.content div.article .title h4').text();
            	var tumblr_link_description = $('.blog_entry .description').html();
						
				// IE 7 has issue with create element, hence its tags are framed with required variables						
				if ($('#blog_detail').hasClass('msie7')) {
					var tumblrStyle = "text-indent:-9999px; overflow:hidden; width:63px; height:20px; background:url('http://platform.tumblr.com/v1/share_2.png') top left no-repeat transparent;";
					var tumblrHref = "http://www.tumblr.com/share/link?url=" + encodeURIComponent(tumblr_link_url) + "&name=" + encodeURIComponent(tumblr_link_name) + "&description=" + encodeURIComponent(tumblr_link_description);
					$('.blog_entry .twitter-share-button').after('<span id="tumblr_button_abc123"><a style="' + tumblrStyle + '" title="Share on Tumblr" href=' + tumblrHref + ' target="_blank"/></span>');
				}
				else {
            		$('.twitter-share-button').after('<span id="tumblr_button_abc123"></span>');
            
		            var tumblr_button = document.createElement("a");
            		tumblr_button.setAttribute("href", "http://www.tumblr.com/share/link?url=" + encodeURIComponent(tumblr_link_url) + "&name=" + encodeURIComponent(tumblr_link_name) + "&description=" + encodeURIComponent(tumblr_link_description));
            		tumblr_button.setAttribute("title", "Share on Tumblr");
            		tumblr_button.setAttribute("style", "display:inline-block; text-indent:-9999px; overflow:hidden; width:63px; height:20px; background:url('http://platform.tumblr.com/v1/share_2.png') top left no-repeat transparent;");
            		tumblr_button.setAttribute("target", "_blank");
            		tumblr_button.innerHTML = "Share on Tumblr";
			
		            $('.blog_entry #tumblr_button_abc123').append(tumblr_button);	
				}				
            
            	var plusone = document.createElement("g:plusone");
            	plusone.setAttribute("href", tumblr_link_url);
            	plusone.setAttribute("size", "medium");
            	$('.twitter-share-button').after('<div class="gPlus"></div>');
			
            	$('.gPlus').append(plusone);		
        }
    }
    $('.articles li.article').each(function(){
    
        var tumblr_link_url = "http://www.simpleplan.com" + $(this).find(".title h4 a").attr("href") +"?cmpid=simpleplan/tumblr/share-on-tumblr/blog-detail/";
        var tumblr_link_name = $(this).find('.title h4').text();
        var tumblr_link_description = $(this).find('.description').clone();
tumblr_link_description.find('a.read_more').remove();
tumblr_link_description = $(tumblr_link_description).html();
        
        
        var plusone = document.createElement("g:plusone");
        plusone.setAttribute("href", tumblr_link_url);
        plusone.setAttribute("size", "medium");
        $(this).find('.twitter-share-button').after('<div class="gPlus"></div>');
        $(this).find('.gPlus').append(plusone);
        $(this).find('.twitter-share-button').after('<span id="tumblr_button_abc123"></span>');
        
        
        var tumblr_button = document.createElement("a");
        tumblr_button.setAttribute("href", "http://www.tumblr.com/share/link?url=" + encodeURIComponent(tumblr_link_url) + "&name=" + encodeURIComponent(tumblr_link_name) + "&description=" + encodeURIComponent(tumblr_link_description));
        tumblr_button.setAttribute("title", "Share on Tumblr");
        tumblr_button.setAttribute("style", "display:inline-block; text-indent:-9999px; overflow:hidden; width:63px; height:20px; background:url('http://platform.tumblr.com/v1/share_2.png') top left no-repeat transparent;");
        tumblr_button.setAttribute("target", "_blank");
        tumblr_button.innerHTML = "Share on Tumblr";
        $(this).find('#tumblr_button_abc123').append(tumblr_button);
        
    });
    
    window.___gcfg = {
        lang: 'en-US'
    };
    (function(){
        var po = document.createElement('script');
        po.type = 'text/javascript';
        po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(po, s);
    })();
    
});

function eoscInit(){

    $('.blog_listing .articles li.article').each(function(){
        $(this).find('.description a').each(function(){
            if ($(this).text() == "Read more") {
                $(this).addClass("read_more");
            }
        });
    });
    if (($('body').attr('id') == "blog_detail")) {
        if ($('.blog_entry #tumblr_button_abc123').length == 0) {
            $('.twitter-share-button').after('<span id="tumblr_button_abc123"></span>');
            
            var tumblr_link_url = "http://www.simpleplan.com" + window.location.pathname +"?cmpid=simpleplan/tumblr/share-on-tumblr/blog-detail/";
            var tumblr_link_name = $('.content div.article .title h4').text();
           var tumblr_link_description = $('.blog_entry .description').html();
			
            var plusone = document.createElement("g:plusone");
            plusone.setAttribute("href", tumblr_link_url);
            plusone.setAttribute("size", "medium");
            $('.twitter-share-button').after('<div class="gPlus"></div>');
            $('.gPlus').append(plusone);
            
            var tumblr_button = document.createElement("a name='tumblr'");
			tumblr_button.setAttribute("href", "http://www.tumblr.com/share/link?url=" + encodeURIComponent(tumblr_link_url) + "&name=" + encodeURIComponent(tumblr_link_name) + "&description=" + encodeURIComponent(tumblr_link_description));
            tumblr_button.setAttribute("title", "Share on Tumblr");
			tumblr_button.setAttribute("style", "display:inline-block; text-indent:-9999px; overflow:hidden; width:63px; height:20px; background:url('http://platform.tumblr.com/v1/share_2.png') top left no-repeat transparent;");
            tumblr_button.setAttribute("target", "_blank");
            tumblr_button.innerHTML = "Share on Tumblr";
			
			$('.blog_entry #tumblr_button_abc123').append(tumblr_button);
	        }
    }
    $('.articles li.article').each(function(){
    
        var tumblr_link_url = "http://www.simpleplan.com" + $(this).find(".title h4 a").attr("href") +"?cmpid=simpleplan/tumblr/share-on-tumblr/blog-detail/";
        var tumblr_link_name = $(this).find('.title h4').text();
        var tumblr_link_description = $(this).find('.description').clone();
tumblr_link_description.find('a.read_more').remove();
tumblr_link_description = $(tumblr_link_description).html();
        
        
        var plusone = document.createElement("g:plusone");
        plusone.setAttribute("href", tumblr_link_url);
        plusone.setAttribute("size", "medium");
        $(this).find('.twitter-share-button').after('<div class="gPlus"></div>');
        $(this).find('.gPlus').append(plusone);
        $(this).find('.twitter-share-button').after('<span id="tumblr_button_abc123"></span>');
        
        
        var tumblr_button = document.createElement("a");
        tumblr_button.setAttribute("href", "http://www.tumblr.com/share/link?url=" + encodeURIComponent(tumblr_link_url) + "&name=" + encodeURIComponent(tumblr_link_name) + "&description=" + encodeURIComponent(tumblr_link_description));
        tumblr_button.setAttribute("title", "Share on Tumblr");
        tumblr_button.setAttribute("style", "display:inline-block; text-indent:-9999px; overflow:hidden; width:63px; height:20px; background:url('http://platform.tumblr.com/v1/share_2.png') top left no-repeat transparent;");
        tumblr_button.setAttribute("target", "_blank");
        tumblr_button.innerHTML = "Share on Tumblr";
        $(this).find('#tumblr_button_abc123').append(tumblr_button);
        
    });
    
    window.___gcfg = {
        lang: 'en-US'
    };
    (function(){
        var po = document.createElement('script');
        po.type = 'text/javascript';
        po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(po, s);
    })();
    
    /* group configuration */
    var photoFCCategories = new Array("category_56708");
    var videoFCCategories = new Array("category_56710");
    var blogFCCategories = new Array("category_56709");
    
    var groupNotifier = true;
    var badgeinsert = '<div class="badge"><a class="badgelink" href="http://www.simpleplan.com/group/get-your-heart-on/"></a></div>';
    if (groupNotifier) {
    
        $('.photo_thumbnail li.photo').each(function(){
            for (count = 0; count < photoFCCategories.length; count++) {
                $(".photo_thumbnail li." + photoFCCategories[count] + ".photo").addClass("getyourhearton");
                
            }
        });
        
        
        $('.video_thumbnail li.video').each(function(){
            for (count = 0; count < videoFCCategories.length; count++) {
                $(".video_thumbnail li." + videoFCCategories[count] + ".video").addClass("getyourhearton");
                
            }
        });
        
        $('.blog_listing li.article').each(function(){
            for (count = 0; count < blogFCCategories.length; count++) {
                $(".blog_listing li." + blogFCCategories[count] + ".article").addClass("getyourhearton");
                
            }
        });
        
        $('.photo_thumbnail li.getyourhearton.photo').each(function(){
            $(this).find('.img').append(badgeinsert);
        });
        $('.video_thumbnail li.getyourhearton.video').each(function(){
            $(this).find('.img').append(badgeinsert);
        });
        $('.blog_listing li.getyourhearton.article').each(function(){
            $(badgeinsert).insertBefore($(this).find('.title'));
        });
    }
    $(".badges ul").each(function(){
        if ($(this).find("li").length > 0) {
            $(this).html('<li class="badge"><a class="badgeImageReplace" href="/group/get-your-heart-on/"></a></li>');
        }
    });
    
    var upcomingHead = $('#event_listing-707476.event_listing .module .content .head').find('#upcomingHead');
    if (!(upcomingHead.length > 0)) {
        var eventArchiveHead = '<div id="upcomingHead"><div id="archiveSpan">Been to a show?</div><a id="uploadTag" href="/past-shows/">Upload your show photos and videos</a></div>';
        $("#event_listing-707476.event_listing .module .content .head").append(eventArchiveHead);
    }
    var archiveHead = $('#event_listing-5216723.event_listing .module .content .head').find('#archiveHead');
    if (!(archiveHead.length > 0)) {
        var eventUpcomingHead = '<div id="archiveHead"><div id="upcomingSpan">Want to see simple plan?</div><a id="upcomingTag" href="/event/" >Check out upcoming dates</a></div>';
        $("#event_listing-5216723.event_listing .module .content .head").append(eventUpcomingHead);
    }
    
    
    $('.grid_5 .event_listing ul.cal_events li.cal_event').each(function(){
        var availablity = $(this).find('.availability');
        var buyLink = $(this).find('.buy');
        if (!(buyLink.length > 0 || availablity.length > 0)) {
            $(this).find('.date').css('margin-top', '0px');
        }
        
    });
    
    
    $('#event_listing-5216724.event_listing ul.cal_events li.cal_event').each(function(){
    
        var availablity = $(this).find('.availability').text();
        if (availablity.length > 0 || availablity.toUpperCase() == "SOLD OUT") {
            var buyLink = $(this).find('.buy');
            if (buyLink.length > 0) {
            
                $(this).find('.availability').insertBefore($(this).find('.buy'));
                $(this).find('.buy').remove();
            }
            else {
                $(this).find('.availability').insertBefore($(this).find('.date'));
            }
        }
    });
    
    $('#event_listing-707476.event_listing ul.cal_events li.cal_event').each(function(){
    
        var availablity = $(this).find('.availability').text();
        if (availablity.length > 0 || availablity.toUpperCase() == "SOLD OUT") {
            var buyLink = $(this).find('.buy');
            if (buyLink.length > 0) {
            
                $(this).find('.availability').insertBefore($(this).find('.buy'));
                $(this).find('.buy').remove();
            }
            else {
                $(this).find('.availability').insertBefore($(this).find('.date'));
            }
        }
    });
    
    $('#event_listing-5206070.event_listing ul.cal_events li.cal_event').each(function(){
    
        var availablity = $(this).find('.availability').text();
        if (availablity.length > 0 || availablity.toUpperCase() == "SOLD OUT") {
            var buyLink = $(this).find('.buy');
            if (buyLink.length > 0) {
            
                $(this).find('.availability').insertBefore($(this).find('.buy'));
                $(this).find('.buy').remove();
            }
            else {
                $(this).find('.availability').insertBefore($(this).find('.date'));
            }
        }
    });
    
    $('#event_listing-5216726.event_listing ul.cal_events li.cal_event').each(function(){
    
        var availablity = $(this).find('.availability').text();
        if (availablity.length > 0 || availablity.toUpperCase() == "SOLD OUT") {
            var buyLink = $(this).find('.buy');
            if (buyLink.length > 0) {
            
                $(this).find('.availability').insertBefore($(this).find('.buy'));
                $(this).find('.buy').remove();
            }
            else {
                $(this).find('.availability').insertBefore($(this).find('.date'));
            }
        }
    });
    
    
    
    
    var memberGoing = " Fans Going ";
    $('#event_listing-707476.event_listing ul.cal_events li.cal_event').each(function(){
        var attendeeCount = $(this).find('.attendee_count').html();
        var eventPath = $(this).find('.txt .date h4 a').attr('href');
        var moreinfo = $(this).find(".moreinfo");
        if (!(moreinfo.length > 0)) {
            $(this).find('.attendee_count').remove();
            if (attendeeCount != "") {
                if (attendeeCount == null) {
                    attendeeCount = 0
                }
                else {
                    attendeeCount = attendeeCount.substring((attendeeCount.lastIndexOf(":") + 1), attendeeCount.length).trim();
                }
                if (attendeeCount == 1) {
                    memberGoing = " Fan Going";
                }
                else {
                    memberGoing = " Fans Going";
                }
                var member_det = '<div class="member_details"><div class="membrGoing"><span><a href="' + eventPath + '">' + attendeeCount + memberGoing + '</a></span></div></div><div class="moreinfo"><a class="viewmoreinfo" href="' + eventPath + '">More info</a></div>';
                $(this).find('.txt').append(member_det);
                
            }
            else {
                var member_det = '<div class="moreinfo" style="padding-left:0px;"><a class="viewmoreinfo" href="' + eventPath + '">More info</a></div>';
                $(this).find('.txt').append(member_det);
            }
        }
        
    });
    
    $('#event_listing-5216723.event_listing ul.cal_events li.cal_event').each(function(){
        var memberGoing = " Fans Went";
        var eventPath = $(this).find('.txt .date h4 a').attr('href');
        eventPath = eventPath + "?show=archive";
        $(this).find('.txt .date h4 a').attr('href', eventPath);
        var attendeeCount = $(this).find('.attendee_count').html();
        $(this).find('.attendee_count').remove();
        
        
        if (attendeeCount != "") {
            if (attendeeCount == null) {
                attendeeCount = 0
            }
            else {
                attendeeCount = attendeeCount.substring((attendeeCount.lastIndexOf(":") + 1), attendeeCount.length).trim();
            }
            if (attendeeCount == 1) {
                memberGoing = " Fan Went";
            }
            
            var member_det = '<div class="member_details"><div class="membrGoing"><a href="' + eventPath + '" >' + attendeeCount + memberGoing + '</a></div></div>';
            $(this).find('.txt').append(member_det);
        }
        
        
    });
    
    $('#event_listing-5216723.event_listing .module .content .body ul.cal_events li.cal_event').each(function(){
        var viewhref = $(this).find('.txt .date h4 a').attr("href");
        var viewEvent = $(this).find(".moreinfo");
        if (!(viewEvent.length > 0)) {
            $(this).append('<div class="viewEvent"><a href="' + viewhref + '">View Photos & Videos</a></div>');
            
        }
    });
    $('#event_listing-5216723.event_listing ul.cal_events li.cal_event').each(function(){
        var eventPath = $(this).find('.txt .date h4 a').attr('href');
        var moreinfo = $(this).find(".moreinfo");
        if (!(moreinfo.length > 0)) {
            var member_det = '<div class="moreinfo" style="padding-left:0px;"><a class="viewmoreinfo"   href="' + eventPath + '">More Info</a></div>';
            $(this).find('.txt').append(member_det);
        }
    });
    
    
    
    
    //code to disable event detail page(tour), this code removes anchor tag from event titles
    
    //truncating titles in photo page
    var photoTitleLen = 18;
    $('.photos li .txt .title h4 a').each(function(){
        var trunc = (this).innerHTML;
        if (trunc.length > photoTitleLen) {
            trunc = trunc.substring(0, photoTitleLen);
            trunc += '<span>' + '...</span>';
            (this).innerHTML = trunc;
        }
    });
    
    var vidTitleLen = 15;
    $('.videos li.pro .txt .author a ').each(function(){
        var trunc = (this).innerHTML;
        if (trunc.length > vidTitleLen) {
            trunc = trunc.substring(0, vidTitleLen);
            trunc += '<span>' + '...</span>';
            (this).innerHTML = trunc;
        }
    });
    //Modifying the legal text in the log in and sign up pages.
    $("body#sign_up #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show();
    $("body#join #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show();
    
    
    /* For SP and EOS integration */
    $(".edit_account #accountData .buttons.input .button.submit input.submit").removeAttr("onclick");
    $(".edit_account #accountQuestoins .buttons.input .button.submit input.submit").removeAttr("onclick");
    
    $('.edit_account #accountData .buttons.input .button.submit input.submit').unbind('click');
    $('.edit_account #accountQuestoins .buttons.input .button.submit input.submit').unbind('click');
    
    $.wmgfeature.spFeatureEditAccountAccData(".edit_account #accountData .buttons.input .button.submit input.submit", "edit_account-294534", true, arrElementIDs, "http://www.simpleplan.com/", "579704");
    $.wmgfeature.spFeatureEditAccountAccQuestions(".edit_account #accountQuestoins .buttons.input .button.submit input.submit", "edit_account-294534", true, arrElementIDs, "http://www.simpleplan.com/", "2006");
    /* For SP and EOS integration */
    
    var modHead = $('body#home_tumbler .blog_listing');
    var modHeadoffset = modHead.offset();
    var modHeadTop = modHeadoffset.top;
    $('body#home_tumbler .blog_listing .foot .nav_page ul li a').click(function(){
        $('html, body').animate({
            scrollTop: modHeadTop
        }, 'slow');
        return false;
    });
    
    /*comments blog */
    $.each($('.activity .comment'), function(index, value){
        var newCommentNo = $('.activity .comment').eq(index).html();
        newCommentNo = newCommentNo.replace("Comments", "").replace("(", "").replace(")", "");
        newCommentNo = newCommentNo.replace("Comment", "");
        $('.activity .comment').eq(index).html(newCommentNo);
    });
    /* Official Twitter and fLike buttons implementation - pagination */
    
    /* Blog Author Name - Start*/
    
    $.each($('.articles .article .author'), function(index, value){
        var authorName = $('.articles .article .author').eq(index).html().replace("Posted by", "");
        $('.articles .article .author').eq(index).html(authorName);
        
    });
    
    $.each($('div.article .author'), function(index, value){
        var authorName = $('div.article .author').eq(index).html().replace("Posted by", "");
        $('div.article .author').eq(index).html(authorName);
        
    });
    
    
    $('.blog_listing .articles li.article').each(function(){
    
        var meKill = $(this).find('.author');
        $(meKill).insertBefore($(this).find('.description'));
        
        blogcharacters = $(this).find('.description').text().length;
        writeToConsole(blogcharacters + " blog" + $(this).find('.description').text());
        if (blogcharacters > 465) {
            $(this).find('.description a').each(function(){
            
                if ($(this).text() == "READ MORE") {
                    $(this).text("....");
                    $(this).addClass("blogreadmore");
                }
            });
        }
        else {
            $(this).find('.description a').each(function(){
                if ($(this).text() == "READ MORE") {
                    $(this).css("display", "none");
                }
            });
        }
        
    });
    
    
}


function updateNavBar(newNavObj){
    if (newNavObj != null) {
        $('body.international .nav_main ul li.nav-home a').text(newNavObj.Home);
        $('body.international .nav_main ul li.nav-blog a').text(newNavObj.News);
        $('body.international .nav_main ul li.nav-custom.nav-music a').text(newNavObj.Music);
        $('body.international .nav_main ul li.nav-video a').text(newNavObj.Videos);
        $('body.international .nav_main ul li.nav-photo a').text(newNavObj.Photos);
        $('body.international .nav_main ul li.nav-bio a').text(newNavObj.Bio);
        $('body.international .nav_main ul li.nav-fanclub a').text(newNavObj.Fanclub);
        $('body.international .nav_main ul li.nav-event a').each(function(){
            if ($(this).text() == "Tour") {
                $(this).text(newNavObj.Tour_Dates);
            }
        });
        $('body.international .nav_main ul li.nav-community_landing a').each(function(){
            if ($(this).text() == "Community") {
                $(this).text(newNavObj.Community);
            }
        });
        $('body.international .nav_main ul li.nav-community_landing ul li#discussionsNav a').text(newNavObj.discussions);
        $('body.international .nav_main ul li.nav-community_landing ul li#communityHomeNav a').text(newNavObj.Community);
        $('body.international .nav_main ul li.nav-event ul li#upcomingNav a').text(newNavObj.upcoming);
        $('body.international .nav_main ul li.nav-event ul li#archivesNav a').text(newNavObj.past);
        
        $('body.international .nav_main ul li.nav-custom.nav-store a').each(function(){
            if ($(this).text() == "Store") {
                $(this).text(newNavObj.Store);
            }
        });
    }
}

function updateHomePage(intPageObj){
    $('#rss_in-367007 .module .content .head h3').text(intPageObj.cellstream)
    $('.song_playlist .module .content .head h3').text(intPageObj.nowplaying);
    $('#event_listing-5206070 .module .content .head h3').text(intPageObj.shows);
    $('#discussion_listing-5179321 .module .content .head h3').text(intPageObj.spmemories);
    $('.song_playlist .nav_meta ul li.launchPlayer a').text(intPageObj.launchplayer);
    $('.song_playlist .nav_meta ul li.more a').text(intPageObj.moremusic);
    $('#video_thumbnail-5305840 .module .content .foot .nav_meta ul li.more a').text(intPageObj.viewMore)
    $('#video_thumbnail-5381826 .module .content .foot .nav_meta ul li.more a').text(intPageObj.viewMore)
    $('#event_listing-5206070 .module .content .foot .nav_meta ul li.more a').text(intPageObj.viewMore)
}


/* End of Functions for New Merch */

