$(document).ready ( function () {
	
	function init(){
			$("#move_next").unbind();
			$("#move_prev").unbind();
			
			var curr = "";
			
			$("#move_next").nextAll("img").each(function(){
			
			
				if (!($(this).hasClass("hide"))) 
					curr = $(this);
			});
			
			
			
			var changeToPrev = curr.prev("img");
			if (changeToPrev.length > 0) {
				
				$("#move_prev").show();
				
				$("#move_prev").click(function(){
					curr.addClass("hide");
					changeToPrev.removeClass("hide");
					
					init();
				});
			}
			else {
				$("#move_prev").hide();
				
			}
			
			var changeTo = curr.next("img");
			
			if (changeTo.length > 0) {
				$("#move_next").show();
				
				$("#move_next").click(function(){
					curr.addClass("hide");
					changeTo.removeClass("hide");
					init();
				});
			}
			else {
				$("#move_next").hide();
				
			}
		
	
	}
	
	$("a.toggler").click( function () {
		
		init();
	});
	
	init();
});

