jQuery(function() {
  
  // Check out http://api.jquery.com/
  
  // Expects 'href' attribute of each 'a' to point to large version of image
	var lightBoxConfig = {
    imageLoading: '/images/lightbox/ico-loading.gif',
    imageBtnClose: '/images/lightbox/btn-close.gif',
    imageBtnPrev: '/images/lightbox/btn-prev.gif',
    imageBtnNext: '/images/lightbox/btn-next.gif'
  };
	var lightBoxGroups = []
	$('a.lightbox[rel]').each(function(){
		if($.inArray($(this).attr('rel'), lightBoxGroups) < 0){
			lightBoxGroups.push($(this).attr('rel'));
		}
	});
	for(i=0;i<lightBoxGroups.length;i++){
		$('a.lightbox[rel='+ lightBoxGroups[i] +']').lightBox(lightBoxConfig);
	}
	$('a.lightbox:not([rel])').lightBox(lightBoxConfig);
  
  // Expects container with images
  $('.cycle').cycle({
    timeout: 3000,
    speed: 3000,
    delay: 0
  });
  
  // Open external links in new tab
  $('a[href^="http://"]').attr('target', 'blank');
  
});
