function showbundleinfo(bundleName, isProtoBundle, sessionCookie)
{
    var div = document.getElementById("id_" + bundleName);
    if (div != null)
    {
        if (div.style.display == "none")
        {   // initiate Web Service call, callback will display
            call_getbundleinfo(bundleName, isProtoBundle, sessionCookie);
            var img = document.getElementById("imgtoggle" + bundleName);
            if (img != null)
                img.src = "images/collapse.jpg";
        }
        else
        {   // hide content
            div.style.display = "none";
            var img = document.getElementById("imgtoggle" + bundleName);
            if (img != null)
                img.src = "images/expand.jpg";
        }
    }
}
    
function call_getbundleinfo(bundleName, isProtoBundle, sessionCookie)
{
    try
    {
        var hostname = location.hostname;
        if (hostname == "localhost")
            hostname = "localhost/opteviv2";
        var url = "http://" + hostname + "/BundleService.asmx";
        
        var pl = new SOAPClientParameters();
        pl.add("bundleName", bundleName);
        pl.add("isProtoBundle", isProtoBundle);
        pl.add("sessionCookie", sessionCookie);
        SOAPClient.invoke(url, "GetBundleInfo", pl, true, showbundleinfo_callback);
    }
    catch (ex)
    {    
        alert("Failed to retrieve bundle information. Error: [" + ex.name + "] Details: [" + ex.message + "]");
    }
}
        
function showbundleinfo_callback(result)
{
    if (result.constructor.toString().indexOf("function Error()") != -1)
    {
        alert("Failed to retrieve bundle.\r\n\r\n" + result.description + "\r\n\r\n[Error code: " + result.number + "]");
    }
    else
    {
        // build a string to display the bundle contents
        var bundleInfo = result;
        var content = "";
                 
        if (bundleInfo != null)
        {                    
            if (bundleInfo.loves.length > 0)
                content = "<b>loves: </b>";
            for (i = 0; i < bundleInfo.loves.length; i++)
            {
                content += bundleInfo.loves[i];
                if (i < bundleInfo.loves.length - 1)
                    content += ", ";
            }

            if (bundleInfo.likes.length > 0)
            {
                if (content.length > 0)
                    content += "<br>";
                content += "<b>likes: </b>";
                for (i = 0; i < bundleInfo.likes.length; i++)
                {
                    content += bundleInfo.likes[i];
                    if (i < bundleInfo.likes.length - 1)
                        content += ", ";
                }
            }
                    
            if (bundleInfo.dislikes.length > 0)
            {
                if (content.length > 0)
                    content += "<br>";
                content += "<b>dislikes: </b>";
                for (i = 0; i < bundleInfo.dislikes.length; i++)
                {
                    content += bundleInfo.dislikes[i];
                    if (i < bundleInfo.dislikes.length - 1)
                        content += ", ";
                }
            }
                                        
            if (bundleInfo.blacklist.length > 0)
            {
                if (content.length > 0)
                    content += "<br>";
                content += "<b>blacklist: </b>";
                for (i = 0; i < bundleInfo.blacklist.length; i++)
                {
                    content += bundleInfo.blacklist[i];
                    if (i < bundleInfo.blacklist.length - 1)
                        content += ", ";
                }
            }

            var div = document.getElementById("id_" + bundleInfo.name);
            if (div != null)
            {
                div.innerHTML = content;
                div.style.display = "";
            }            
        }
    }
}
        
function hidebundle(bundleName)
{
    var div = document.getElementById("id" + bundleName);
    if (div != null)
    {
        div.style.display = "none";
    }
}