function initgallery(){
  /**
   * Image Slider
   * Copyright 2010, Fat Pixel and KOeF
   * Written by Marijn Tijhuis and Roeland Kuiper
   */
  
  // SETTINGS
  var speed = 350;  // set animation speed, in milliseconds (1000 = 1s)
  // --------
  
  var slides=new Array();

  // set class
  $(".thumbnail>div").addClass("slider");

  $('.slider').each(function(index) {

  // set unique slider
 	 var sid = $(this).attr("id");

//	alert(index + ': ' + sid);
	// count number of slides

	var slides = new Array();
	slides[index] = $(this).children("ul").children("li").size();
	$(this).data('slides',slides[index]);
//	alert($(this).data('slides'));
//		alert(index + ': ' + slides[index]);

	  
	  // build controls
	  $(this).children("ul").addClass("slidecont");
	  $(this).addClass("slideinit");
	  if (slides[index] > 1) { // if there is only 1 slide, then ignore the arrows
		  $(this).append('<span class="slidefwd"><a href="#">&gt;</a><a href="#" class="arrow"></a></span>');
		  $(this).prepend('<span class="slidebck"><a href="#" class="arrow"></a><a href="#">&lt;</a></span>');
	  }
	  // get the size of a slide
	  var slide_width = parseInt($(this).css("width"));
	  // read height of first image in slider
	  var slide_height = parseInt($(this).find("img:first").height());
	  // set the slide container width
	  $(this).children("ul.slidecont").css("width",slide_width * slides[index]);
	  // set the slide container height
	  $(this).css("height",slide_height);
	  // set the slide height
	  $(this).children().children("li").css("height",slide_height);
	  // set variables
	  var clicks = 1;
	  var numslides;
	  $(this).data('clicks',clicks);
  
	  $(this).children(".slidefwd").click(function(){
//	    alert(index+" clicks : "+$(this).parent().data('clicks')+" / slides : "+$(this).parent().data('slides'));
		if($(this).parent().data('clicks') == $(this).parent().data('slides')){
	      $(this).parent().children("ul").animate({ left: '0px'},speed,'swing');
	      $(this).parent().data('clicks',1);
    	} else {
	      $(this).parent().children("ul").animate({ left: '-='+slide_width+'px'},speed,'swing');
	    	  clicks = $(this).parent().data('clicks');
			  clicks += 1;
			  $(this).parent().data('clicks',clicks);
	    }
	    return false;
	  });
	
	  $(this).children(".slidebck").click(function(){
	    if($(this).parent().data('clicks') == 1){
	    	numslides = $(this).parent().data('slides') - 1;
	      $(this).parent().children("ul").animate({ left: '-'+slide_width*(numslides)+'px'},speed,'swing');
	      $(this).parent().data('clicks',numslides+1);
	    } else {
	      $(this).parent().children("ul").animate({ left: '+='+slide_width+'px'},speed,'swing');
	      clicks = $(this).parent().data('clicks');
		  clicks -= 1;
		  $(this).parent().data('clicks',clicks);
	    }
	    return false;
	  });
  });

}
