var gallery = {};
var counter = {};

function img(subid, which){
	var len = gallery[subid].length;

	if (which)
		counter[subid]++;
	else 
		counter[subid]--;

	// if at end, go to beginning; if at beginning, go to end

	if (counter[subid] < 0)
		counter[subid] = len - 1;

	else if (counter[subid] == len)
		counter[subid] = 0;

	
	document.getElementById('status' + subid).innerHTML = (counter[subid] + 1) + ' of ' + len;
	document.getElementById('title' + subid).innerHTML = gallery[subid][counter[subid]][1];

	var img = document.getElementById('gallery' + subid);
	img.src = '/imagevault/' + gallery[subid][counter[subid]][0];
	img.onclick = Function('showimg(' + subid + ',' + (counter[subid]+1) + ')');
}


function showimg(subid, ordernum){
	window.open('/cms/showimg.php?subid=' + subid + '&ordernum=' + ordernum, 'showimg', 'scrollbars=yes,width=730,height=720');
}