$(document).ready(f_init);

var aoAnchors = new Array();
var aoPhotos  = new Array();
var oAnc  = null;
var oImg  = null;
var nCur  = 0;

function f_init() {
	$("a.lightbox").lightBox();
	var aoButtons = document.getElementsByTagName("a");
	for(var i=0; i<aoButtons.length; i++) {
		if(aoButtons[i].getAttribute("id")!=null)
		if(aoButtons[i].getAttribute("id").substr(0, 3)=="anc") {
			var n = aoAnchors.length;
			aoAnchors[n] = aoButtons[i];
			aoAnchors[n].num     = n;
			aoAnchors[n].onclick = f_putImage;
		}
	}
	var aoImages = document.getElementsByTagName("img");
	for(var i=0; i<aoImages.length; i++) {
		if(aoImages[i].getAttribute("id")!=null)
		if(aoImages[i].getAttribute("id").substr(0, 3)=="pic") {
			var n = aoPhotos.length;
			aoPhotos[n] = aoImages[i];
			if(i>0) $(aoImages[i]).css("display", "none");
		}
	}
	oAnc = aoAnchors[0];
	oImg = aoPhotos[0];
	oAnc.setAttribute("aux", oAnc.getAttribute("href"));
	oAnc.removeAttribute("href");
	oImg.style.display = "block";
}

function f_putImage() {
	$("#pic"+nCur).fadeOut(1000, new Function("$(\"#pic"+this.num+"\").fadeIn(1000);"));
	nCur = this.num;
	oAnc.setAttribute("href", oAnc.getAttribute("aux"));
	oAnc.removeAttribute("aux");
	oAnc = aoAnchors[nCur];
	oAnc.setAttribute("aux", oAnc.getAttribute("href"));
	oAnc.removeAttribute("href");
	//oImg.style.display = "none";
	//oImg = aoPhotos[nCur];
	//oImg.style.display = "block";
	return false;
}