﻿


function manageSiteFavoriteClick(siteID, isEvent, isClub, isSpot, isMini, hIsAdd, addToFavoriteImg, addToFavoriteText, boxText, addToFavoriteDiv) {

       
    var param = '{"siteID":"' + siteID + '"}';

    if ($('#' + hIsAdd).val() == 'true') {

        $.ajax({
            type: "POST",
            url: "/WebServices/SportTribeWebService.asmx/AddSiteToFavorite",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: param,
            //processData: false,
            error: function(xhr, message) { },
            success: function(json) {

                if (isMini) {
                    $("#" + addToFavoriteImg).attr("src", "/images/gfx/button/mini_favorite_del.gif");
                    $("#" + addToFavoriteText).html(ResourceManager.GetString("favorite_miniDelFavorite"));
                }
                else {
                    $("#" + addToFavoriteImg).attr("src", "/images/gfx/button/pop_bookmark_remove.jpg");

                    if (isEvent) {
                        $("#" + addToFavoriteImg).attr("alt", ResourceManager.GetString("favorite_DeleteEvent"));
                        $("#" + addToFavoriteText).html(ResourceManager.GetString("favorite_DeleteEvent"));
                    }
                    else if (isClub) {
                        $("#" + addToFavoriteImg).attr("alt", ResourceManager.GetString("favorite_DeleteClub"));
                        $("#" + addToFavoriteText).html(ResourceManager.GetString("favorite_DeleteClub"));
                    }
                    else if (isSpot) {
                        $("#" + addToFavoriteImg).attr("alt", ResourceManager.GetString("favorite_DeleteSpot"));
                        $("#" + addToFavoriteText).html(ResourceManager.GetString("favorite_DeleteSpot"));
                    }
                }

                if (isEvent) {
                    $("#" + boxText).html(ResourceManager.GetString("favorite_DeleteEvent"));
                    closeMessage(addToFavoriteDiv);
                    showUserMessage(ResourceManager.GetString("favorite_AddEventOK"));
                }
                else if (isClub) {
                    $("#" + boxText).html(ResourceManager.GetString("favorite_DeleteClub"));
                    closeMessage(addToFavoriteDiv);
                    showUserMessage(ResourceManager.GetString("favorite_AddClubOK"));
                }
                else if (isSpot) {
                    $("#" + boxText).html(ResourceManager.GetString("favorite_DeleteSpot"));
                    closeMessage(addToFavoriteDiv);
                    showUserMessage(ResourceManager.GetString("favorite_AddSpotOK"));
                }

                $('#' + hIsAdd).val('false')
            }
        });

    }
    else {

        $.ajax({
            type: "POST",
            url: "/WebServices/SportTribeWebService.asmx/DeleteSiteToFavorite",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: param,
            //processData: false,
            error: function(xhr, message) { },
            success: function(json) {

            if (isEvent) {
                    if (isMini) {
                        $("#" + addToFavoriteImg).attr("src", "/images/gfx/button/mini_favorite.gif");
                        $("#" + addToFavoriteText).html(ResourceManager.GetString("favorite_miniAddFavorite"));
                    }
                    else {
                        $("#" + addToFavoriteImg).attr("src", "/images/gfx/button/pop_bookmark_event.jpg");
                        $("#" + addToFavoriteText).html(ResourceManager.GetString("favorite_AddEvent"));
                    }                                 
                    $("#" + boxText).html(ResourceManager.GetString("siteDetails_AddParticipant"));

                    closeMessage(addToFavoriteDiv);
                    showUserMessage(ResourceManager.GetString("favorite_DeleteEventOK"));
                }
                else if (isClub) {
                    if (isMini) {
                        $("#" + addToFavoriteImg).attr("src", "/images/gfx/button/mini_favorite.gif");
                        $("#" + addToFavoriteText).html(ResourceManager.GetString("favorite_miniAddFavorite"));
                    }
                    else {
                        $("#" + addToFavoriteImg).attr("src", "/images/gfx/button/pop_bookmark_club.jpg");
                        $("#" + addToFavoriteText).html(ResourceManager.GetString("favorite_AddClub"));
                    }                   
                    $("#" + boxText).html(ResourceManager.GetString("favorite_AddClub"));

                    closeMessage(addToFavoriteDiv);
                    showUserMessage(ResourceManager.GetString("favorite_DeleteClubOK"));
                }
                else if (isSpot) {
                    if (isMini) {
                        $("#" + addToFavoriteImg).attr("src", "/images/gfx/button/mini_favorite.gif");
                        $("#" + addToFavoriteText).html(ResourceManager.GetString("favorite_miniAddFavorite"));
                    }
                    else {
                        $("#" + addToFavoriteImg).attr("src", "/images/gfx/button/pop_bookmark_spot.jpg");
                        $("#" + addToFavoriteText).html(ResourceManager.GetString("favorite_AddClub"));
                    }                  
                    $("#" + boxText).html(ResourceManager.GetString("favorite_AddSpot"));

                    closeMessage(addToFavoriteDiv);
                    showUserMessage(ResourceManager.GetString("favorite_DeleteSpotOK"));
                }
                $('#' + hIsAdd).val('true');
            }
        });

    }

}


function manageUserFavoriteClick(friendID, isMini, hIsAdd, imgAddToFavorite, linkAddToFavorite, boxText, addToFavoriteDiv, miniAddToFavoriteText) {


    var param = '{"friendID":"' + friendID + '"}';

    if ($('#' + hIsAdd).val() == 'true') {

        $.ajax({
            type: "POST",
            url: "/WebServices/SportTribeWebService.asmx/AddUserToFavorite",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: param,
            //processData: false,
            error: function(xhr, message) { },
            success: function(json) {

                if (isMini) {
                    $("#" + imgAddToFavorite).attr("src", "/images/gfx/button/mini_favorite_del.gif");
                    $("#" + miniAddToFavoriteText).html(ResourceManager.GetString("favorite_miniFriendDelFavorite"));
                }
                else {
                    $("#" + imgAddToFavorite).attr("src", "/images/gfx/button/pop_bookmark_remove.jpg");
                }

                $("#" + imgAddToFavorite).attr("alt", ResourceManager.GetString("favorite_DeleteFriend"));
                $("#" + linkAddToFavorite).attr("title", ResourceManager.GetString("favorite_DeleteFriend"));
                $("#" + boxText).html(ResourceManager.GetString("favorite_DeleteFriend"));
                closeMessage(addToFavoriteDiv);
                showUserMessage(ResourceManager.GetString("favorite_AddFriendOK"));
                
                $('#' + hIsAdd).val('false')
            }
        });

    }
    else {

        $.ajax({
            type: "POST",
            url: "/WebServices/SportTribeWebService.asmx/DeleteUserToFavorite",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: param,
            //processData: false,
            error: function(xhr, message) { },
            success: function(json) {
            
                if (isMini) {
                    $("#" + imgAddToFavorite).attr("src", "/images/gfx/button/mini_favorite.gif");
                    $("#" + miniAddToFavoriteText).html(ResourceManager.GetString("favorite_miniFriendAddFavorite"));
                }
                else {
                    $("#" + imgAddToFavorite).attr("src", "/images/gfx/button/pop_bookmark_member.jpg");
                }
                $("#" + imgAddToFavorite).attr("alt", ResourceManager.GetString("favorite_AddFriend"));
                $("#" + linkAddToFavorite).attr("title", ResourceManager.GetString("favorite_AddFriend"));
                $("#" + boxText).html(ResourceManager.GetString("favorite_AddFriend"));

                closeMessage(addToFavoriteDiv);
                showUserMessage(ResourceManager.GetString("favorite_DeleteFriendOK"));
           
                $('#' + hIsAdd).val('true');
            }
        });

    }

}