﻿/*Defualt.aspx-start*/
var css_browser_selector = function() { var ua = navigator.userAgent.toLowerCase(), is = function(t) { return ua.indexOf(t) != -1; }, h = document.getElementsByTagName('html')[0], b = (!(/opera|webtv/i.test(ua)) && /msie\s(\d)/.test(ua)) ? ('ie ie' + RegExp.$1) : is('firefox/2') ? 'gecko ff2' : is('firefox/3') ? 'gecko ff3' : is('gecko/') ? 'gecko' : is('opera/9') ? 'opera opera9' : /opera\s(\d)/.test(ua) ? 'opera opera' + RegExp.$1 : is('konqueror') ? 'konqueror' : is('chrome') ? 'chrome webkit safari' : is('applewebkit/') ? 'webkit safari' : is('mozilla/') ? 'gecko' : '', os = (is('x11') || is('linux')) ? ' linux' : is('mac') ? ' mac' : is('win') ? ' win' : ''; var c = b + os + ' js'; h.className += h.className ? ' ' + c : c; } ();

function HideCenterPanels(type) {
    //alert(type)
    //user playlist
    if (type != 'playlist' && type != 'JustShowPlaylist') {
        $("#playlistcontentsdiv").hide();
    }
    else if (type == 'JustShowPlaylist') {
        animatedcollapse.hide('boxMusicFeedsContents');
        $("#MusicFeedContent").hide();
        //document.getElementById('boxMusicFeedsHeading12').className = 'showUpArrow';
        animatedcollapse.hide('taggedPlaylists');
        //document.getElementById('boxTagsHeading').className = 'showUpArrow';
        return;
    }
    //history
    if (type != 'history') { $("#HistoryContent").hide(); }
    else { ShowCenterWidget('HistoryContent', 'boxHistoryHeading12', 'boxHistoryContents'); }
    //music feeds
    if (type != 'musicfeeds') { $("#MusicFeedContent").hide(); }
    else { ShowCenterWidget('MusicFeedContent', 'boxMusicFeedsHeading12', 'boxMusicFeedsContents'); }
    //tag
    if (type != 'tag') { $("#TaggedPlaylistsContent").hide(); }
    else { ShowCenterWidget('TaggedPlaylistsContent', 'boxTagsHeading', 'taggedPlaylists'); }
    //search
//    if (type != 'search' && type != 'playlist') { $("#searchcontents").hide(); }
//    else if (type == 'playlist') {
//        animatedcollapse.hide('boxSearch1');
//        document.getElementById('boxSearchHeading').className = 'showUpArrow';
//    }
    //    else { ShowCenterWidget('searchcontents', 'boxSearchHeading', 'boxSearch1'); }
    if (type != 'search' && type != 'playlist') { $("#searchcontents").hide(); }
    if (type != 'search') { $("#searchcontents").hide(); }
    else { ShowCenterWidget('searchcontents', 'boxSearchHeading', 'boxSearch1'); }
    
    if (type != 'playlist') { $("#playlistcontentsdiv").hide(); }
    else {
        animatedcollapse.hide('boxSearch1');
        document.getElementById('boxSearchHeading').className = 'showUpArrow';
        $("#playlistcontentsdiv").show();
    }
    
    

    
    
    //user browsing
    if (type != 'userbrowse') { $("#UserBrowseContent").hide(); }
    else { $("#UserBrowseContent").show(); }
    //friends
    if (type != 'friends') { $("#FriendContent").hide(); }
    else { ShowCenterWidget('FriendContent', 'boxFriendsHeading12', 'boxFriendsContents'); }
    //admin users
    if (type != 'adminusers') { $("#AdminUsersContent").hide(); }
    else { ShowCenterWidget('AdminUsersContent', 'boxAdminUserHeading', 'boxAdminUsers'); }
    //most played
    if (type != 'mostPlayed') { $("#MostPlayedContent").hide(); }
    else { ShowCenterWidget('MostPlayedContent', 'boxMostPlayedHeading', 'boxMostPlayed'); }
    //recently added
    if (type != 'RecentlyAdded') { $("#RecentlyAddedContent").hide(); }
    else { ShowCenterWidget('RecentlyAddedContent', 'boxRecentlyAddedHeading', 'boxRecentlyAdded'); }
    //Browse
    if (type != 'Browse') { $("#BrowseContent").hide(); }
    else { ShowCenterWidget('BrowseContent', 'boxBrowseContentHeading', 'boxBrowsesongs'); }
    //ratedUsers
    if (type != 'rateUsers') { $("#rateUsersContent").hide(); }
    else { ShowCenterWidget('rateUsersContent', 'boxRateUsersHeading', 'divRateUsersbox'); }
}
function ShowCenterWidget(contentDiv, HeaderID, boxID) {
    $("#" + contentDiv).show();
    //document.getElementById(HeaderID).className = 'PlaylistHeader';
    animatedcollapse.show(boxID);
}
function CreateDialogs() {
    $("#divAddPlaylist").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 380, width: 216,
        modal: true, zIndex: 2000000, minHeight: 380
    });
    $('#divAddPlaylist').dialog("close");
    $("#divTagforUser").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 385, width: 216,
        modal: true, zIndex: 2000000, minHeight: 385
    });
    $('#divTagforUser').dialog("close");
    $("#divAddNewPlayList").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 105, width: 216,
        modal: true, zIndex: 2000000, minHeight: 105
    });
    $('#divAddNewPlayList').dialog("close");
    $("#divRenamePlaylist").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 165, width: 250,
        modal: true, zIndex: 2000000, minHeight: 165
    });
    $('#divRenamePlaylist').dialog("close");
    $("#divLoading").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false, closeOnEscape: false,
        resizable: false, height: 36, width: 36,
        modal: true, zIndex: 2000000, minHeight: 36
    });
    $('#divLoading').dialog("close");
    $("#divRatingComment").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 215, width: 285,
        modal: true, zIndex: 2000000, minHeight: 190,
        open: function() { document.getElementById('txtRatingComment').focus(); }
    });
    $('#divRatingComment').dialog("close");
    $("#divRemovefromMusiFeedPopup").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 175, width: 260,
        modal: true, zIndex: 2000000, minHeight: 175
    });
    $('#divRemovefromMusiFeedPopup').dialog("close");
    $("#divAddToMusicFeedPopup").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 180, width: 280,
        modal: true, zIndex: 2000000, minHeight: 175
    });
    $('#divAddToMusicFeedPopup').dialog("close");
    $("#divEditMedia").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 950, width: 385,
        modal: true, zIndex: 2000000, minHeight: 700
    });
    $('#divEditMedia').dialog("close");
    $("#divRemovePlaylist").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 160, width: 280,
        modal: true, zIndex: 2000000, minHeight: 160
    });
    $('#divRemovePlaylist').dialog("close");
    $("#divShufflePlaylist").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 160, width: 280,
        modal: true, zIndex: 2000000, minHeight: 160
    });
    $('#divShufflePlaylist').dialog("close");
    $("#divFacebookLogin").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 200, width: 320,
        modal: true, zIndex: 2000000, minHeight: 160
    });
    $('#divFacebookLogin').dialog("close");
    $("#divLinktoSong").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 100, width: 400,
        modal: true, zIndex: 2000000, minHeight: 100
    });
    $('#divLinktoSong').dialog("close");
    $("#divTwitterSong").dialog({ bgiframe: true, autoOpen: false,
        dialogClass: 'dialog', draggable: false,
        resizable: false, height: 250, width: 410,
        modal: true, zIndex: 2000000, minHeight: 250
    });
    $('#divTwitterSong').dialog("close");
}

function minimizePlaylist(headerclass) {
    if (headerclass == 'showDownArrow') {
        animatedcollapse.hide('testdiv');
        document.getElementById('boxPlaylistHeading').className = 'showUpArrow';
    }
}
function InitAnimateCollapse() {
    animatedcollapse.addDiv('boxGenresContents', 'fade=1');
    //animatedcollapse.addDiv('boxBrowseContents', 'fade=1, hide=true');
    //animatedcollapse.addDiv('boxShoutBoxContents', 'fade=1, hide=true');
    animatedcollapse.addDiv('boxAdministrationContent', 'fade=1, hide=true');
//    if (CURRENT_USERID == '') { animatedcollapse.addDiv('boxPlaylistsContents', 'fade=1, hide=true'); }
    //    else { animatedcollapse.addDiv('boxPlaylistsContents', 'fade=1'); }
    animatedcollapse.addDiv('boxPlaylistsContents', 'fade=1');
    animatedcollapseLeft.addDiv('leftSideAllBoxes', 'fade=1, speed=400');
    animatedcollapseLeft.addDiv('rightSideBoxes', 'fade=1, speed=400');
    animatedcollapse.addDiv('taggedPlaylists', 'fade=1');
    animatedcollapse.addDiv('testdiv', 'fade=1');
    animatedcollapse.addDiv('divPlaylistEdit', 'fade=1');
    animatedcollapse.addDiv('boxHistoryContents', 'fade=1');
    animatedcollapse.addDiv('boxSearch1', 'fade=1');
    animatedcollapse.addDiv('boxMusicFeedsContents', 'fade=1');
    animatedcollapse.addDiv('boxFriendsContents', 'fade=1');
    animatedcollapse.addDiv('boxAdminUsers', 'fade=1');
    animatedcollapse.addDiv('boxMostPlayed', 'fade=1');
    animatedcollapse.addDiv('boxRecentlyAdded', 'fade=1');
    animatedcollapse.addDiv('boxBrowsesongs', 'fade=1');
    animatedcollapse.addDiv('divRateUsersbox', 'fade=1');
    animatedcollapse.init();
    animatedcollapseLeft.init();
//    if ($("#boxShoutBoxHeading12").hasClass("showUpArrow")) {
//        toggleclass('boxShoutBoxHeading12');
//        animatedcollapse.toggle('boxShoutBoxContents');
//    }
}
function InitFilter() {
    $("#boxGenresContents div:first").addClass('firstContent');
    $("#txtNewPlaylist").keyup(function(event) {
        if (event.keyCode == 13) { AddPlaylist(); }
    });
    $("#txtNewPlaylistName").keyup(function(event) {
        if (event.keyCode == 13) { AddNewPlayListClick(); }
    });
    $("#txtRatingComment").keyup(function(event) {
        if (event.keyCode == 13) { ValidateRatingComments(0,'txtRatingComment'); }
    });
    $("#ShoutBox1_txtShoutRatingComment").keyup(function(event) {
        if (event.keyCode == 13) { ValidateRatingComments(0, 'ShoutBox1_txtShoutRatingComment'); }
    });
    $("#txtRenamePlaylist").keyup(function(event) {
        if (event.keyCode == 13) { RenamePlayList(); }
    });
    $("#txtFilterPerson").keyup(function(event) {
        if (event.keyCode == 13) { TagforSelectedUsers(); }
    });   
    $("#txtTwitterMessage").charCounter(65, {
        container: "#spanTwitterCharCount"
    });
    $("#txtTwitterUsername").keyup(function(event) {
        if (event.keyCode == 13) { TwitterSong(); }
    });
    $("#txtTwitterPassword").keyup(function(event) {
        if (event.keyCode == 13) { TwitterSong(); }
    });
    $("#txtTwitterMessage").keyup(function(event) {
        if (event.keyCode == 13) { TwitterSong(); }
    });    
}
function SessionExpired() {
    ShowNotification('Your session has expired');
    SignOut();
}
function showwait() {
    $("#imgMainloading").remove();   
    SetVisibilityFalse();
    HideCenterPanels('search');
}
function CancelAlreadyOpenRequests() {    
    var sd = __pendingCallbacks.length;
    while (sd > 0) {
         sd = __pendingCallbacks.length;
         if (__pendingCallbacks[sd - 1]!=null && __pendingCallbacks[sd - 1].xmlRequest != null) {
             __pendingCallbacks[sd - 1].xmlRequest.abort();
         }
        __pendingCallbacks.splice(0, 1);
    }
}
function ChangetoBlue(cookieName, cookieExpiration) {
    if (theme != 'blue') {
        theme = 'blue';
        Theme_Img_Folder = 'img/blue/';
        LoadImage = "<img src='img/Loading_img.gif' class='loading' />";
        ChangeColorScheme('css/global.css', 'css/globalBlack.css', 'img/blue/', 'img/b/', cookieName, cookieExpiration);
    }
}
function Changetoblack(cookieName, cookieExpiration) {
    if (theme != 'black') {
        theme = 'black';
        Theme_Img_Folder = 'img/b/';
        LoadImage = "<img src='img/b/Loading_img.gif' class='loading' />";
        ChangeColorScheme('css/globalBlack.css', 'css/global.css', 'img/b/', 'img/blue/', cookieName, cookieExpiration);
    }
}
function ChangeColorScheme(newCss, oldCss, imgPathNew, imgPathPrev,cookieName,cookieExpiration) {
    try {
        var b = document.createElement("link");
        b.href = newCss;
        b.type = "text/css";
        b.rel = "stylesheet";
        var head = document.getElementsByTagName("head");
        if (head.length > 0) {
            head = head[0];
            var links = head.getElementsByTagName("link");
            var temp = null;
            for (i = 0; i < links.length; i++) {
                if (links[i].href.indexOf(oldCss) > -1) {
                    temp = links[i];
                    break;
                }
            }
            //append new style sheet
            head.appendChild(b);
            //remove previos style sheet
            if (temp != null) { temp.parentNode.removeChild(temp); }
            //update images path for selected color scheme
            $("img").each(function() {
                SetColorschemePath(this, imgPathPrev, imgPathNew);
            });
            $("input:image").each(function() {
                SetColorschemePath(this, imgPathPrev, imgPathNew);
            });
            //set color scheme cookie
            var exdate = new Date();
            exdate.setDate(exdate.getDate() + parseInt(cookieExpiration));
            document.cookie = cookieName + "=" + theme + ";expires=" + exdate.toGMTString();
            //set imeem player color
            if (iplayer != null) {
                var imeemPlayer = document.createElement('div');                
                var player12 = document.getElementById('imeemPlayer');
                if (player12) {
                    player12.parentNode.replaceChild(imeemPlayer, player12);
                    iplayer = null;
                    imeemPlayer.id = 'imeemPlayer';
                    if (document.getElementById('youtubePlayer').style.display == 'none') {                        
                        showplayer();
                    }
                }                
            }
        }
    }
    catch (ex) { }
}
function SetColorschemePath(obj, imgPathPrev, imgPathNew) {
    var src = obj.src;
    src = src.replace(imgPathPrev, imgPathNew);
    obj.src = src;
}
function SetVerticalbarheight(controlID, divID, flag, defaultHeight, isAdjustBothbars) {
    var longBarLeft = document.getElementById('leftSideAllBoxes');
    var longBarHalf = document.getElementById('rightSideBoxes');
    if (longBarLeft != null && longBarHalf != null) {
        var longBarLeftHeight = parseInt(longBarLeft.clientHeight != null && longBarLeft.clientHeight != 0 ? parseInt(longBarLeft.clientHeight) : (longBarLeft.offsetHeight != null && longBarLeft.offsetHeight != 0 ? parseInt(longBarLeft.offsetHeight) : 600));
        var longBarHalfHeight = parseInt(longBarHalf.clientHeight != null && longBarHalf.clientHeight != 0 ? parseInt(longBarHalf.clientHeight) : (longBarHalf.offsetHeight != null && longBarHalf.offsetHeight != 0 ? parseInt(longBarHalf.offsetHeight) : 600));
        var height = 600;
        if (longBarLeftHeight > longBarHalfHeight) { height = longBarLeftHeight; }
        else { height = longBarHalfHeight; }
        height = height < 600 ? 600 : height;
        $("#longBarHalf").css('height', height + 'px');
        var player1 = document.getElementById('player1');
        if (player1 && player1.style.display.toLocaleLowerCase() != 'none') {
            //var playerHeight = parseInt(player1.clientHeight != null && player1.clientHeight!=0 ? parseInt(player1.clientHeight) : (player1.offsetHeight != null && player1.offsetHeight!=0 ? parseInt(player1.offsetHeight) : 0));
            var imeemPlayer = document.getElementById('imeemPlayer');
            if (imeemPlayer && imeemPlayer.style.display.toLocaleLowerCase() != 'none') {
                $("#longBarLeft").css('height', (height + 125) + 'px');
            }
            else {
                var youtubePlayer = document.getElementById('youtubePlayer');
                if (youtubePlayer && youtubePlayer.style.display.toLocaleLowerCase() != 'none') {
                    $("#longBarLeft").css('height', (height + 255) + 'px');
                }
            }
        }
        else { $("#longBarLeft").css('height', height + 'px'); }
    }
}
function SetHeight()
{
//    var longBarLeft = document.getElementById('leftSideAllBoxes');
//    var longBarHalf = document.getElementById('rightSideBoxes');
//    if (longBarLeft != null && longBarHalf != null) {
//        var longBarLeftHeight = parseInt(longBarLeft.clientHeight != null && longBarLeft.clientHeight != 0 ? parseInt(longBarLeft.clientHeight) : (longBarLeft.offsetHeight != null && longBarLeft.offsetHeight != 0 ? parseInt(longBarLeft.offsetHeight) : 600));
//        var longBarHalfHeight = parseInt(longBarHalf.clientHeight != null && longBarHalf.clientHeight != 0 ? parseInt(longBarHalf.clientHeight) : (longBarHalf.offsetHeight != null && longBarHalf.offsetHeight != 0 ? parseInt(longBarHalf.offsetHeight) : 600));
//        var height = 600;
//        //alert(longBarLeftHeight + '....' + longBarHalfHeight);
//        if (longBarLeftHeight > longBarHalfHeight) { height = longBarLeftHeight; }
//        else { height = longBarHalfHeight; }
//        height = height < 600 ? 600 : height;
//       // $("#leftSideAllBoxes").css('height', height + 'px');
//       // $("#rightSideBoxes").css('height', height + 'px');

//    }
}

function SetLeftBarHeight() {
    setTimeout("SetVerticalbarheight('longBarLeft', 'leftSideAllBoxes', isDisplayingLeftMenu, 600,true);", 500);
}
function SetRightBarHeight() {
    setTimeout("SetVerticalbarheight('longBarHalf', 'rightSideBoxes', isDisplayingRightMenu, 600,true);", 500);
}
function imagMouseevent(obj, src) {
    obj.src = Theme_Img_Folder + src;
}
/*Defualt.aspx-end*/
/*tag.ascx-start*/
function View_TagPopup() {    
    $('div#divCloseTag').hide();
    $('div#divViewTag').hide();
    $('img#imgTagloader').show();
    $('div#friends').html('').hide();
    $("#txtFilterPerson").val('');    
    $('#divTagforUser').dialog("open"); 
    $('#divTagforUser').dialog('option', 'height', 410);      
}
function ViewTagPopupCallbackMapEvent(eventArgument, context) {
    if (ShowErrorMessage(eventArgument)) {
        $('div#friends').html(eventArgument).show();
        $('div#divCloseTag').show();
        $('div#divViewTag').show();
        $('img#imgTagloader').hide();
        if (document.getElementById("txtFilterPerson")) { document.getElementById("txtFilterPerson").focus(); }
        GetCurrentMediaTitle(30, 'spanTaggingMedia', 135)
    } else {HideTagPopup();}
}
function HideTagPopup() {
    $('#divTagforUser').dialog("close");
}
function FilterFriends(txtFilter) {
    Filter(txtFilter, "friends", "divTagNoresults");
}
function Filter(txtFilter, maindivID, noresultsDivID) {
    var filter = $(txtFilter).val(), count = 0;
    $("#" + maindivID + " .checkbox").each(function() {
        var Parent_Node = document.getElementById('div' + this.id);
        if (Parent_Node.parentNode.id == maindivID) {
            var name = $(this).html();
            if (name.search(new RegExp(filter, "i")) < 0) {
                $(Parent_Node).addClass("hidden").removeClass('tempClass');
            } else {
                $(Parent_Node).removeClass("hidden").addClass('tempClass');
                count++;
            }
        }
     });
/*    //debugger;
//    alert('total = '+$("#" + maindivID + " div.checkbox").length +'\n'+
//          'contains = '+  $("#" + maindivID + " div.checkbox:contains('" + filter + "')").length+'\n'+
//          'does not contain = ' + $("#" + maindivID + " div.checkbox:not(:contains('" + filter + "'))").length);

    //$("tr:not(:has(td))")
    //count = $("#" + maindivID + " div.checkbox:contains('" + filter + "')").length;
    $("#" + maindivID + " div.checkbox:contains('" + filter + "')").each(function() {
        if (this.parentNode.id == maindivID) {
            $(this).removeClass("hidden").addClass('tempClass');
            count++;
        } 
    });
    $("#" + maindivID + " div.checkbox:not(:contains('" + filter + "'))").each(function() {
        if (this.parentNode.id == maindivID) {
            $(this).addClass("hidden").removeClass('tempClass');
        }
    });*/
    if (count > 0) {
        if ($(".tempClass").length == 1) {
            $(".tempClass input").each(function() {
                if (!this.checked) {
                    this.checked = true;
                    TagCheckboxclick(this);
                }
            });
        }
        $("#" + noresultsDivID).addClass("hidden");
    } else {
        $("#" + noresultsDivID).removeClass("hidden");
    }
}

function TagCheckboxclick(checkbox) {
    ToggleCheckbox(checkbox, document.getElementById('div' + checkbox.value + '_tag'), 'friends', 'divSelectedFriends');
    FilterFriends($('#txtFilterPerson'));
}
function ToggleCheckbox(checkbox, Parent_Node, maindivID, selecteddivID) {
    if (Parent_Node != null) {
        if (checkbox.checked) {
            var divSelected = document.getElementById(selecteddivID);
            if (divSelected) {
                divSelected.appendChild(Parent_Node);
                if ($(divSelected).children.length > 0) {
                    $(divSelected).removeClass("hidden");
                }
            }
        }
        else {
            document.getElementById(maindivID).appendChild(Parent_Node);
            var divSelected = $("#" + selecteddivID);
            if (divSelected != null && divSelected.children.length <= 0) {
                divSelected.addClass("hidden");
            }
        }
    }
}
function TagforSelectedUsers() {
    var mediaID = GetCurrentMediaIDByFlowerType();
    var FacebookIDs = '';
    //var FacebookNames = '';
    $("#divSelectedFriends input:checked").each(function() {
        if (this.checked) {
            //FacebookIDs += this.value + "$$";            
            FacebookIDs += this.value + ",";
            //FacebookNames += $('#' + this.value + '_tag').html() + ',';
        }
    });
    if (jQuery.trim(FacebookIDs) == '') {
        return;
    }
    DisableButton('btnTag', 'Tagging');
    TagforUsers(flowerType, mediaID, FacebookIDs);
}
function TagforUser_Calback(eventArgument, context) {    
    if (ShowErrorMessage(eventArgument)) {
        ShowSharenotification(eventArgument);
    }
    HideTagPopup();
    EnableButton('btnTag', 'Tag');
}
function ShowSharenotification(arguments) {
    var users;
    var MediaType;
    var MediaID;
    var permaLink    
    var Invite_FacebookIDs = '';
    var Invite_FacebookNames = '';
    if (arguments.indexOf('**') > -1) {
        arguments = arguments.split('**');
        users = arguments[0];
        MediaType = arguments[1];
        MediaID = arguments[2];
        permaLink = arguments[3];
    }
    var dbUsers = Array();    
    if (users.indexOf('##') > -1) {
        users = users.split('##');
        for (s = 0; s < users.length; s++) {
            if (users[s].indexOf('$$') > -1) {
                Invite_FacebookIDs += users[s].split('$$')[0] + ",";
                Invite_FacebookNames += users[s].split('$$')[1] + ",";
            }
            else {dbUsers.push(users[s]);}
        }
    }
    else {
        if (users.indexOf('$$') > -1) {
            users = users.split('$$');
            Invite_FacebookIDs += users[0] + ",";
            Invite_FacebookNames += users[1] + ",";
            users = users[1];
        }
        else {dbUsers.push(users);}
    }
    var title = GetCurrent_MediaTitle();
    title= (title.length > 30 ? title.toString().substring(0,30)+'...' : title);
    if (dbUsers.length > 1) {
        if (flowerType == 'song') { ShowNotification("<div style='float: left; width: 100%;'><div style='float: left; text-align: center; height: 55px;'><img src='img/blue/social2.png' alt='' style='margin-left: 5px;'/></div> <div> Shared song with<br><u>" + dbUsers.length + "</u> friends </div></div>"); }
        else { ShowNotification("<div style='float: left; width: 100%;'><div style='float: left; text-align: center; height: 55px;'><img src='img/blue/social2.png' alt='' style='margin-left: 5px;'/></div> <div> Shared <u>" + title + "</u><br>with<br><u>" + dbUsers.length + "</u> friends </div></div>"); }
    }
    else if (dbUsers.length == 1) {
    if (flowerType == 'song') { ShowNotification("<div style='float: left; width: 100%;'><div style='float: left; text-align: center; height: 55px;'><img src='img/blue/social2.png' alt='' style='margin-left: 5px;'/></div> <div> Shared song with<br><u>" + dbUsers[0] + "</u></div></div>"); }
        else { ShowNotification("<div style='float: left; width: 100%;'><div style='float: left; text-align: center; height: 55px;'><img src='img/blue/social2.png' alt='' style='margin-left: 5px;'/></div> <div> Shared <u>" + title + "</u><br>with<br><u>" + dbUsers[0] + "</u> </div></div>"); }
    }
    if (Invite_FacebookIDs != '') {
        SendFacebookInvitation(Invite_FacebookIDs, Invite_FacebookNames, flowerType, permaLink, MediaID);
    }
}
//function Send_FacebookInvitation(Invite_FacebookIDs, Invite_FacebookNames, flowerType, MediaID, callbackURL) {
function Send_FacebookInvitation(Invite_FacebookIDs, Invite_FacebookNames, flowerType, permalink, MediaID, callbackURL) {
    var title = GetCurrent_MediaTitle();
    title = title.length > 30 ? title.substring(0, 30) + '...' : title;
    title = ReplaceHTMLSpecialchars(title);
    //PageMethods.GetPermalink(MediaID, flowerType, function() {
        //var permalink = arguments[0];
        Invite_FacebookIDs = (Invite_FacebookIDs.lastIndexOf(",") == Invite_FacebookIDs.length - 1) ? Invite_FacebookIDs.substring(0, Invite_FacebookIDs.length - 1) : Invite_FacebookIDs;
        Invite_FacebookNames = (Invite_FacebookNames.lastIndexOf(",") == Invite_FacebookNames.length - 1) ? Invite_FacebookNames.substring(0, Invite_FacebookNames.length - 1) : Invite_FacebookNames;
        if (flowerType == 'song') {title = "song <a href='" + permalink + "' target='_blank'>" + title + "</a>";}
        else {title = "playlist <a href='" + permalink + "' target='_blank'>" + title + "</a>";}
        if (jQuery.trim(Invite_FacebookIDs) != '') {
            callbackURL = callbackURL + "/app_Invite.aspx?close=true&facebookIDs=" + Invite_FacebookIDs + "&MediaID=" + MediaID + "&flowerType=" + flowerType;
            //callbackURL = "http://localhost:90/app_Invite.aspx?close=true&facebookIDs=" + Invite_FacebookIDs + "&MediaID=" + MediaID + "&flowerType=" + flowerType;
            var the_fbml = '<fb:request-form action="' + callbackURL + '" method="POST" invite="true" target="_self" type="Meuzer" content="Check out this ' + title + ' at Meuzer <fb:req-choice url=\'' + permalink + '\' label=\'Listen!\' />">';
            var UserText = '';
            Invite_FacebookIDs = Invite_FacebookIDs.split(',');
            Invite_FacebookNames = Invite_FacebookNames.split(',');
            for (i = 0; i < Invite_FacebookIDs.length; i++) {
                the_fbml += '<input type="hidden" fb_protected="true" name="ids[]" value="' + Invite_FacebookIDs[i] + '"/>';
            }
            if (Invite_FacebookNames.length == 1) {
                UserText = 'Are you sure you want to send an invitation to ' + Invite_FacebookNames[0] + '?<br>' +
		                'From now on, ' + Invite_FacebookNames[0] + ' can see any music you share in the "Tagged Playlist"';
            }
            else {
                UserText = 'Are you sure you want to send an invitation to ' + Invite_FacebookNames.length + ' of your friends?<br>' +
		                    'From now on, these friends can see any music you share for them in the "Tagged Playlist"';
            }
            the_fbml = '<div id="divUserText" style="color:#A2A5AA;font-size:14px;padding: 10px; display: block; text-align: center;line-height: 1.9em;">'
                        + UserText + '</div><br>' + the_fbml +
                        '<div style="width: 510px; text-align: right;">' +
                        '<fb:request-form-submit/></div></fb:request-form>';

            var dlg = new FB.UI.FBMLPopupDialog('Send Meuzer Invitation', the_fbml, true, true);
            dlg.setContentWidth(630);
            dlg.setContentHeight(120);
            dlg.set_placement(FB.UI.PopupPlacement.center);
            dlg.show();
            var tempDiv = document.createElement('div');
            tempDiv.innerHTML = '<input class="button" type="button" value="Cancel" onclick="$(\'#RES_ID_fb_pop_dialog_table\').remove()" style="height:24px"/>';
            tempDiv.className = 'popup';
            $(tempDiv).insertAfter("#fb_dialog_content");
            if (navigator.appName.indexOf('Internet Explorer') > -1) {
                $(tempDiv).css('background-color', 'transparent').css('margin-top', '-43px').css('text-align', 'right').css('padding-right', '10px');
            }
            else {
                $(tempDiv).css('background-color', 'transparent').css('margin-top', '-54px').css('text-align', 'right').css('padding-right', '10px');
            }
        }
    //});
}
/*tag.ascx-end*/
/*ShoutBox.ascx-start*/
function LoadShoutBox_Callback(eventArgument, context) {
    if (ShowErrorMessage(eventArgument)) {
        if (jQuery.trim(eventArgument) != '') {
            if (eventArgument.indexOf('##') > -1) {
                eventArgument = eventArgument.split('##');
                $("div#ShoutBoxContents").html(eventArgument[0]);                
                setLikedandDislikedCounts(parseInt(eventArgument[1]), parseInt(eventArgument[2]));
            } else {
                $("div#ShoutBoxContents").html(eventArgument);
            }
            praseFBMLData();
            var items = $("#ShoutBoxContents .item");
            if (items != null && items.length > 0) {
                $(items[0]).addClass('firstContent');
            }
        }
        else {
            //$("div#ShoutBoxContents").html("<div class='boxGenresContents'>" +"<div style='margin-left:10px;'>No Comments</div>" +"<div><a class='leftSideBoxLink' href='javascript:' onclick='ShowRatingCommentPopup()'>Make a comment</a></div>" +"</div>");
            $("div#ShoutBoxContents").html("");
        }
        $("div#divShoutComment").css('display', '');
        $('#imgShoutThumbsup').click(function() {
            ShoutboxThumbClick(1);
        });
        $('#imgShoutThumbDown').click(function() {
            ShoutboxThumbClick(-1);
        });
        animatedcollapse.show('boxShoutBoxContents');
    }
   
}
function ShowNext10Comments_Callback(eventArgument, context) {    
    if (ShowErrorMessage(eventArgument)) {
        if (eventArgument.indexOf('##') > -1) {
            eventArgument = eventArgument.split('##');
            $("div#divNext10Comments").html($("div#divNext10Comments").html() + eventArgument[0]).show();
            var lnkNext = document.getElementById('ShoutBox1_rptShoutbox_ctl05_lnkShownext');
            if (lnkNext != null) {
                var count = parseInt(eventArgument[1]);
                if (count > 0) {
                    $(lnkNext.parentNode).removeClass('hidden');
                    lnkNext.href = "javascript:ShowNext10Comments('" + eventArgument[2] + "','" + (parseInt(eventArgument[3]) + 1) + ")";
                    if (count < 10) {
                        $(lnkNext).html("Show Next " + count);
                    }
                }
                else {$(lnkNext.parentNode).addClass('hidden');}
            }
        }
        else {$("div#divNext10Comments").html(eventArgument).show();}
        praseFBMLData();
    }
}

function ShowRecentComment(flag, response) {
    if (response.indexOf('$$') > -1) {
        response = response.split('$$');
        var commentDiv = document.createElement('div');
        commentDiv.className = 'item firstContent';
        var facebookID = GetCurrentUserFacebookID();
        if (flag == "RELOAD_SHOUTBOX") {
            commentDiv.innerHTML = '<div class="shouterImage" style="float:left;min-height:40px;min-width:40px;">\
                                <a href="javascript:" class="profilepic" onclick="BrowseUserMusic(\'' + response[0] + ' ' + response[1] + '\',\'' + CURRENT_USERID + '\',\'' + facebookID + '\');">\
                                <fb:profile-pic uid="' + facebookID + '" width="40" height="40" size="square" facebook-logo=false linked="false"></fb:profile-pic></a></div>\
                                <div class="comment"></div>\
                                <div class="CommentPanel" style="padding:7px;margin-bottom:15px;width:185px;">\
                                    <div class="">\
                                       <a href="javascript:" class="link" onclick="BrowseUserMusic(\'' + response[0] + ' ' + response[1] + '\',\'' + CURRENT_USERID + '\',\'' + facebookID + '\');">' + response[0] + '</a>\
                                       <a class="link">says...</a></div>\
                                    <div class="message" style="padding-left:5px;">' + response[response.length - 1] + '</div>\
                                    <div class="cdate">' + response[2] + '<br /><div style="width:100%;text-align:right;"><a class="detail" href="#" onclick="BrowseUserMusic(\'' + response[0] + ' ' + response[1] + '\',\'' + CURRENT_USERID + '\',\'' + facebookID + '\');">View ' + response[0] + '\'s Music</a></div></div></div>';

        }
        else if (flag == "LOAD_POSITIVE_RATING") {
        commentDiv.innerHTML = '<div class="shouterImage" style="float:left;min-height:40px;min-width:40px;">\
                                <a href="javascript:" class="profilepic" onclick="BrowseUserMusic(\'' + response[0] + ' ' + response[1] + '\',\'' + CURRENT_USERID + '\',\'' + facebookID + '\');"">\
                                <fb:profile-pic uid="' + facebookID + '" width="40" height="40" size="square" facebook-logo=false linked="false"></fb:profile-pic></a></div>\
                                <div class="comment"></div>\
                                <div class="CommentPanel" style="padding:5px 5px 0px 5px;margin-bottom:15px;width:185px;">\
                                    <div class="">\
                                       <a href="javascript:" class="link" onclick="BrowseUserMusic(\'' + response[0] + ' ' + response[1] + '\',\'' + CURRENT_USERID + '\',\'' + facebookID + '\');">' + response[0] + ' </a>\
                                       <a class="link"> <img src="img/blue/thumbsup.png" style="height:19px;width:15px;vertical-align:middle;margin-left:3px;margin-right:3px;" alt=""/> liked this song</a></div>\
                                    <div class="cdate">' + response[2] + '<br /><div style="width:100%;text-align:right;"><a class="detail" href="#" onclick="BrowseUserMusic(\'' + response[0] + ' ' + response[1] + '\',\'' + CURRENT_USERID + '\',\'' + facebookID + '\');">View ' + response[0] + '\'s Music</a></div></div></div>';
        
         }
         else if (flag == "LOAD_NEGATIVE_RATING") {
         commentDiv.innerHTML = '<div class="shouterImage" style="float:left;min-height:40px;min-width:40px;">\
                                <a href="javascript:" class="profilepic" onclick="BrowseUserMusic(\'' + response[0] + ' ' + response[1] + '\',\'' + CURRENT_USERID + '\',\'' + facebookID + '\');"">\
                                <fb:profile-pic uid="' + facebookID + '" width="40" height="40" size="square" facebook-logo=false linked="false"></fb:profile-pic></a></div>\
                                <div class="comment"></div>\
                                <div class="CommentPanel" style="padding:5px 5px 0px 5px;margin-bottom:15px;width:185px;">\
                                    <div class="">\
                                       <a href="javascript:" class="link" onclick="BrowseUserMusic(\'' + response[0] + ' ' + response[1] + '\',\'' + CURRENT_USERID + '\',\'' + facebookID + '\');">' + response[0] + ' </a>\
                                       <a class="link"> <img src="img/blue/thumbsdown.png" style="height:19px;width:15px;vertical-align:middle;margin-left:3px;margin-right:3px;" alt=""/> didn\'t like this song</a></div>\
                                    <div class="cdate">' + response[2] + '<br /><div style="width:100%;text-align:right;"><a class="detail" href="#" onclick="BrowseUserMusic(\'' + response[0] + ' ' + response[1] + '\',\'' + CURRENT_USERID + '\',\'' + facebookID + '\');">View ' + response[0] + '\'s Music</a></div></div></div>';
        
         }
        var firstElement = $("#ShoutBoxContents .firstContent");
        var parentDiv = document.getElementById('ShoutBoxContents');
        if (parentDiv != null) {
            if (firstElement.length > 0) {
                firstElement = firstElement[0];
                firstElement.className = 'item';
                parentDiv.insertBefore(commentDiv, firstElement);
            }
            else {
                parentDiv.innerHTML = '';
                parentDiv.appendChild(commentDiv);
            }
        }
        praseFBMLData();
    }
    $("#ShoutBox1_txtShoutRatingComment").val('');
}

function ShoutboxThumbClick(rating) {
    RateClick(rating, null, $("#hdnCurrentPlayingID").val());
    $("#imgShoutThumbsup").unbind("click");
    $("#imgShoutThumbDown").unbind("click");
}
function setLikedandDislikedCounts(likedCount, disLikedcount) {
    if (likedCount == 1) {$("#lnkLiked").html('<span id="likedcount">1</span> person');}
    else {$("#lnkLiked").html('<span id="likedcount">' + likedCount + '</span> people');}
    if (disLikedcount == 1) {$("#lnkDisliked").html('<span id="dislikedcount">1</span> person');}
    else {$("#lnkDisliked").html('<span id="dislikedcount">' + disLikedcount + '</span> people');}
}
/*ShoutBox.ascx-end*/
function praseFBMLData() {
    if (FB != null && FB.XFBML != null && FB.XFBML.Host != null) {
        FB.XFBML.Host.parseDomTree();        
    }
}
/*TwitterSong.ascx - start*/


function Twitter_Song_Callback(eventArgument, context) {
    EnableButton('btnTweet', 'Tweet');
    if (eventArgument.indexOf('Error') > -1) {
        eventArgument = eventArgument.split('##');
        //alert(eventArgument[0]);
        if (eventArgument[0].indexOf('Invalid login credentials.') > -1) {
            document.getElementById('txtTwitterUsername').focus();
            $("#hdnTWUser").val('');
            return;
        }
        $("#hdnTWUser").val('');
    }
    else
    { $("#hdnTWUser").val("USER"); }
    $('#divTwitterSong').dialog('close');
    ShowNotification("<div style='float: left; width: 100%;'><div style='float: left; text-align: center; height: 55px;'><img src='img/blue/tweet2.png' alt='' style='margin-left: 5px;'/></div> <div> Tweeted<br>" + flowerType + "</div></div>");  //<u>"+$("#divTwitterTilte").html()+"</u>");
}
/*TwitterSong.ascx - end*/
/*EditMedia.ascx - start*/
function ShowEditMedia() {
    BindCurrentEditingMedia();
    GetEditMedia(editMediaCurrentLink.id);
    $('#divViewEditMedia').hide();
    $('#divEditMedia img.loading').css('display', '');
    $('#divEditMedia').dialog('open');
}
function GetEditMedia_Callback(eventargs, context) {
    if (ShowErrorMessage(eventargs)) {
        var NextMedia = eventargs.split('##');
        ShowEditMediaPlayer('', NextMedia[5]);
        SetEditMediaTextboxValues(NextMedia[0], NextMedia[1], NextMedia[2], NextMedia[3], NextMedia[4]);

        $("#ucEditMedia_dlGenre input:checkbox:checked").each(function() {
            this.checked = false;
        });

        $("#hdnMediaGenre").val(NextMedia[6]);

        if (NextMedia[6]) {
            var genres = NextMedia[6].split('**');
            for (x = 0; x < genres.length; x++) {
                $("#ucEditMedia_dlGenre input[id=" + genres[x] + "]:checkbox").each(function() {
                    this.checked = true;
                });
            }
        }
        $('#divEditMedia img.loading').hide();
        $('#divViewEditMedia').css('display', '');
        $('#divEditMedia').dialog('option', 'height', 950);
    }
    else {
        $('#divEditMedia').dialog('close');
    }
}
function PopulateMetadata_Callback(eventargs, context) {
    if (ShowErrorMessage(eventargs)) {
        if (eventargs == '0') {
            ShowNotification('Invalid Music Braiz ID');
            return;
        }
        else if (eventargs.indexOf('##') > -1) {
            eventargs = eventargs.split('##');
            SetEditMediaTextboxValues(eventargs[0], eventargs[1], eventargs[2], eventargs[3], eventargs[4]);
        }
    }
}
function BindCurrentEditingMedia() {
    var mbid = $('#' + returnallid()[4]).val();
    var url = $('#' + returnallid()[9]).val();
    $('#txtMBID').val(mbid);
    SetEditMediaTextboxValues($('#' + returnallid()[8]).val(), $('#' + returnallid()[2]).val(), $('#' + returnallid()[5]).val(), $('#' + returnallid()[0]).val(), $('#' + returnallid()[1]).val());
    var prentNode = editMediaCurrentLink.parentNode;
    while (prentNode != null) {
        if (prentNode.id == "divrepeater") {
            $('#divEditMediaFrom').html('from: ' + $("#spanPlaylistHeading").html());
            break;
        }
        else if (prentNode.id == "divTaggedPlaylists") {
            $('#divEditMediaFrom').html('from: Tagged Playlist');
            break;
        }
        else if (prentNode.id == "divHistoryContents") {
            $('#divEditMediaFrom').html('from: History');
            break;
        }
        else if (prentNode.id == "divMusicFeedsContents") {
            $('#divEditMediaFrom').html('from: Music feed');
            break;
        }
        else if (prentNode.id == "divMostPlayed") {
            $('#divEditMediaFrom').html('from: Most Played');
            break;
        }
        else if (prentNode.id == "divRecentlyAdded") {
            $('#divEditMediaFrom').html('from: Recently Added');
            break;
        }
        else if (prentNode.id == "divBrowse") {
            $('#divEditMediaFrom').html('from: ' + $("#boxBrowseContentHeading").html());
            break;
        }
        prentNode = prentNode.parentNode;
    }
}

function ShowEditMediaPlayer(type, url) {
    if (url.indexOf('www.youtube.com') > -1) {
        $("#EditMediaPlayer").html('<object height="200" width="360" id="player" data="' + url + '&showinfo=0" type="application/x-shockwave-flash">\
                  <param value="' + url + '&showinfo=0" name="src"/>\
                  <param value="transparent" name="wmode"/>\
                  <param value="always" name="allowscriptaccess"/>\
                  <param name="volume" value="' + volume + '" />\
                  </object>');
    }
    else {
        $("#EditMediaPlayer").html('<object width="360" height="110" id="player">\
						        <param name="movie" value="' + url + '/aus=false/"></param>\
						        <param name="wmode" value="transparent"></param>\
						        <param name="Showcontrols" value="false" />\
						        <param name="volume" value="' + volume + '" />\
						        <param name="allowscriptaccess" value="true" />\
						        <param name="allowfullscreen" value="true" />\
						        <param name="displayclick" value="fullscreen" />\
						        <param name="ShowStatusBar" value="0">\
						        <param name="FlashVars" value="backColor=32597a&primaryColor=A4A9AD&secondaryColor=193C58&linkColor=A4A9AD" />\
						        <embed src="' + url + '/aus=false/" type="application/x-shockwave-flash" width="360" height="110" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="backColor=32597a&primaryColor=A4A9AD&secondaryColor=193C58&linkColor=A4A9AD"></embed>\
						    </object>');
    }
    var player = document.getElementById('player');
}
function GetNextEditMedia() {
    if (editMediaCurrentLink.parentNode != null) {
        if (editMediaCurrentLink.parentNode.tagName.toLowerCase() == 'li') {            
            var next = editMediaCurrentLink.parentNode.nextSibling;
            while (next.tagName == null || next.tagName.toLowerCase() != 'li') {
                next = next.nextSibling
            }
            next = next.firstChild;
            while (next.tagName == null || next.tagName.toLowerCase() != 'a') {
                next = next.nextSibling
            }
            return next;
        }
        else if (editMediaCurrentLink.parentNode.parentNode != null) {
            var rowindex = editMediaCurrentLink.parentNode.parentNode.rowIndex + 1;
            var ParentTable = editMediaCurrentLink.parentNode.parentNode.parentNode;
            if (ParentTable.rows.length > rowindex) {
                var temp = $(ParentTable.rows[rowindex]).children('td').children('a');
                while (temp.length > 0 && jQuery.trim(temp[0].id) == '') {
                    rowindex = rowindex + 1;
                    if (ParentTable.rows.length > rowindex) {
                        temp = $(ParentTable.rows[rowindex]).children('td').children('a');
                    }
                    else {
                        temp = null;
                        break;
                    }
                }
                if (temp != null && temp.length > 0) {
                    return temp[0];
                }
            }
        }
    }
    return null;
}
function SetEditMediaTextboxValues(title, artist, song, album, albumArtUrl) {
    $('#txtTitle').val(title);
    $('#txtArtistName').val(artist);
    $('#txtSongName').val(song);
    $('#txtAlbum').val(album);
    $('#txtAlbumArtURL').val(albumArtUrl);
    $('#imgEditMedia').attr("src", albumArtUrl);
    GetCurrentMediaTitle(50, 'spanEditingMedia', 200, title);
}
function SaveEditMediaError_Callback(eventargs, context) {
    ShowNotification('Error occured.\n Please try again.');
    $('#divEditMedia').dialog('close');
}
function UpdateMediaLink(id, url, title, album, albumArtUrl, artist, mbid, song, source, sourceFkid) {
    var prentNode = editMediaCurrentLink.parentNode;
    while (prentNode != null) {
        if (prentNode.id == "divrepeater" || prentNode.id == "divMostPlayed"
                || prentNode.id == "divRecentlyAdded" || prentNode.id == "divHistoryContents"
                || prentNode.id == "divTaggedPlaylists" || prentNode.id == "divBrowse") {
            var ParentTD = editMediaCurrentLink.parentNode;
            var link = "<a id='" + id + "' class='playlistContent' href='javascript:'" +
                                " onclick=\"javascript:Geturlforsong('" + url + "','" + title + "','');getaddmediaparams('" + album + "','" + albumArtUrl + "','" + artist + "','" + id + "','" + mbid + "','" + song + "','" + source + "','" + sourceFkid + "','" + title + "','" + url + "');showFlower(event, 'song');\"";
            ParentTD.removeChild(editMediaCurrentLink);

            if (prentNode.id == "divHistoryContents") {
                ParentTD.innerHTML = link + "><span class='title'>" + (title.length > 50 ? title.substring(0, 50) + "..." : title) + "</span></a>" +
                                         ParentTD.innerHTML;
                setTitleWidth('divHistoryContents');
            }
            else if (prentNode.id == "divTaggedPlaylists") {
                ParentTD.innerHTML = link + " style='display:inline'><span class='title'>" + (title.length > 25 ? title.substring(0, 25) + "..." : title) + "</span></a>" +
                                         ParentTD.innerHTML;
                // setTitleWidth('divTaggedPlaylists');                    
            }
            else {
                ParentTD.innerHTML = link + "><span class='title'>" + title + "</span></a>" +
                                         ParentTD.innerHTML;
            }
            break;
        }
        else if (prentNode.id == "divMusicFeedsContents") {
            var ParentTD = editMediaCurrentLink.parentNode;
            var link = "<a id='" + id + "' style='display:inline' class='playlistContent' href='javascript:'" +
                                " onclick=\"MusicFeedMediaClick('"+album+"', '"+albumArtUrl+"', '"+artist+"', '"+id+"', '"+mbid+"', '"+song+"', '"+source+"', '"+sourceFkid+"', '"+title+"', '"+url+"',event)\">" +
                                "<span class='title'>" + (title.length > 50 ? title.substring(0, 50) + "..." : title) + "</span></a>"

            ParentTD.removeChild(editMediaCurrentLink);
            ParentTD.innerHTML = link + ParentTD.innerHTML;
            setTitleWidth('divMusicFeedsContents');
            break;
        }
        prentNode = prentNode.parentNode;
    }
}
function SaveEditMedia_Callback(eventargs, context) {
    if (ShowErrorMessage(eventargs)) {
        EnableButton('btnSaveEditMedia', 'Save'); //$('#btnSaveEditMedia').removeAttr("disabled");        
        EnableButton('btnSavenextEditMedia', 'Save & Next'); //$('#btnSavenextEditMedia').removeAttr("disabled");        
        if (eventargs.indexOf('$$') > -1) {
            eventargs = eventargs.split('$$');
            var NextMedialink = GetNextEditMedia();
            var UpdatedMedia = eventargs[0].split('##');
            UpdateMediaLink(UpdatedMedia[0], UpdatedMedia[1], UpdatedMedia[2], UpdatedMedia[3], UpdatedMedia[4], UpdatedMedia[5], UpdatedMedia[6], UpdatedMedia[7], UpdatedMedia[8], UpdatedMedia[9]);
            if (eventargs[1].toString().toLowerCase() == 'false') {
                $('#divEditMedia').dialog('close');
            }
            else if (eventargs[1].indexOf('##') > -1) {
                if (NextMedialink == null) {
                    $('#divEditMedia').dialog('close');
                    return
                }
                //check genres
                GetEditMedia_Callback(eventargs[1], null);                
                editMediaCurrentLink = NextMedialink;                
            }
        }
    } else {
        $('#divEditMedia').dialog('close');
    }
}
function SaveEditMedia(ShowNext) {
    var err_msg = '';
    if (jQuery.trim($('#txtTitle').val()) == '') {
        err_msg += 'Please enter title.\n';
        document.getElementById('txtTitle').focus();
    }
    if (err_msg != '') {
        alert(err_msg);
        return;
    }
    else {
        var NextMediaID = '';
        var CurrentMediaID = editMediaCurrentLink.id;
        if (ShowNext) {
            var nextMedia = GetNextEditMedia();
            if (nextMedia != null) {
                NextMediaID = nextMedia.id;
            }
            else {
                ShowNext = false;
            }
        }
        var genre = '';
        $("#ucEditMedia_dlGenre input:checkbox:checked").each(function() {
            if (this.checked) {
                genre += this.id + '$$';
            }
        });
        var args = "SAVE_METADATA##" +
                     CurrentMediaID + "##" +
                     $('#txtTitle').val() + "##" +
                     $('#txtArtistName').val() + "##" +
                     $('#txtAlbum').val() + "##" +
                     $('#txtSongName').val() + "##" +
                     $('#txtAlbumArtURL').val() + "##" +
                     ShowNext + "##" + NextMediaID + "##" +
                     genre + "##" + $("#hdnMediaGenre").val();

        DisableButton('btnSaveEditMedia', 'Save');    //$('#btnSaveEditMedia').attr("disabled", true);
        DisableButton('btnSavenextEditMedia', 'Save & Next');    //$('#btnSavenextEditMedia').attr("disabled", true);
        Save_EditMedia(args);
    }
}
/*EditMedia.ascx - end*/
/*Friend.ascx - Start*/
function LoadFfriends() {
    CURRENT_USERID = getCurrentUserID();
    if (CURRENT_USERID != '') {
        $('#divFacebookLogin').dialog('close'); 
        if ($("div#divFriends td.userProfile").length == 0) {
            LoadFacebookFriends(0);
        }
        HideCenterPanels('friends');
    }
    else {
        ACTION = "friends";
        $('#divFacebookLogin').dialog('open');
        $("#spanloginAction").html('to view friends on Meuzer.');
        
    }
}
function RemovefromMusicFeed_Callback(eventArgument, context) {
    EnableButton('btnRemovefromMusicFeed', 'Remove');
    $("#btnRemovefromMusicFeed").unbind("click");
    $('#divRemovefromMusiFeedPopup').dialog('close');
    ShowNotification("<div style='float: left; width: 100%;'><div style='float: left; text-align: center; height: 55px;'><img src='img/blue/minus.png' alt='' style='margin-left: 5px;'/></div> <div> Removed<br><u>" + $("#nameMusicFeedRemove").html() + "</u><br>from music feed </div></div>");
    if (ShowErrorMessage(eventArgument)) {
        LoadFacebookFriends_callback(eventArgument, context);
    }
}
function LoadFacebookFriends_callback(eventArgument, context) {
    $("div#divFriends .loading").each(function() {
        $(this.parentNode).remove();
    });
    if (ShowErrorMessage(eventArgument)) {
        if (eventArgument.indexOf('##') > -1) {
            eventArgument = eventArgument.split('##');
            var count = parseInt(eventArgument[1]);
            var currentIndex = parseInt(eventArgument[2]);
            if (currentIndex > 0) {
                $("div#divFriends").html($("div#divFriends").html() + eventArgument[0]);
            }
            else if (jQuery.trim($("div#divFriends").html()) != eventArgument[0]) {
                $("div#divFriends").html(eventArgument[0]);
            }
            else {
                return;
            }

            var lnkNext = document.getElementById('lnkShownextFriends');
            if (count > 0) {
                $(lnkNext.parentNode).removeClass('hidden');
                lnkNext.href = "javascript:LoadFacebookFriends(" + (currentIndex + 1) + ")";
                if (count < 20) {
                    $(lnkNext).html("Show Next " + count);
                }
            }
            else {
                $(lnkNext.parentNode).addClass('hidden');
            }
        }
    }
    $("div#divFriends .loading").each(function() {
        $(this).remove();
    });
    $("div#divFriends .hidden").each(function() {
        $(this).removeClass('hidden');
    });
}
function LoadRatedPeopleList_Callback(eventArgument, context) {
    if (ShowErrorMessage(eventArgument)) {
        $("#divratedUsers").html(eventArgument);
        praseFBMLData();
    }
    else {
        $("#divratedUsers").html('');
    }

}
//function FilterRatedUsers() {
//    var filter = $('#txtSearchRatedUsers').val();
//    $("#divratedUsers .ratedUser").each(function() {
//        var name = this.innerHTML;
//        var prevNode = this.parentNode.parentNode.parentNode.previousSibling;        
//        while (prevNode.tagName == null || prevNode.tagName.toLowerCase() != 'tr') {
//            prevNode = prevNode.previousSibling;
//        }
//        if (name.search(new RegExp(filter, "i")) < 0) {
//            $(this.parentNode.parentNode.parentNode).addClass('hidden');
//            $(prevNode).addClass('hidden');
//        } else {
//            $(this.parentNode.parentNode.parentNode).removeClass('hidden');
//            $(prevNode).removeClass('hidden');
//        }
//    });    
//}
/*Friend.ascx - end*/
/*UserBrowse.ascx - start*/
function BrowseUserMusic(UserName, UserID, FaceBookID) {
    //if (jQuery.trim(CURRENT_USERID) != '') {
        SelectedStyle('');
        GenreSelectedStyle(''); 
        TagSelectStyle('');
        $("#tdubProfilepic").html('');
        $("#ubStatus").html('');
        if (FB != null && FB.Facebook != null && FB.Facebook.apiClient != null) {
            FB.Facebook.apiClient.users_getInfo(FaceBookID, ['pic_square_with_logo', 'status']
            , function(uinfo, ex) {
                if (uinfo != null) {
                    $("#tdubProfilepic").html("<a href='http://www.facebook.com/profile.php?id=" + FaceBookID + "' class='FB_Link'>" +
                                    "<img style='height:50px;width:50px' class='fb_profile_pic_rendered' title='" + UserName + "' alt='" + UserName + "' src='" + uinfo[0].pic_square_with_logo + "' /></a>");
                    if(uinfo[0].status != null)                
                     $("#ubStatus").html(uinfo[0].status.message);
                }
                else {
                    $("#tdubProfilepic").html("<fb:profile-pic uid='" + FaceBookID + "' size='square' facebook-logo=false></fb:profile-pic>");
                    $("#ubStatus").html("<fb:user-status uid='" + FaceBookID + "' linked='false'></fb:user-status>");
                    praseFBMLData();
                }
            });
        }
        $("#btnubPlaylists").removeClass('fselected');
        $("#btnubHistory").removeClass('fselected');
        $("#btnubMostplayed").removeClass('fselected');
        $("#hdbUBID").val(UserID);
        $("#tdUserBrowseName").html(UserName);
        $("#divUserPofile").show();
        HideCenterPanels('userbrowse');
        BindFriendsPlaylists(UserID);        
    //}
}
function BrowseUserMusic_Callback(eventArgument, context) {
    if (ShowErrorMessage(eventArgument)) {
        if (eventArgument.indexOf('##') > -1) {
            eventArgument = eventArgument.split('##');
            if (eventArgument[0].toLowerCase() == 'true') {
                $("#divFeedExclude").show();
                $("a#lnkFeedExclude").html("+ Add to Music Feed");
                //document.getElementById('lnkFeedExclude').href = 'javascript:setUserFeedExclude(false,"' + eventArgument[2] + '")';
                document.getElementById('lnkFeedExclude').href = 'javascript:ShowAddToMusicFeedPopup("' + eventArgument[4] + '","' + eventArgument[2] + '","' + eventArgument[3] + '" , "\'\'")';
            }
            else if (eventArgument[0].toLowerCase() == 'false') {
                $("#divFeedExclude").show();
                $("a#lnkFeedExclude").html("- Remove from Music Feed");
                //document.getElementById('lnkFeedExclude').href = 'javascript:setUserFeedExclude(true,"' + eventArgument[2] + '")';
                document.getElementById('lnkFeedExclude').href = 'javascript:ShowRemovefromMusicFeedPopup("' + eventArgument[4] + '","' + eventArgument[2] + '","' + eventArgument[3] + '" , "\'\'")';
            }
            else {
                $("#divFeedExclude").hide();
                $("a#lnkFeedExclude").html("");
            }
            if (jQuery.trim(eventArgument[1]) != '') { $("div#divUserBrowsePlaylists").html(eventArgument[1]); }
            else {
                var firstname = $("#tdUserBrowseName").html();
                firstname = (firstname.indexOf(' ') > -1 ? firstname.substring(0, firstname.indexOf(' ')) : firstname);                
                $("div#divUserBrowsePlaylists").html('<div class="text14 noPlaylists">' + firstname + ' has not created any playlists</div>'); 
            }

            $('#boxBrowseContents').css('display', browseBoxDisplay);

                        
            $("#divUserBrowsePlaylists .playlistContent").each(function() {
                animatedcollapse.addDiv(this.id, 'fade=1, hide=true');
            });
            animatedcollapse.init();
            //animatedcollapse.show('boxPlaylistsContents');
            var shoutboxBoxDisplay = document.getElementById("boxShoutBoxContents").style.display;
            var AdminBoxDisplay = document.getElementById("boxAdministrationContent").style.display;
            var PlaylistBoxDisplay = document.getElementById("boxPlaylistsContents").style.display;
            var browseBoxDisplay = document.getElementById('boxBrowseContents').style.display;
            
            //alert(shoutboxBoxDisplay)  
//            if (shoutboxBoxDisplay == 'none') {
//                animatedcollapse.hide('boxShoutBoxContents');
//            }
//            else {
//                animatedcollapse.show('boxShoutBoxContents');
//            }
            
            if (AdminBoxDisplay == 'none') {
                animatedcollapse.hide('boxAdministrationContent');
            }
            else { animatedcollapse.show('boxAdministrationContent'); }
            
//            if (PlaylistBoxDisplay == 'none') {
//               animatedcollapse.hide('boxPlaylistsContents');
//            }
//            else {
//                 
//                }
           
        }
        else {
            $("div#divUserBrowsePlaylists").html('');
        }
    }
    else {
        $("div#divUserBrowsePlaylists").html('');
    }
}
function UserBrowseLoadPlaylist_Callback(eventArgument, context) {
    if (ShowErrorMessage(eventArgument)) {
        if (eventArgument.indexOf('##') > -1) {
            eventArgument = eventArgument.split('##');
            if (jQuery.trim(eventArgument[0]) != '') {
                $("div#" + eventArgument[1]).html(eventArgument[0]);
                var table = $("div#" + eventArgument[1] + " table");
                if (table != null && table.length > 0) {
                    table = table[0];
                    if (table.rows.length > 0) {
                        $(table.rows[0].cells[0]).addClass('firstContent');
                        $(table.rows[table.rows.length - 1].cells[0]).addClass('lastContent');
                    }
                }
                //InitDragable(eventArgument[1],false);    
            }
            else {$("div#" + eventArgument[1]).html(BlankPlaylist);}
        }
    }
    else {
        $("div#divUserBrowsePlaylists .loading").each(function() {
            $(this).remove();
        });
    }
}
function setUserFeedExclude_Callback(eventArgument, context) {
    if (ShowErrorMessage(eventArgument)) {
        if (eventArgument.indexOf('##') > -1) {
            eventArgument = eventArgument.split('##');
            var link = document.getElementById('lnkFeedExclude');
            if (link != null) {
                //link.href = 'javascript:setUserFeedExclude("' + eventArgument[0] + '","' + eventArgument[1] + '",null);';
                var userName = $("#tdUserBrowseName").html(); //$('#divUserPofile .FB_Link')[1].innerHTML;
                if (eventArgument[0] == "True") {
                    EnableButton('btnAddtoMusicFeed', 'Add');
                    $("#btnAddtoMusicFeed").unbind("click");
                    $('#divAddToMusicFeedPopup').dialog('close');
                    link.href = 'javascript:ShowRemovefromMusicFeedPopup("' + eventArgument[2] + '","' + eventArgument[1] + '","' + eventArgument[3] + '" , "\'\'")';
                    link.innerHTML = '- Remove from Music Feed';
                    ShowNotification("<div style='float: left; width: 100%;'><div style='float: left; text-align: center; height: 55px;'><img src='img/blue/social2.png' alt='' style='margin-left: 5px;'/></div> <div> Added<br><u>" + userName + "</u><br>to music feed </div></div>");
                }
                else {
                    EnableButton('btnRemovefromMusicFeed', 'Remove');
                    $("#btnRemovefromMusicFeed").unbind("click");
                    $('#divRemovefromMusiFeedPopup').dialog('close');
                    link.href = 'javascript:ShowAddToMusicFeedPopup("' + eventArgument[2] + '","' + eventArgument[1] + '","' + eventArgument[3] + '" , "\'\'")';
                    link.innerHTML = '+ Add to Music Feed';
                    ShowNotification("<div style='float: left; width: 100%;'><div style='float: left; text-align: center; height: 55px;'><img src='img/blue/minus.png' alt='' style='margin-left: 5px;'/></div> <div> Removed<br><u>" + userName + "</u><br>from music feed </div></div>");
                }
            }
        }
    }
}
function UserBrowseLoadPlaylist_Callback(eventArgument, context) {
    if (ShowErrorMessage(eventArgument)) {
        if (eventArgument.indexOf('##') > -1) {
            eventArgument = eventArgument.split('##');
            if (jQuery.trim(eventArgument[0]) != '') {
                $("div#" + eventArgument[1]).html(eventArgument[0]);
                var table = $("div#" + eventArgument[1] + " table");
                if (table != null && table.length > 0) {
                    table = table[0];
                    if (table.rows.length > 0) {
                        $(table.rows[0].cells[0]).addClass('firstContent');
                        $(table.rows[table.rows.length - 1].cells[0]).addClass('lastContent');
                    }
                }
                //InitDragable(eventArgument[1],false);    
            }
            else {$("div#" + eventArgument[1]).html(BlankPlaylist);}
        }
    }
    else {
        $("div#divUserBrowsePlaylists .loading").each(function() {
            $(this).remove();
        });
    }
}
/*UserBrowse.ascx - end*/
/*History.ascx - start*/
function LoadPlayHistory_Callback(eventArgument, context) {
    $("div#divHistoryContents .loading").each(function() {
        $(this.parentNode).remove();
    });
    if (ShowErrorMessage(eventArgument)) {
        ShowNextSongsorPlaylists('divHistoryContents', 'lnkShownextHistory', 20, eventArgument,
                            'ShowNext20PlayHistory', 'divHistoryContents');

        var firstTable = $("#divHistoryContents table:first");
        var SencondTable = null;
        var tables = $("#divHistoryContents table");
        if (tables.length > 0 && firstTable.length > 0) {
            firstTable = firstTable[0];
            for (x = 0; x < tables.length; x++) {
                if (tables[x] != firstTable) {
                    while (tables[x].rows.length > 0) {
                        firstTable.rows[firstTable.rows.length - 1].parentNode.appendChild(tables[x].rows[0]);
                    }
                    if (tables[x].rows.length == 0) {
                        $(tables[x]).remove();
                    }
                }
            }
        }
    }
    
    //InitDragable('divHistoryContents', false);
}
/*History.ascx - end*/
/*MostPlayed.ascx - start*/
function MostPlayed_Callback(shownextfunction, eventArgument) {
    $("div#divMostPlayed .loading").each(function() {
        $(this.parentNode).remove();
    });
    if (ShowErrorMessage(eventArgument)) {
        ShowNextSongsorPlaylists('divMostPlayed', 'lnkShownextMostPlayed', 20, eventArgument,
                            shownextfunction, 'divMostPlayed');
    }
}
function LoadMostPlayed_Callback(eventArgument, context) {
    MostPlayed_Callback('LoadMostPlayed', eventArgument);
}
function LoadFriendsMostPlayed_Callback(eventArgument, context) {
    MostPlayed_Callback('LoadFriendsMostPlayed', eventArgument);
}
/*MostPlayed.ascx - end*/
/*MusicFeeds.ascx - start*/
function LoadMusicFeeds_Callback(eventArgument, context) {
    if (ShowErrorMessage(eventArgument)) {
        if (jQuery.trim(eventArgument) != '') {
            $("div#divMusicFeedsContents").html(eventArgument);
            setTitleWidth('divMusicFeedsContents');
        }
        else {
            $("div#divMusicFeedsContents").html("<div style='margin-left:150px;' class='NoContentMsg'>No Music Feeds</div>");
        }
    }
    else { $("div#divMusicFeedsContents").html(''); }
    praseFBMLData();
    //InitDragable('divMusicFeedsContents', false, 'drag');
}
function MusicFeedPlaylistclick(PlaylistID) {
    bindplaylistidtohf(PlaylistID);
    loadplaylist('JustShowPlaylist');
}
function MusicFeedMediaClick(album, albumArtUrl, artist, id, mbid, song, source, sourceFkid, title, url,event) {
    Geturlforsong(url, title, '');
    getaddmediaparams(album, albumArtUrl, artist, id, mbid, song, source, sourceFkid, title, url);
    showFlower(event, 'song');
}
function setTitleWidth(divID) {
//    $("#" + divID + " td").each(function() {
//        var height = parseInt(this.clientHeight != null ? parseInt(this.clientHeight) : 0);
//        if (height == 0) {
//            height = (this.offsetHeight != null ? parseInt(this.offsetHeight) : 0);
//        }
//        var span = jQuery(this).children().children('.title');
//        if (span != null && span.length > 0) {
//            span = span[0];
//            var spanTitle = span.innerHTML;
//            var OriginalTitle = spanTitle;
//            //remove '...'
//            if (parseInt(height) > 25) { spanTitle = spanTitle.substring(0, spanTitle.length - 3); }
//            while (parseInt(height) > 25) {
//                spanTitle = spanTitle.substring(0, spanTitle.length - 1);
//                span.innerHTML = spanTitle + '...';
//                height = parseInt(this.clientHeight != null ? parseInt(this.clientHeight) : 0);
//                if (height == 0) {
//                    height = (this.offsetHeight != null ? parseInt(this.offsetHeight) : 0);
//                }
//            }
//            if (OriginalTitle.length > spanTitle.length)
//                spanTitle += '...'
//            span.innerHTML = spanTitle;
//        }
//    });
}
function ShowNext20MusicFeeds_callback(eventArgument, context) {
    $("div#divNext20Musicfeeds .loading").each(function() {
        $(this.parentNode).remove();
    });
    if (ShowErrorMessage(eventArgument)) {
        ShowNextSongsorPlaylists('divNext20Musicfeeds', 'ucMusicFeeds_rptMusicFeeds_ctl16_lnkShownext',
                                20, eventArgument, 'ShowNext20MusicFeeds', 'divNext20Musicfeeds');
    }
    praseFBMLData();
    //InitDragable('divNext20Musicfeeds', false, 'drag');
}
/*MusicFeeds.ascx - end*/
/*TaggedPlaylists.ascx - start*/
function LoadTaggedPlaylists_Callback(eventArgument, context) {
    if (ShowErrorMessage(eventArgument)) {
        if (jQuery.trim(eventArgument) != '') {
            $("div#divTaggedPlaylists").html(eventArgument);
        }
        else {
            $("div#divTaggedPlaylists").html(notags_msg);
        }
    }
    else {
        $("div#divTaggedPlaylists .loading").each(function() {
            $(this).remove();
        });
    }
    InitDragable('tblTaggedSongs', false);
}
function ShowNext20Songs_callback(eventArgument, context) {
    if (ShowErrorMessage(eventArgument)) {
        ShowNextSongsorPlaylists('divNext20Songs', 'ucTaggedPlaylists_rptTaggedSongs_ctl16_lnkShownext',
                                20, eventArgument, 'ShowNext20Songs', 'divTaggedPlaylists');
    }
    else {
        $("div#divNext20Songs .loading").each(function() {
            $(this.parentNode).remove();
        });
    }
    InitDragable('divNext20Songs', false);
}
function ShowNext10playlists_callback(eventArgument, context) {
    if (ShowErrorMessage(eventArgument)) {
        ShowNextSongsorPlaylists('divNext10Playlists', 'ucTaggedPlaylists_rptTaggedPlaylists_ctl06_lnkShownext',
                                10, eventArgument, 'ShowNext10playlists', 'divTaggedPlaylists');
    }
    else {
        $("div#divNext10Playlists .loading").each(function() {
            $(this.parentNode).remove();
        });
    }
}
function ShowNextSongsorPlaylists(divID, linkID, maxCount, eventArgument, NextFunctionName, parentDivID) {
    $("div#" + divID + " .loading").each(function() {
        $(this.parentNode).remove();
    });
    if (eventArgument.indexOf('##') > -1) {
        eventArgument = eventArgument.split('##');
        var count = parseInt(eventArgument[1]);
        var currentIndex = parseInt(eventArgument[2]);
        if (currentIndex > 0) {
            $("div#" + divID).html($("div#" + divID).html() + eventArgument[0]);
        }
        else {
            $("div#" + divID).html(eventArgument[0]);
        }
        var lnkNext = document.getElementById(linkID);
        if (count > 0) {
            $(lnkNext.parentNode).removeClass('hidden');
            lnkNext.href = "javascript:" + NextFunctionName + "(" + (currentIndex + 1) + ")";
            if (count < maxCount) {
                $(lnkNext).html("Show Next " + count);
            } else { $(lnkNext).html("Show Next 20"); }
        }
        else {
            $(lnkNext.parentNode).addClass('hidden');
        }
    }
    setTitleWidth(parentDivID);
}
function loadTaggedPlaylist(event) {
    showFlower(event, 'TaggedPlaylist');
}
function HideShowNextLink(linkID) {
    if (document.getElementById(linkID) != null) {
        $("#" + linkID).parent().addClass('hidden');
    }
}
/*TaggedPlaylists.ascx - end*/
/*AddPlaylist.ascx - start*/
function FilterPlaylist(txtFilter) {
    Filter(txtFilter, "playlist", "divNoresults");
}
function Checkboxclick(chkPlaylist) {
    ToggleCheckbox(chkPlaylist, document.getElementById('div' + chkPlaylist.value + '_add'), 'playlist', 'divSelected');
    FilterPlaylist(document.getElementById('txtFilter'));
}
function AddPlaylistCallback(eventArgument, context) {
    var isError = false;
    var playlistHTML = '';
    var PlaylistNames = Array();
    if (eventArgument.indexOf('##') > -1) {
        eventArgument = eventArgument.split('##');
        playlistHTML = eventArgument[0];
        //update center playlist
        if (jQuery.trim(eventArgument[1]) != '') {
            if (ShowErrorMessage(eventArgument[1])) {
                document.getElementById('divrepeater').innerHTML = eventArgument[1];
            }
            else {
                isError = true;
            }
        }
    }
    else {
        playlistHTML = eventArgument;
    }
    //update right panel
    if (jQuery.trim(playlistHTML) != '') {
        if (ShowErrorMessage(playlistHTML)) {
            PlaylistNames[PlaylistNames.length] = jQuery.trim($('#txtNewPlaylist').val());
            RefreshPlaylist(playlistHTML);
        }
        else {
            isError = true;
        }
    }
    if (!isError) {
        $("#divSelected input:checked").each(function() {
            if (this.checked) {
                $("#" + this.value + "_add").each(function() {
                    PlaylistNames[PlaylistNames.length] = this.innerHTML;
                }
                );
            }
        });
        if (PlaylistNames.length == 1) {
            ShowNotification("<div style='float: left; width: 100%;'><div style='float: left; text-align: center; height: 55px;'><img src='img/blue/plus.png' alt='' style='margin-left: 5px;'/></div> <div> Added song<br>to playlist </div></div>");
        }
        else if (PlaylistNames.length > 1) {
        ShowNotification("<div style='float: left; width: 100%;'><div style='float: left; text-align: center; height: 55px;'><img src='img/blue/plus.png' alt='' style='margin-left: 5px;'/></div> <div> Added song<br>to <u>" + PlaylistNames.length + "</u> playlists </div></div>");
        }
    }
    EnableButton('btnAdd', 'Add');
    HideAddNewPlaylist();
}
function AddNewPlayListClick_Callback(eventArgument, context) {
    if (ShowErrorMessage(eventArgument)) {
        if (jQuery.trim(eventArgument) != '') {
            RefreshPlaylist(eventArgument);
        }
        var PlaylistName = jQuery.trim($("#txtNewPlaylistName").val())
        PlaylistName = PlaylistName.length > 12 ? PlaylistName.substring(0, 12) + '...' : PlaylistName;
        ShowNotification("<div style='float: left; width: 100%;'><div style='float: left; text-align: center; height: 55px;'><img src='img/blue/plus.png' alt='' style='margin-left: 5px;'/></div> <div> Created playlist<br><u>" + PlaylistName + "</u></div></div>");
    }
    $('#divAddNewPlayList').dialog('close');
    EnableButton('btnAddnewPlaylist', 'Add');
}
function AddMediaToSelectedPlaylists() {
    DisableButton('btnAdd', 'Add');
    var PlaylistIDs = '';
    CenterPlaylistID = jQuery.trim(CenterPlaylistID);
    var centerPlaylist = '';
    $("#divSelected input:checked").each(function() {
        if (this.checked) {
            PlaylistIDs += this.value + "$$";
            if (jQuery.trim(this.value) == CenterPlaylistID) {
                centerPlaylist = this.value;
            }
        }
    });
    if (jQuery.trim(PlaylistIDs) == '') {
        EnableButton('btnAdd', 'Add');
        return '';
    }
    var mediaID = GetCurrentMediaIDByFlowerType();
    var NewPlaylistname = ''; // = jQuery.trim($('#txtNewPlaylist').val());        
    return NewPlaylistname + '##' + mediaID + '##' + PlaylistIDs + "##" + centerPlaylist + "##" + flowerType;
}
/*AddPlaylist.ascx - end*/