 $(document).ready(function() {
	//accordion
	$('div.accordionButton').click(function() {
	$('div.accordionContent').slideUp('normal');
	$(this).next().slideDown('normal');
	$('div.accordionButtonSelected').removeClass().addClass('accordionButton');
	$(this).removeClass().addClass('accordionButtonSelected');
	});
	
	
	jQuery(function($) {
		
		$('.jcarousel-skin-tango').addClass('gallery');
		
		//$('.gallery').addClass('galleria'); // adds new class name to maintain degradability
		
		$('.gallery').galleria({
			history   : true, // activates the history object for bookmarking, back-button etc.
			clickNext : true, // helper for making the image clickable
			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
				if(! ($.browser.mozilla && navigator.appVersion.indexOf('Win')!=-1) ) { // FF/Win fades large images terribly slow
					image.css('display','none').fadeIn(600);
				}
				//center images based on width and height
				var top = ( $('.entry ').height() - $('.entry #main_image').height() ) / 2;
    			$('.entry #main_image').css('margin-top', top);
				var left = ( $('.entry ').width() - $('.entry #main_image').width() ) / 2;
    			$('.entry #main_image').css('margin-left', left);
				
				
				$('#main_image .caption').css('height', 0)
				 
				$('#main_image')
                .hover(
                    function(){ $('#main_image .caption').stop().animate({height: 50}, 250) 
					},
                    function(){ 
                        if (!$('#show-caption').is(':checked')) {
                            $('#main_image .caption').stop().animate({height: 0}, 250) 
                        }
                    }
                );
				$('#show-caption').change(function(){
    	if (this.checked) {
    		$('#main_image .caption').stop().animate({height: 50}, 250)
    	} else {
            $('#main_image .caption').stop().animate({height: 0}, 250)   
        }
    })
				 
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(500,0.7);
				
				// fade in active thumbnail
				thumb.fadeTo('fast',1).addClass('selected');
				
				// add a title for the clickable image
				image.attr('title','Next image >>');
			},
			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.3';
				
				// 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.3); } // don't fade out if the parent is active
				)
			}
			
		});
		
		jQuery('#mycarousel').jcarousel({
        	scroll: 2, vertical: true,wrap: 'last', visible:4
	        
	    });
		 
	});

});


