﻿function rss_addLoadEvent(func)
{
   var oldonload = window.onload;
   if (typeof window.onload != 'function')
   {
       window.onload = func;
   }
   else
   {
       window.onload = function()
       {
           oldonload();
           func();
       }
   }
}

function rss_loadXMLDoc(url, callback) 
{
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = callback;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = callback;
            req.open("GET", url, true);
            req.send();
        }
    }
    
    return req;
}

function rss_callback(id, req) 
{
    if (req != null)
    {
        // only if req shows "complete"
        if (req.readyState == 4) {
            // only if "OK"
            if (req.status == 200)
            {
               document.getElementById(id).innerHTML = req.responseText;
            } 
            else 
            {
                document.getElementById(id).innerHTML = "Error";
            }
        }
    }
}

function rss_DoExpand(el)
{
    var target = el.parentNode.childNodes[2];
    
    if (target.style.display == "")
    {
        target.style.display = "none";
        el.className = "RSS_Expand";
    }
    else
    {
        target.style.display = "";
        el.className = "RSS_Collapse";
    }
}
