  
var hpcPosts //total number of certain case type defined in index.php

var offset = 0

var count = -1

var url = "http://www.knottlab.com/getpreview/"

var nextThumbs = function(){  

	count++

	offset = count * 3

	if (offset >= hpcPosts) {

		count = 0
		offset = 0

	}

	jQuery('#previewContainer').addClass("loader")

  	jQuery('#preview').fadeOut(500).load(url+'?offset='+offset,"",function() {

		jQuery('#preview').fadeIn(500)
		jQuery('#previewContainer').removeClass("loader")

		//textStr = "<b>Count:</b> " + count + " <b>offset:</b> " + offset

		//jQuery('#previewText').html(textStr)					
	

	})


     	return false

}




var prevThumbs = function(){

	count--


	if (count < 0) {
		
		count = 0
	}
	
	offset = count * 3 

    	jQuery('#previewContainer').addClass("loader")
    	jQuery('#preview').fadeOut(500).load(url+'?offset='+offset,"",function() {

    		jQuery('#preview').fadeIn(500)
    		jQuery('#previewContainer').removeClass("loader")


		//textStr = "<b>Count:</b> " + count + " <b>offset:</b> " + offset

		//jQuery('#previewText').html(textStr)		

	})
		
  
  	return false
 }



jQuery(document).ready(function(){  


	nextThumbs()

  	jQuery('.preview-next').click(nextThumbs)

	jQuery('.preview-prev').click(prevThumbs)
	

})