  $(function() {
   
    var galleries = $('.ad-gallery').adGallery(
	{
	thumb_opacity: 0.9,
	display_next_and_prev: true, // Can you navigate by clicking on the left/right on the image?
	display_back_and_forward: false, // Are you allowed to scroll the thumb list?
	effect: 'fade', //'slide-hori' or 'slide-vert', 'fade', or 'resize', 'none'
	loader_image: '',
	  callbacks: {
		init: function() {
		  this.preloadAll();
		}
	  },

slideshow: {
    enable: true,
    autostart: true,
    speed: 5000,
    start_label: 'Start',
    stop_label: 'Stop',
    stop_on_scroll: true, // Should the slideshow stop if the user scrolls the thumb list?
    countdown_prefix: '(', // Wrap around the countdown
    countdown_sufix: ')'}
	}
	
	);
    $('#switch-effect').change(
      function() {
        galleries[0].settings.effect = $(this).val();
        return false;
      }
    );
    $('#toggle-slideshow2').click(
      function() {
	  if(this.className=='btn_play')
	  {
	  galleries[0].slideshow.start();
	  this.className='btn_pause';
	  }
	  else if(this.className=='btn_pause')
	  {
	  galleries[0].slideshow.stop();
	   this.className='btn_play';
	 	}
        //slideshow.toggle();
		//document.getElementsById('pause_js').class="";
	
        return false;
      }
    );
$('#sekantis').click(
function() {
galleries[0].nextImage();
galleries[0].slideshow.stop();
document.getElementById('toggle-slideshow2').className='btn_play'; 
return false;
}
);
$('#ankstesn').click(
function() {
//alert('haha');
galleries[0].prevImage();
galleries[0].slideshow.stop();
document.getElementById('toggle-slideshow2').className='btn_play'; 
return false;
}
);
    $('#toggle-description').click(
      function() {
	  
        if(!galleries[0].settings.description_wrapper) {
          galleries[0].settings.description_wrapper = $('#descriptions');
        } else {
          galleries[0].settings.description_wrapper = false;
        }
        return false;
      }
    );
  });
