function getno (imag) {
	return parseInt(imag.getAttribute("alt"));
}

function show(imag) {
	container = document.getElementById("current");
	imagine=container.getElementsByTagName("img")[0];
	path=galerie+imag+".jpg";
	imagine.setAttribute("src",path);
	imagine.setAttribute("alt",imag);
}

function next() {
	container = document.getElementById("current");
	imagine=container.getElementsByTagName("img")[0];
	nr=getno(imagine);
	if (nr>=total) {
		show(nr);
		set(next,nr);
		set(prev,nr-1);
	} 
	else {
		show(nr+1);
		set(next,nr+2);
		set(prev,nr);
	}
}

function prev() {
	container = document.getElementById("current");
	imagine=container.getElementsByTagName("img")[0];
	nr=getno(imagine);
	if (nr==1) {
		show(nr);
		set("next",nr+1);
		set("prev",nr);
	} 
	else {
		show(nr-1);
		set("next",nr);
		set("prev",nr-2);
	}
}

function set(who,what) {
	obj=document.getElementById(who);
	what="javascript:"+who+"("+what+")";
	obj.setAttribute("href",what);
}

function opn(path) {
	path='galerie/'+path;
	poza = window.open(path,"pozza","toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=520,height=370");
}