﻿/*
    Add to favorites
*/

function addFavorite(mediaID)
{
    var req;
    if (window.XMLHttpRequest)
        req = new XMLHttpRequest();
    else if (window.ActiveXObject) 
        req = new ActiveXObject("Microsoft.XMLHTTP");    
        
    req.onreadystatechange = function()
    {                    
        if (req.readyState == 4 && req.status == 200)
        {
            var resp = req.responseText;
            var ec = resp.split("\n")[0];
            if (ec == "exitcode=1")
            {
                alert("The item has been bookmarked.");
            }
            else if (ec == "success=0")
            {
                alert("You need to be logged in in order to bookmark meda.");
            }
            else if (ec == "exitcode=-2")
            {
                alert("You already have this item bookmarked!");
            }
            else 
            {
                alert("A problem occured, please try again later!");
            }            
        }
    }    
    
    req.open("GET", "/PlayerBookmark.ashx?mid=" + encodeURI(mediaID), true);
    req.send(null);
}


/*
    Add to favorites
*/

function addFavoriteComp(compID)
{
    var req;
    if (window.XMLHttpRequest)
        req = new XMLHttpRequest();
    else if (window.ActiveXObject) 
        req = new ActiveXObject("Microsoft.XMLHTTP");    
        
    req.onreadystatechange = function()
    {                    
        if (req.readyState == 4 && req.status == 200)
        {
            var resp = req.responseText;
            var ec = resp.split("\n")[0];
            if (ec == "exitcode=1")
            {
                alert("The company has been bookmarked.");
            }
            else if (ec == "success=0")
            {
                alert("You need to be logged in in order to bookmark companies.");
            }
            else if (ec == "exitcode=-2")
            {
                alert("You already have this company bookmarked!");
            }
            else 
            {
                alert("A problem occured, please try again later!");
            }            
        }
    }    
    
    req.open("GET", "/CompanyBookmark.ashx?compID=" + encodeURI(compID), true);
    req.send(null);
}
