(function($) {
  $.fn.equalizeCols = function(){
    var height = 0,
    reset = $.browser.msie ? "1%" : "auto";
  
    return this
      .css("height", reset)
      .each(function() {
        height = Math.max(height, this.offsetHeight);
      })
      .css("height", height)
      .each(function() {
        var h = this.offsetHeight;
        if (h > height) {
          $(this).css("height", height - (h - height));
        };
      });
   };

})(jQuery);

$(document).ready(function() {

  // Establish the systems cycle for the homepage et al
  $('#systems-cycle').cycle({ 
    fx:  'scrollDown',
    speed:  1500,
    timeout:  8000
  });


// Page scrollers
$.scrollTo.defaults.axis = 'x'; 			
	//this one is important, many browsers don't reset scroll on refreshes
	$('div.pane').scrollTo( 0 );//reset all scrollable panes to (0,0)
	$.scrollTo( 0 );//reset the screen to (0,0)

var $paneTarget = $('#scroll-pane');
$('#scroll-right').click(function(){ $paneTarget.stop().scrollTo( '+=300', 500 ); return false;});
$('#scroll-left').click(function(){ $paneTarget.stop().scrollTo( '-=300', 500 ); return false;});

// Ensure all columns that should be are equal
$(".col .content").equalizeCols();
$(".col .title").equalizeCols();

// Catch all links with lightbox rel
$('a[@rel*=lightbox]').lightBox({
	imageLoading: 'http://www.4energy.co.uk/images/site/lightbox-ico-loading.gif',
	imageBtnClose: 'http://www.4energy.co.uk/images/site/lightbox-btn-close.gif',
	imageBtnPrev: 'http://www.4energy.co.uk/images/site/lightbox-btn-prev.gif',
	imageBtnNext: 'http://www.4energy.co.uk/images/site/lightbox-btn-next.gif'
   });

});
