
$(document).ready(function(){
/*
 * Gallery
 */


 
// create ul element
$('.option_gallery2').after('<ul id="option_gallery2"></ul>');
// create li elements
$('.option_gallery2 .csc-textpic-imagecolumn img').each(function() {
   $('#option_gallery2').append($(this));
   $('#option_gallery2 > img').wrap('<li></li>');
});

$('.option_gallery2').remove();
$('#option_gallery2').addClass('jcarousel-skin-tango');

carousel = $('#option_gallery2').jcarousel({
    vertical:false,
    scroll:1,
    auto:0,
//    itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback },
    buttonNextHTML:'<a class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-triangle-1-e"/></a>',
    buttonPrevHTML:'<a class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-triangle-1-w"/></a>'
});

carousel.addClass('option_gallery2');
carousel.css('display','block');

$('.option_gallery2 li img').each(function() {
  $(this).wrap('<a href="' + $(this).attr('src').replace(/uploads\/pics\//g, 'fileadmin/templates/pics/gallery/img_') + '" class="thickbox" title="click to enlarge!"></a>');
});

tb_init('.thickbox');

/* 
 * UI-Elements
 */
  $('.option_gallery2_wrapper .fg-button')
  .hover(
      function(){ 
        if(!$(this).hasClass("jcarousel-prev-disabled") && !$(this).hasClass("jcarousel-next-disabled")) {
  	  $(this).addClass("ui-state-hover"); 
  	}
      },
      function(){ 
	$(this).removeClass("ui-state-hover"); 
      }
  );
 
});


