function showButtons(obj)
{
    //parent_obj = obj.parentNode;
    var parent_obj = obj;

    // get all child a tags
    var a_objs = parent_obj.getElementsByTagName("a");

    // show the add and view links
    a_objs[1].style.display = 'inline';
    a_objs[2].style.display = 'inline';
    Element.addClassName(a_objs[1],'img');
    Element.addClassName(a_objs[2],'img');

}

function hideButtons(obj)
{
    //parent_obj = obj.parentNode;
    var parent_obj = obj;

    // get all child a tags
    var a_objs = parent_obj.getElementsByTagName("a");

    // hide the add and view links
    a_objs[1].style.display = 'none';
    a_objs[2].style.display = 'none';
    Element.removeClassName(a_objs[1],'img');
    Element.removeClassName(a_objs[2],'img');

}

function initButtons()
{

    // loop through all buttons and add behaviour
    // get main container div
    var c = document.getElementById('product_wrapper');

    if (c) {
        var divs = c.getElementsByTagName('div');
        for(var i=0;i<divs.length;i++) {
            if (!Element.hasClassName(divs[i], "thumbs")) {
                divs[i].onmouseover=function(){showButtons(this);};
                divs[i].onmouseout=function(){hideButtons(this);};
            }
        }
    } else {
        //alert("initButtons: Couldn't find product_wrapper");
    }
}


function highlightButtons(pr_ids)
{

    // loop through all buttons and add behaviour
    // get main container div
    var c = document.getElementById('product_wrapper');

    if (c) {

        var as = c.getElementsByTagName('a');
        for (var i=0;i<as.length;i++) {

            if (as[i].id != '') {
                var matches = as[i].id.match(/\d+/);
                if (matches[0]) {
                    if (pr_ids[matches[0]]) {
                        Element.addClassName($('p_' + matches[0]), "f");
                    } else {
                        Element.removeClassName($('p_' + matches[0]), "f");
                    }
                }
            }
        }
    } else {
        //alert("highlightButtonsResponse: Couldn't get product wrapper!");
    }
}


function initProducts()
{
    resize();

    $('product_loading').style.display = 'none';
    $('product_wrapper').style.display = '';

    // initialise button rollovers
    initButtons();
}

// add onload events
Event.observe(window, 'load', function() {initProducts();}, false);
