// supporting functions for photo.net mini slide show
// must be included AFTER the two declarations in the html part


var photos = p.split(' | '); 
var pix = photos.length;
var curr = 0;

function move() {
	var lmt = cnt;
	
    if (cnt >= pix){
		lmt = pix;
		curr = 0;
    }

	for (i=0; i<cnt; i++){
		var src = 'http://gallery.photo.net/photo/' + photos[checkForEnd(curr + i)] + '-' + img_size + '.jpg';
		var ref = 'http://photo.net/photodb/photo?photo_id=' + photos[checkForEnd(curr + i)];
		document.getElementById("img"+i).src = src; 
		document.getElementById("a"+i).href = ref; 
	}    
}

function checkForEnd(p) {
	p = (p < pix) ? p : p-pix;
	return p;
}

function checkForBeg(p) {
	p = (p < 0) ? pix + p : p;
	return p;
}

function next() {    
    curr = checkForEnd( curr + cnt ); 
    move(); 
}

function prev() {
    curr = checkForBeg(curr - cnt);
    move(); 
}

document.write('<table align=center style="text-align:center; border:1px solid #aaa;">');
document.write('<tr><td style="font-size:x-small;text-align:center;"><a href="http://photo.net" target="_blank">');
document.write('<img src="http://photo.net/v3graphics/photonet_logo_100.jpg" style="border:0px;padding:0px;margin:0px;">');
document.write('</a></td></tr>');
for (i=0; i<cnt; i++) {
	document.write('<tr><td style="font-size:x-small;text-align:center;">');
	document.write('<a id=a' + i + ' target=_blank href="http://photo.net/photodb/photo?photo_id=' + photos[i] + '">');
	document.write('<img id="img' + i + '" name="img' + i + '" src="http://gallery.photo.net/photo/' + photos[i] + '-' + img_size + '.jpg"'); 
	document.write(' style="height:' + img_height + 'px;padding:5px;border:0px solid #aaa;"></a>'); 
	document.write('</td></tr>');
}
document.write('<tr><td style="font-size:small;text-align:center;">&nbsp;&lt;&nbsp;<a href="#" onclick="prev();return false;">prev</a>&nbsp;|&nbsp;<a href="#" onclick="next();return false;">next</a>&nbsp;&gt;&nbsp;');
document.write('</td></tr></table>');
