function initHorizontalContainer(){
  if ($('content-framework-content')){

    function setContainerWidth(){
      var containerWidth = 0;
      $$('#content-framework-content .itemblock').each(function(item){
        itemWidth = item.getStyle('width').toString().toInt();
        itemMargin = item.getStyle('margin-left').toString().toInt() + item.getStyle('margin-right').toString().toInt();
        itemPadding = item.getStyle('padding-left').toString().toInt() + item.getStyle('padding-right').toString().toInt();
        extraSpace = 1; // Some extra spacing to fix Mac-Firefox bug
        containerWidth = containerWidth + itemWidth + itemMargin + itemPadding + extraSpace;
      })

      $('content-framework-content').setStyle('width', containerWidth);
    }

    var images = new Array();
    $$('#content-framework-content .itemblock img').each(function(item){
      images.include(item.getProperty('src'));
    });

    if (images.length != 0){
      new Asset.images(images, {
        onComplete: function(){
          setContainerWidth();
        }
      });
    }else {
      setContainerWidth();
    }

  }
}

function initImageblocks(){

  $$('.imageblock').addEvent('mouseenter', function(){
    if (this.getElement('.description')){
      this.getElement('.description').setStyle('display', 'block');
      var image = this.getElement('img');
      var width = image.getStyle('width');
      var height = image.getStyle('height');

      this.getElement('.description').setStyle('width', width);
      this.getElement('.description').setStyle('height', height);
    }
  });

  $$('.imageblock').addEvent('mouseleave', function(){
    if (this.getElement('.description')){
      this.getElement('.description').setStyle('display', 'none');
    }
  });
}

window.addEvent('domready', function(){
  initImageblocks();
  initHorizontalContainer();
});
