$(document).ready(function(){
	gallery.configure( 'Gallery' )
})

var gallery = {
	configure: function ( galleryName ) {
		$('#' + galleryName + ' .previousDesignsButton').click(function ( e ) {
			e.preventDefault()
			gallery.loadDesigns( this.href, 'previousDesignsButton', galleryName )
		})
		$('#' + galleryName + ' .nextDesignsButton').click(function ( e ) {
			e.preventDefault()
			gallery.loadDesigns( this.href, 'nextDesignsButton', galleryName )
		})
		$('#' + galleryName + ' .thumbButton').jqueryzoom( '#' + galleryName )
	},
	loadDesigns: function ( path, button, galleryName ) {
		$('#' + galleryName + ' .' + button).after("<img src='/img/waiting.gif' width='24' height='24' />")
		$.get(path, function(data){
		  $('#' + galleryName).replaceWith(data)
		  gallery.configure( galleryName )
		})
	}
}