Index: galleria.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/galleria/Attic/galleria.admin.inc,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 galleria.admin.inc
--- galleria.admin.inc	23 Mar 2009 14:40:16 -0000	1.1.2.5
+++ galleria.admin.inc	11 Apr 2009 19:37:37 -0000
@@ -50,6 +50,64 @@
     drupal_set_message(t('If you install the imagecache module, you will get extra options here for integration.'), 'status');
   }
 
+  if (module_exists('jcarousel')) {
+    $form['galleria_jcarousel'] = array('#type' => 'fieldset', '#title' => t('jCarousel Integration'));
+    $form['galleria_jcarousel']['galleria_jcarousel'] = array(
+      '#type' => 'select',
+      '#title' => t('jCarousel Integration'),
+      '#options' => array(
+        'enabled' => 'Enabled',
+        'disabled' => 'Disabled',
+      ),
+      '#default_value' => variable_get('galleria_jcarousel', 'enabled'),
+    );
+    $form['galleria_jcarousel']['galleria_jcarousel_vertical'] = array(
+      '#type' => 'select',
+      '#title' => t('Orientation'),
+      '#options' => array(
+        'false' => 'Horizontal',
+        'true' => 'Vertical',
+      ),
+      '#default_value' => variable_get('galleria_jcarousel_vertical', 'false'),
+    );
+    $form['galleria_jcarousel']['galleria_jcarousel_visible'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Limit of visible thumbnails'),
+      '#size' => 15,
+      '#default_value' => variable_get('galleria_jcarousel_visible', '3'),
+      '#description' => t('Thumbnails will be cropped so exactly this number of thumbnails is always shown. Must be an integer greater than zero.'),
+    );
+    $form['galleria_jcarousel']['galleria_jcarousel_scroll'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Scroll size'),
+      '#size' => 15,
+      '#default_value' => variable_get('galleria_jcarousel_scroll', '3'),
+      '#description' => t('The number of thumbnails to scroll with each mouse click.'),
+    );
+    $form['galleria_jcarousel']['galleria_jcarousel_animation'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Animation speed'),
+      '#size' => 15,
+      '#default_value' => variable_get('galleria_jcarousel_animation', 'fast'),
+      '#description' => t('The speed of the scroll animation. Use "slow", "normal", "fast", or the number of milliseconds (ie. "100"). If set to 0, animation is turned off.'),
+    );
+    $form['galleria_jcarousel']['galleria_jcarousel_wrap'] = array(
+      '#type' => 'select',
+      '#title' => t('Wrap'),
+      '#options' => array(
+        'null' => 'None',
+        'left' => 'Left',
+        'right' => 'Right',
+        'both' => 'Both',
+      ),
+      '#default_value' => variable_get('galleria_jcarousel_wrap', 'null'),
+      '#description' => t('Specifies whether to wrap at the first/last item (or both) and jump back to the start/end.'),
+    );
+  }
+  else {
+    drupal_set_message(t('If you install the jCarousel module, you will get extra options here for integration.'), 'status');
+  }
+
   $form['galleria_show_page_warning'] = array(
     '#type' => 'checkbox',
     '#title' => t('Galleria warnings'),
@@ -59,3 +117,42 @@
 
   return system_settings_form($form);
 }
+
+function galleria_admin_settings_validate($form, &$form_state) {
+  if (module_exists('jcarousel')) {
+    $input_names = array(
+      'visible' => 'Limit of visible thumbnails',
+      'scroll' => 'Scroll size',
+    );
+    foreach($input_names as $name => $title) {
+      $value =& $form_state['values']['galleria_jcarousel_' . $name];
+      if (!is_numeric($value)) {
+        form_set_error('galleria_jcarousel_' . $name, t('"' . $title . '" must be an integer.'));
+      }
+      else {
+        $value = intval($value);
+      } 
+    }
+
+    //The "visible" setting cannot be 0, otherwise the carousel explodes in IE
+    if ($form_state['values']['galleria_jcarousel_visible'] == 0) {
+      form_set_error('galleria_jcarousel_visible', t('"Limit of visible thumbnails" must be greater than zero.'));
+    }
+
+    $animation =& $form_state['values']['galleria_jcarousel_animation'];
+    switch($animation) {
+      case 'slow':
+      case 'normal':
+      case 'fast':
+      break;
+      default:
+        if (!is_numeric($animation)) {
+          form_set_error('galleria_jcarousel_animation', t('"Animation speed" must be "slow", "normal", "fast", or an integer value.'));
+        }
+        else {
+          $animation = intval($animation);
+        } 
+      break;
+    }
+  }
+}
\ No newline at end of file
Index: galleria.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/galleria/galleria.module,v
retrieving revision 1.1.2.13
diff -u -r1.1.2.13 galleria.module
--- galleria.module	23 Mar 2009 14:40:16 -0000	1.1.2.13
+++ galleria.module	11 Apr 2009 19:29:07 -0000
@@ -287,4 +287,15 @@
 
   $vars['next_prev_links'] = '<a onclick="$.galleria.prev(); return false;" href="#"><< ' . t('previous') . '</a> | <a onclick="$.galleria.next(); return false;" href="#">' . t('next') . '>></a>';
   $vars['gallery'] = theme('item_list', $images, NULL, 'ul', $attribs);
+
+  if (module_exists('jcarousel') && variable_get('galleria_jcarousel', 'enabled') == 'enabled') {
+    $vars['options'] = array(
+      'vertical' => (variable_get('galleria_jcarousel_vertical', 'false') == 'true') ? TRUE : FALSE,
+      'visible' => variable_get('galleria_jcarousel_visible', '3'),
+      'scroll' => variable_get('galleria_jcarousel_scroll', '3'),
+      'animation' => variable_get('galleria_jcarousel_animation', 'fast'),
+      'wrap' => variable_get('galleria_jcarousel_wrap', 'null'),
+      'initCallback' => 'jcarousel_initCallback',
+    );
+  }
 }
Index: galleria.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/galleria/galleria.tpl.php,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 galleria.tpl.php
--- galleria.tpl.php	12 Dec 2008 14:40:28 -0000	1.1.2.1
+++ galleria.tpl.php	11 Apr 2009 19:30:06 -0000
@@ -7,7 +7,13 @@
  */
 ?>
 <div id="galleria-content">
-  <?php print $gallery; ?>
+  <div id="main-image"></div>
+  <?php
+  print $gallery;
+  if (module_exists('jcarousel') && variable_get('galleria_jcarousel', 'enabled') == 'enabled') {
+    jcarousel_add('.gallery', $options);
+  }
+  ?>
   <div class="galleria-nav">
     <?php print $next_prev_links; ?>
   </div>
Index: inc/galleria.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/galleria/inc/galleria.js,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 galleria.js
--- inc/galleria.js	16 Jan 2009 17:02:58 -0000	1.1.2.3
+++ inc/galleria.js	11 Apr 2009 19:56:43 -0000
@@ -1,6 +1,7 @@
 // $Id: galleria.js,v 1.1.2.3 2009/01/16 17:02:58 marktheunissen Exp $
 
 var options = {
+  insert    : '#main-image', // the containing selector for our main image
   onImage : function(image, caption, thumb) {
     // let's add some image effects for demonstration purposes
     // fade in the image & caption
@@ -22,6 +23,9 @@
     image.attr('title','Next image >>');
 
     $('.galleria-nav').show();
+
+    // trigger the jCarousel to scroll to the current image's thumbnail
+    $('#main-image').trigger('img_change', [thumb.parent().attr('jcarouselindex')]);
   },
 
   onThumb : function(thumb) {
@@ -55,3 +59,11 @@
     $('ul.gallery').galleria(options);
   });
 };
+
+function jcarousel_initCallback(carousel) {
+  jQuery('#main-image').bind('img_change', function(e, index) {
+    var num = parseInt(index);
+    carousel.scroll(num);
+    return false;
+  });
+};	

