// <![CDATA[
  $(document).ready(
    function(){
	  init("#imagesgohere");
	  $(".gallery div:first").attr("id","first");
	  $(".gallery div:last").attr("id","last");
	  $('.gallery').serialScroll({
				items:'div',
				prev:'a.prev',//selector to the 'prev' button (absolute!, meaning it's relative to the document)
				next:'a.next',//selector to the 'next' button (absolute too)
				duration:700,
				force:true,
				axis:'y',
				lazy:true,//NOTE: it's set to true, meaning you can add/remove/reorder items and the changes are taken into account.
				step:9, //scroll 2 news each time
				cycle: false,
				exclude: 4,
				onAfter:function( elem ){
					var currentView = $(elem).attr("id");
					
					if ( currentView == "first" ) { $("a.prev").fadeOut("fast"); } else { $("a.prev").fadeIn("slow"); }
					
					if( currentView == "last" ) { $("a.next").fadeOut("fast"); } else { $("a.next").fadeIn("slow"); }
					}
					});	
	
	}
  );
  
  $(".gallery").show();
  
  function init(target){
    $('a').each(
      function() {
        if(this.getAttribute('href') &&
          (this.getAttribute('rel') == 'pagination')) {
          this.onclick = function(){
            if (this.getAttribute("bonus") && this.getAttribute("bonus") != '')
            	{
            	$(target).html('<a id="bigBox" href="' + this.getAttribute("bonus") +
            				'" class="thickbox"><img src="' + this.href +
            				'" alt="' + this.getAttribute("title") +
            				'" title="' + this.getAttribute("title") +
            				'" width="320' +
            				'" /></a>');
            	tb_init('a.thickbox');
            	}
            else
            	{
            	$(target).html('<img src="' + this.href +
                           '" alt="' + this.getAttribute("title") +
                           '" title="' + this.getAttribute("title") +
                           '" width="320' +
                           '" />');
            	}
            return false;
          }
        }
      }
    );
  }
// ]]>

