imgcount = new Array();
imgsrc = new Array();
imgcaption = new Array();
// JG - 17/01/07 - added to enable a caption to have an associated link.
imglink = new Array();

currentImg = new Array();
initObj = new Array();
imgObj = new Array();
linkObj = new Array();
capObj = new Array();
prevObj = new Array();
nextObj = new Array();

function slide_next(s) {
	if (!currentImg[s]) {
		currentImg[s] = 0;
	}

  	if (currentImg[s] == imgcount[s]) currentImg[s] = 0;
  	else currentImg[s] = currentImg[s]+1;

	chng_img(s);
}

function slide_prev(s) {
	if (currentImg[s] == 0) currentImg[s] = imgcount[s];
  	else currentImg[s] = currentImg[s]-1;
	chng_img(s);
}

function chng_img(s) {
	if (initObj[s] != 0) {
		imgObj[s] = document.getElementById("slideimg_"+s);
		linkObj[s] = document.getElementById("slidelink_"+s);
		capObj[s] = document.getElementById("slide_cap_"+s);
		
		prevObj[s] = document.getElementById("slide_link_prev_"+s);
		nextObj[s] = document.getElementById("slide_link_next_"+s);
		initObj[s] = 0;
	}

	imgObj[s].src = imgsrc[s][currentImg[s]];
	imgObj[s].alt = imgcaption[s][currentImg[s]];
	imgObj[s].title = imgcaption[s][currentImg[s]];

	linkObj[s].onclick =  function () { eval("pop_"+s+"_"+currentImg[s]+"();");  return false;};

	// JG - 17/01/07 - added to enable a caption to have an associated link.
	//capObj[s].innerHTML = imgcaption[s][currentImg[s]];
	if ( imglink[s][currentImg[s]] != "&nbsp;" ) {
		capObj[s].innerHTML = "<a onfocus=\"blurLink(this);\" href=\"" + imglink[s][currentImg[s]] + "\">" + imgcaption[s][currentImg[s]] + "</a";
	} else {
		capObj[s].innerHTML = imgcaption[s][currentImg[s]];
	}
	
	if (currentImg[s] == 0) {
		prevObj[s].style.visibility = "hidden";
  	} else {
    	prevObj[s].style.visibility = "visible";
  	}

  	if (currentImg[s] == imgcount[s]) { 
    	nextObj[s].style.visibility = "hidden";
  	} else {
    	nextObj[s].style.visibility = "visible";
  	}
}


var theWindowOn; theWindowOn = false;
function slideOpenPic(img,winParams)	{
	if(theWindowOn){
		theWindow.close();
	}
	winName="slidepop";
	theWindow = window.open('',winName,winParams);
	theWindowOn = true;
	theWindow.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-GB\" lang=\"en-GB\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" /><script type=\"text/javascript\" src=\"fileadmin/templates/scripts/rightclick.js\"></script><title>Picture</title><style></style></head><body LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0><img src='/"+img+"' onclick='window.close()'></body></html>");
	theWindow.document.close();
	if (theWindow) {
		theWindow.focus();
	}
}