var count = 0;
var prevcount = "0";
var nextcount = "1";
var src = "";

currenthref = location.href;
start = currenthref.indexOf("africa/sets/")+13;
end = currenthref.indexOf(".shtml");
var set = currenthref.substring(start,end)-1;

// set the image source
if(location.search.substring(1) != "") {
	if(location.search.substring(1).indexOf("count") > -1) {
		substr = location.search.substring(1).indexOf("count=");
		count = location.search.substring(1).substring(substr+6);
		if(count != "5") {  // first 5 pics
			src = "/africa/images/" + setName + pic[count] + ".jpg";
		} else { // pic 6
			src = "/africa/images/" + setName + pic[5] + ".jpg";
		}
	}
} else {
	count = "0";
	src = "/africa/images/" + setName + pic[0] + ".jpg";
}

// prevcount and nextcount
if(count == 0) {
	prevcount=0;
} else {
	prevcount=parseInt(count)-1; 
	nextcount=parseInt(count)+1;
}

// prev/next set
set == 0 ? prevset = 0 : prevset = set-1;
set == 3 ? nextset = 0 : nextset = set+1;
exitlink = false;
if( (nextset == 0) && (nextcount == 6) ) exitlink = true;
if( (setName == "o") && (nextset == 0) && (nextcount > 1) ) exitlink = true;


