﻿
function UpdateComments(sourceId, userId, userName, userEmail)
{
    var commentText = document.getElementById("user_comment").value;
    UserContentMonitorWebSvc.AddNewComment(sourceId, 1, userId, commentText, userName, userEmail,BuildCommentsHtml );
}

function BuildCommentsHtml(commentsList)
{
    document.getElementById("comment-list").innerHTML = commentsList;
    document.getElementById("user_comment").value="";
}

function AddToFavorites(sourceId, thisUser)
{
    if (thisUser>0)
    {
        UserContentMonitorWebSvc.AddToFavorites(sourceId,  1,  thisUser, FavoriteAdded)
    }
    else
    {
        window.alert ("You must be logged in to add this photo to your favorites");
    }
}

function FavoriteAdded(atlasResponse)
{
    if (atlasResponse>0)
    {
        window.alert("This photo has been added to your Favorites list");
    }
    else
    {
        window.alert("You have already added this photo to your Favorites list");
    }
}

function FlagInappropriate(sourceId, thisUser)
{
   
    if (thisUser>0)
    {
        UserContentMonitorWebSvc.FlagContent(sourceId, 1, thisUser, "Content Inappropriate", ItemFlagged);
    }
    else
    {
        window.alert ("You must be logged in to flag this photo as inappropriate");
    }
}

function ItemFlagged(atlasResponse)
{
    window.alert("You have flagged this photo as inappropriate. WeatherBug will review and take any appropriate action");
}

function SubscribeToUser(subscribedToUserId, thisUser)
{
    var userEmail = document.getElementById("wXpd-neighbor-email").value;
    if ((userEmail != null) && (userEmail != ""))
    {
        UserContentMonitorWebSvc.SubscribeToUser(userEmail, thisUser, subscribedToUserId, 1);
    }
    else
    {
        window.alert("Please Enter Your Email Address");
    } 
}

function Subscribed(atlasResponse)
{
    window.alert("Thank you for subscribing!");
}

function UpdateRank(sourceId, ratedBy, ratingValue)
{
    UserContentMonitorWebSvc.AddRank(sourceId, 1, ratingValue, ratedBy, BuildRankHtml(ratingValue,sourceId));
}

function BuildRankHtml(ratingValue,sourceId)
{
    document.getElementById("rating-value" + sourceId).className = "current-rating-" + ratingValue + "-0";
}
function UpdateShareCount (sourceId)
{
    UserContentMonitorWebSvc.AddUserShare(sourceId, 1, ShareCountUpdated);
}

function ShareCountUpdated(atlasResponse)
{
    return atlasResponse;
}
