<!--
/*
function gallery_prew()
{
	if (gallery_now == 0)
	{
		gallery_now = gallery_id;
	}
	else
	{
		gallery_now--;
	}
	
	gallery_show();
}

function gallery_next()
{
	if (gallery_now == gallery_id)
	{
		gallery_now = 0;
	}
	else
	{
		gallery_now++;
	}
	
	gallery_show();
}

function gallery_show(){
	document.getElementById("gallery_name").innerHTML = gallery_dir_array[gallery_now];
	document.getElementById("gallery_a").href = gallery_array[gallery_now];
	document.getElementById("gallery_a").rel="lightbox["+gallery_dir_array[gallery_now]+"]";
	document.getElementById("gallery_img").src = gallery_array[gallery_now];
}
*/

$j(document).ready(function(){

var current_gallery = 0;
var current_image = 0;

$j("#gallery_select").change(function(){
	current_gallery = $j("#gallery_select > option:selected").val();
	current_image = 0;
	$j("#gallery_counter").html((current_image + 1)+"/"+gallery_array[current_gallery].length);
	$j(".gallery_image").children().remove();
	for (n = 0; n < gallery_array[current_gallery].length; n++){
		$j(".gallery_image").append('<a id="gallery_a_'+current_gallery+'_'+n+'" href="'+dirpath+'/'+gallery_name[current_gallery]+'/'+gallery_array[current_gallery][n]+'" rel="lightbox['+current_gallery+']" class="'+((n == current_image) ? "" : "hidden")+'"><img alt="" src="'+dirpath+'/'+gallery_name[current_gallery]+'/'+gallery_array[current_gallery][n]+'" /></a>');
	}
});

$j("#prev_image").click(function(){
	if (current_image <= 0){
		current_image += gallery_array[current_gallery].length;
	}
	current_image = (current_image - 1) % gallery_array[current_gallery].length;
	$j("#gallery_counter").html((current_image + 1)+"/"+gallery_array[current_gallery].length);
	$j("a[id^=gallery_a]").hide();
	$j("#gallery_a_"+current_gallery+"_"+current_image).show();
});

$j("#next_image").click(function(){
	if (current_image <= 0){
		current_image += gallery_array[current_gallery].length;
	}
	current_image = (current_image + 1) % gallery_array[current_gallery].length;
	$j("#gallery_counter").html((current_image + 1)+"/"+gallery_array[current_gallery].length);
	$j("a[id^=gallery_a]").hide();
	$j("#gallery_a_"+current_gallery+"_"+current_image).show();
});

});

//-->

