

function UpdateComments(sourceId, userId, userName, userEmail)
{
    var commentText = document.getElementById("user_comment").value;
    UserContentMonitorWebSvc.AddNewComment(sourceId, 2, userId, commentText, userName, userEmail,BuildCommentsHtml );
}

function BuildCommentsHtml(commentsList)
{
    document.getElementById("comment-list").innerHTML = commentsList;
    document.getElementById("user_comment").value="";
}

function CreateBlankYouCastVideo(thisUser)
{
    
    if (thisUser > 0)
    {
         UserContentMonitorWebSvc.CreateBlankYouCastVideo(thisUser, YouCastCreated, ErrorOccurred, ErrorOccurred);
    }
    else
    {
        window.alert("You must be logged in to create a YouCast Video");
        location.href=loginRedirect;
    }
}

function ErrorOccurred(atlasResponse)
{
    window.alert(atlasResponse);
}

function YouCastCreated(atlasResponse)
{
    var nowDate = new Date();
    var t = Date.UTC(nowDate.getUTCFullYear(), nowDate.getUTCMonth(), nowDate.getUTCDate(), nowDate.getUTCHours(), nowDate.getUTCMinutes(), nowDate.getUTCSeconds());
    if (userId == "-1")
    {
        userId = "";
    }
     
    if (atlasResponse > 0)
    {
        window.open(ycUrl + "?userid=" + userId + "&clipid=" + atlasResponse + "&t=" + t + "&zipcode=" + zipcode);
        
    }
    else
    {
        window.alert("Error Occurred Initializing YouCaster...Please Try Again Later");
    }
}

function AddToFavorites(sourceId, thisUser)
{
    if (thisUser>0)
    {
        UserContentMonitorWebSvc.AddToFavorites(sourceId, 2,  thisUser, FavoriteAdded)
    }
    else
    {
        window.alert ("You must be logged in to add this video to your favorites");
    }
    return false;
}

function FavoriteAdded(atlasResponse)
{
    if (atlasResponse>0)
    {
        window.alert("This video has been added to your Favorites list");
    }
    else
    {
        window.alert("You have already added this video to your Favorites list");
    }
}

function FlagInappropriate(sourceId, thisUser)
{
    if (thisUser>0)
    {
        UserContentMonitorWebSvc.FlagContent(sourceId, 2, thisUser, "Content Inappropriate", ItemFlagged);
    }
    else
    {
        window.alert ("You must be logged in to flag this video.");
    }
    return false;
}
function ItemFlagged(atlasResponse)
{
    window.alert("You have flagged this video 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, 2);
    }
    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, 2, ratingValue, ratedBy, BuildRankHtml);
}

function BuildRankHtml(ratingValue)
{
    document.getElementById("rating-value").className = "current-rating-" + ratingValue + "-0";
}

function UpdateShareCount (sourceId)
{
    UserContentMonitorWebSvc.AddUserShare(sourceId, 2);
}

function ShareCountUpdated(atlasResponse)
{
    return atlasResponse;
}