var as_current_shot = 1;
var as_total_shots = 27;
var as_current_shot_name = as_current_shot + 0;

function as_update_shot ()
{
	var sb = document.getElementById("as-superbox");
	if ( !sb )
		return;

	var img = sb.getElementsByTagName("img");
	if ( img.length == 0 )
		return;

//	alert(as_current_shot);
	as_current_shot_name = as_current_shot + 0;
	img[0].src = "img/pages/shots/screenshot_" + as_current_shot_name + ".jpg";
}

function as_set_initial_shot ()
{
	var id = document.location.href.match(/.+\?.*&?shot=(\d+).*/);
	if ( id )
	{
		as_current_shot = Number(id[1]);
		if ( (as_current_shot < 1) || (as_current_shot > as_total_shots) )
			as_current_shot = 1;
	}

	as_update_shot ();
}

function as_prev_snapshot ()
{
	as_current_shot = ( as_current_shot > 1 ) ? (as_current_shot - 1) : as_total_shots;
	as_update_shot ();
}

function as_next_snapshot ()
{
	as_current_shot = ( as_current_shot < as_total_shots ) ? (as_current_shot + 1) : 1;
	as_update_shot ();
}

function as_setup_buttons ()
{
	var sv = document.getElementById("as-snapshot-viewer");
	if ( !sv )
		return;

	var img_list = sv.getElementsByTagName("img");
	for ( var i = 0; i < img_list.length; ++i )
	{
		if ( img_list[i].className == "prev" )
			img_list[i].onclick = as_prev_snapshot;
		if ( img_list[i].className == "next" )
			img_list[i].onclick = as_next_snapshot;
	}
}
