$(document).ready(function () {

var current_pos = 0;
var max_elements = $("#gallery").children().length;
var max_video_elements = $("#video_gallery").children().length;

	$("#next").click(function() {
		current_pos += 10;		
		if ( (current_pos + 10) > max_elements ) $("#next").hide();
		$("#prev").show();
		$(".thumb_container").each(function(index) {
			if ( index<(current_pos) ) {
				$(this).hide();
			}
			if ( index>=current_pos && index<(current_pos + 10)) {
				$(this).fadeIn(500);
			}
		});
		return false;
	});
	$("#prev").click(function() {
		current_pos -= 10;
		if (current_pos == 0) $("#prev").hide();
		$("#next").show();
		
		$(".thumb_container").each(function(index) {
			if ( index<current_pos || index>=(current_pos + 10) ) {
				$(this).hide();
			}
			if ( index>=current_pos && index<(current_pos + 10)) {
				$(this).fadeIn(500);
			}
		});
		return false;
	})
	
	$("#next_vid").click(function() {
		current_pos += 6;		
		if ( (current_pos + 6) > max_video_elements ) $("#next_vid").hide();
		$("#prev_vid").show();
		$(".vid_container").each(function(index) {
			if ( index<(current_pos) ) {
				$(this).hide();
			}
			if ( index>=current_pos && index<(current_pos + 6)) {
				$(this).fadeIn(500);
			}
		});
		return false;
	});
	$("#prev_vid").click(function() {
		current_pos -= 6;
		if (current_pos == 0) $("#prev_vid").hide();
		$("#next_vid").show();
		
		$(".vid_container").each(function(index) {
			if ( index<current_pos || index>=(current_pos + 6) ) {
				$(this).hide();
			}
			if ( index>=current_pos && index<(current_pos + 6)) {
				$(this).fadeIn(500);
			}
		});
		return false;
	})
	
	$("a.thumb").colorbox({
		transition:"fade", 
		title:function(){
			var inner_html = $(this).next().html()
			return inner_html;
		},
		current: ''
	});
$('#scroll_content').jScrollPane({showArrows:true});
});

