/**
* @author Den Markin <denmarkin@gmail.com>, http://dmarkin.name
* @version $Id$
* @package LookSystems_PromoWidgets
*/

document.observe("dom:loaded", function() {
  // initially hide all containers for tab content
  $$('div.block').each( function (block) {
    if (true == block.hasClassName('clickable')) {
      block.setStyle({
        cursor: 'pointer'
      });
      Event.observe(block, 'click', function(){goTo(block)}.bind(block), false);
    }
  })
});

function goTo (block) {
  if (block.getElementsBySelector('a.brown-find').length) {
    link = block.getElementsBySelector('a.brown-find').first().readAttribute('href');
  } else if (block.getElementsBySelector('a.more-info').length) {
    link = block.getElementsBySelector('a.more-info').first().readAttribute('href');
  }
  
  if (link) {
    if (false == link.startsWith('http://')) {
      link = BASE_URL + link;
    }
    window.location.href = link;
  }
}

