//<![CDATA[
jQuery(function($) {
// extends one gallery class to the other to use the <li> without problems.
// genero un doble de compatibilidad entre las dos galerias
$('.jcarousel-skin-tango').addClass('gallery');	

// make automatically the thumbnails
//genero miniaturas y recuadro de exposición	
var options = {
        insert : '#main_image',
		
        clickNext : true,
       
		onThumb : function(thumb) { // thumbnail effects goes here
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// if thumbnail is active, fade all the way.
				var _fadeTo = _li.is('.active') ? '1' : '0.9';
				
				// fade in the thumbnail when finished loading
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(500);
				
				// hover effects
				thumb.hover(
					function() { thumb.fadeTo('fast',1); },
					function() { _li.not('.active').children('img').fadeTo('fast',0.6); } // don't fade out if the parent is active
				)
				}
};
$('ul.gallery').galleria(options);


// show the first image by default, otherwise whichever the user wants.
var l  = window.location.hash;
if ( !l )
{
 	$('ul.gallery li:first').addClass('active');
}

// how many pictures we have? This is for the gallery to cycle with non black spaces or a few, but not infinit like in a bug.
var cuantas_son = $('ul.gallery li').size();
cuantas_son=Math.round(cuantas_son/1);

// start thumbnails to slide show with Jcarousel
// convierto miniaturas a Jcarousel para tener slide show 
jQuery('#mycarousel').jcarousel({
        	scroll: 4, 
		vertical: true,
		wrap: 'last',
		size: cuantas_son
				    });

if(  $('ul.gallery li').size() > 8 )
{
	$(".jcarousel-prev-vertical").html('&nbsp;&nbsp;&lt&lt;prev');		
	$(".jcarousel-next-vertical").html('&nbsp;&nbsp;&nbsp;next&gt;&gt;');	
	$(".jcarousel-next-vertical").css('float:', 'right');
	$(".jcarousel-next-vertical").css('text-align:', 'right');
}

//fin 
 }); 
  //]]>

