﻿// JScript File

//Hide Show
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}

function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") 
{ document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none";}
}

//Web Services Voting
function IncrementView(MediaID)
{   
  UtilWebService.IncrementMediaView(MediaID);
}

// Web Services SocialBookmarking
var SocialBookmarkID;

function OnSocialBookmarksComplete(result, eventArgs)
{
  var res = document.getElementById(SocialBookmarkID);
  res.innerHTML = "";
  res.innerHTML = result;
}

function SocialBookmarks(MediaID)
{   
    SocialBookmarkID = "More" + MediaID;
    UtilWebService.SocialBookmarks(MediaID, OnSocialBookmarksComplete);
}

//Web Services Error Handling
function OnError(results)
{
  //alert("Error: " + results.get_message());
}

//Web Services SaveMedia

function ControlValues (ControlID, Value)
{
    this.ControlID = ControlID;
    this.Value = Value;
}

function SaveCareerServices(Params)
{   
    //split the Params which are comma delimited
    var params_array = Params.split(",");
    var MediaGuidString;
    var ControlValues_array = new Array(params_array.length);
    
    for (var counter = 0; counter < params_array.length; counter++)
    {
        if (counter == 0) //this is the MediaGuidString
        {
            MediaGuidString = params_array[counter];
        }
        else //these are the individual control ids associated with the MediaGuidString
        {
            var res = document.getElementById(params_array[counter]);
            ControlValues_array[counter] = new ControlValues(params_array[counter], res.value);
        }
    }
    
    UtilWebService.SaveCareerServices(MediaGuidString, ControlValues_array);
    ReverseContentDisplay("NewBookmark" + MediaGuidString);
}

function DeleteCareerServices(MediaGuidString)
{
   UtilWebService.DeleteUserMedia(MediaGuidString);
   ReverseContentDisplay("NewBookmark" + MediaGuidString);
   ReverseContentDisplay("MoreNewBookmark" + MediaGuidString);
}

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();