/* -------------------------------------------------------------------------- */
/**
 *    @fileoverview
 *       box linker
 *
 *    @version rev001.2008-12-05
 *    @requires bajl.js
 */
/* -------------------------------------------------------------------------- */



/* -------------------- function : BABoxLinker -------------------- */

function BABoxLinker(baseNode) {
    if (!BARegisterDOMMethodsTo(baseNode)) {
        throw 'BABoxLinker: base element node is required.';
    } else {
        var anchor = baseNode.getElementsByTagNameBA('a')[1];
        if (!anchor) {
            anchor = baseNode.getElementsByTagNameBA('a')[0];
        }
        if (anchor) {
            baseNode.addEventListenerBA('click'     , function(e) {
                location.href = anchor.href;
            });
            baseNode.addEventListenerBA('mouseenter', function(e) {
                anchor  .style.color          = '#598fc5';
                anchor  .style.textDecoration = 'underline';
                baseNode.style.cursor         = 'pointer';
                BASingleton(BAStatusMsg).set(anchor.href);
            });
            baseNode.addEventListenerBA('mouseleave', function(e) {
                anchor  .style.color          = '#0053a6';
                anchor  .style.textDecoration = 'none';
                baseNode.style.cursor         = 'default';
                BASingleton(BAStatusMsg).unset();
            });
        }
    }
}





/* -------------------- Main : register start-up -------------------- */

if (typeof BA == 'object' && BA.ua.isDOMReady) {
    BAAddOnload(function() {
        BAConcatNodeList(
              document.getElementByIdBA        ('galeries-pickup')
            , document.getElementsByClassNameBA('pick-up-unit'        , 'dl')
            , document.getElementsByClassNameBA('index-block-B01-unit', 'dl')
            , document.getElementsByClassNameBA('index-block-B02-unit', 'dl')
        ).forEach(BABoxLinker);
    });
}
