function showCat(id, name) {
    pageTracker._trackPageview("'" + name + "'");
    placeRequest("cats.php?id=" + id);
}

function showPage(page) {
    placeRequest("page.php?page=" + page);
}

function showSearchResults(result) {
   showContent(result);
}

function showExpCompany(id, catID) {
    placeRequest("company.php?cID=" + id + "&catID=" + catID);
}

function addCompany() {
    //placeRequest("addcompany.php");
    countries.loadajaxpage("addcompany.php");
}

function showContent(content) {
    var el = getElementsByClassName('desktop_columns');

    for(var i = 0; i < el[0].childNodes.length; i++) {
        el[0].childNodes[i].style.display = "none";
    }

    if(document.getElementById('linkPage')) {
        el[0].removeChild(document.getElementById('linkPage'));
    }

    var theDiv = document.createElement('div');
    theDiv.setAttribute('id', 'linkPage');
    theDiv.innerHTML = content;


    el[0].appendChild(theDiv);

    kernel.getWidget(2).hideTab('0');
}

function placeRequest(sRequest) {
    var oXmlHttp = zXmlHttp.createRequest();
    var sURL = sRequest;

    oXmlHttp.open("get", sURL, true);

    oXmlHttp.onreadystatechange = function()
    {
        if(oXmlHttp.readyState == 4)
        {
            if(oXmlHttp.status == 200)
            {
                showContent(oXmlHttp.responseText);
            }
            else
            {
                return "An error occured: " + oXmlHttp.statusText;
            }
        }
    };
    oXmlHttp.send(null);
}

function showPhone(id) {
    if(document.getElementById("phoneRow-"+id).style.display == "block")
        document.getElementById("phoneRow-"+id).style.display = "none";
    else
        document.getElementById("phoneRow-"+id).style.display = "block";
}

function showInfo(id) {
    if(document.getElementById("extraInfo-"+id).style.display == "block") {
        document.getElementById("extraInfo-"+id).style.display = "none";
        document.getElementById("ci").style.backgroundImage = "url('/static/contact/extra.jpg')";
    }
    else {
        document.getElementById("extraInfo-"+id).style.display = "block";
        document.getElementById("ci").style.backgroundImage = "url('/static/contact/driehoek.jpg')";
    }
}

function viewFeed(item_id, feed_id, title) {

    item_id = item_id.replace(/^\s+|\s+$/g, '');
    feed_id = feed_id.replace(/^\s+|\s+$/g, '');

    if(document.getElementById("staticrss_window")) {
        document.getElementById('staticarticle').src = '/rss_generator/html/' + feed_id + '_' + item_id + '.html';

    } else {
        var decoded_title = title.replace(/\+/g, " ");
        var oWindow = document.createElement("div");
        oWindow.setAttribute("id", "staticrss_window");
        oWindow.setAttribute('width', '700');
        oWindow.setAttribute('height', '400');

       var oHeader = document.createElement("div");
       oHeader.setAttribute("id", "headerBar");
       oHeader.appendChild(document.createTextNode(decoded_title));

       var aCloseLink = document.createElement("a");
       aCloseLink.setAttribute('href', 'javascript:void(0)');
       //aCloseLink.setAttribute('onclick', 'removeFeed()');
       aCloseLink.appendChild(document.createTextNode('sluit'));
       aCloseLink.onclick = function () {
           removeFeed();
       };
       oHeader.appendChild(aCloseLink);

       oWindow.appendChild(oHeader);

       var oSpacer = document.createElement("br");
       oWindow.appendChild(oSpacer);

       var oTitle = document.createElement("h1");
       oTitle.appendChild(document.createTextNode("U bekijkt:" + decoded_title));

       var oSideBar = document.createElement('iframe');
       oSideBar.setAttribute('src', 'rss_generator/html/' + feed_id + '.html');
       oSideBar.setAttribute('width', '330');
       oSideBar.setAttribute('height', '370');
       oSideBar.setAttribute('frameborder', 'no');
       oSideBar.style.border = '1px solid #A0A0A0';

       var oArticle = document.createElement('iframe');
       oArticle.setAttribute('src', 'rss_generator/html/' + feed_id + '_' + item_id + '.html');
       oArticle.setAttribute('name', 'staticarticle');
       oArticle.setAttribute('id', 'staticarticle');
       oArticle.setAttribute('width', '330');
       oArticle.setAttribute('height', '370');
       oArticle.setAttribute('frameborder', 'no');
       oArticle.style.border = '1px solid #A0A0A0';

       oWindow.appendChild(oTitle);
       oWindow.appendChild(oSideBar);
       oWindow.appendChild(oArticle);

       document.getElementById('container').appendChild(oWindow);
    }

    return false;
}

function removeFeed() {
    var ifr = document.getElementById('staticarticle');

    document.getElementById('staticrss_window').removeChild(ifr);
    document.getElementById('container').removeChild(document.getElementById("staticrss_window"));
}



