$(function() {
	$('a.gallery').lightBox();
});

$(window).load(function() {
	var rh = $('#right_column').height();
	var lh = $('#left_column').height();
	var ch = $('#center_column').height();
	if(ch < rh || ch < lh) {
		if(rh < lh) {
			$('#center_column').height(lh);
		} else {
			$('#center_column').height(rh);
		}
	}
});

var banners = new Array();
function initBannerRotator(c_id, w, h, res, str_images, str_urls, str_titles)
{
  var nelementi = str_images.split('|').length;
  if(nelementi > 1) {
    banners[c_id] = {
      container_id: c_id,
      images: str_images.split('|'),
      urls: str_urls.split('|'),
      titles: str_titles.split('|'),
      width: w,
      heigth: h,
      resize: res,
      next: 0,
      nelements: nelementi - 1
    };
         
    setTimeout('nextBanner(\'' + c_id + '\');', 13000);
  }
}

function nextBanner(c_id)
{
  var banner = banners[c_id];
  var content = '';
  
  content += '<img alt="' + banner.titles[banner.next] + '" src="';
  if(banner.resize)
    content += '/phpthumb/phpThumb.php?src=' + banner.images[banner.next] + ((banner.heigth> 0) ? '&amp;h= "' + banner.heigth : '') + ((banner.width> 0) ? '&amp;w=' + banner.width : '');
  else
    content += banner.images[banner.next];
  content += '"' + ((banner.heigth> 0) ? ' height= "' + banner.heigth + '"' : '') + ((banner.width> 0) ? ' width= "' + banner.width + '"' : '');
  content += ' />';

  if(banner.urls[banner.next] != '') {
    content = '<a href="' + banner.urls[banner.next] + '" title="' + banner.titles[banner.next] +'">' + content + '</a>';
  }
    
  $('#' + c_id + ' div').hide();
  $('#' + c_id).append('<div>' + content + '</div>');
  
  banner.next++;
  if(banner.next == banner.nelements) {
    $('#' + c_id).cycle({
      fx: 'none', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
      //speed: 2000,
      timeout: 13000
      //delay: -16000
    });
  } else {
    setTimeout('nextBanner(\'' + c_id + '\');', 13000);
  }
}
