ciao ho un codice javascript con una funzione che viene chiamata al click di un pulsante per avanzare e scorrere la fotografia successiva in una galleria,
qui
onclick="shutterReloaded.make('+prev+');return false"

per ora mi fa scorrere tutte le gallerie in successione io vorrei che in base al link premuto si fermasse alla fine della galleria di appartenenza del link

ho recuperato il numero dell'ultima foto per ciascuna galleria quindi cambio la variabile qui: per ig metto il numero dell'ultima fotografia

if ( shutterLinks[ln].num != -1 && shutterLinks[ln].num < ig ) {

next = shutterSets[shutterLinks[ln].set][shutterLinks[ln].num];
nextlink =

solo che i vari ig li so recuperare e quindi commentando e scommentando il codice mi funzionano ad uno ad uno non mi so recuperare il numero della foto cliccata

il problema è sulla a
così come la individuo non va non corrisponde alla foto cliccata,
non è che mi date una mano forse aggiungendo un parametro??grazie dell'aiuto

a=shutterSets[shutterLinks[ln].set][shutterLinks[ln].num - 1];

if(document.getElementById('ig1')){
ig1=document.getElementById('ig1').value;
igx1=document.getElementById('ig1').value;

if(a>=igx1 && a<igx2){
ig=igx2;
}


codice:
make : function(ln,fs) {
		var t = this, prev, next, prevlink = '', nextlink = '', previmg, nextimg, D, S, W, fsarg = -1, imgNum, NavBar, prevalt = '', nextalt = '';

		if ( ! t.Top ) {
			if ( typeof window.pageYOffset != 'undefined' ) t.Top = window.pageYOffset;
			else t.Top = (document.documentElement.scrollTop > 0) ? document.documentElement.scrollTop : document.body.scrollTop;
		}

		if ( typeof t.pgHeight == 'undefined' )
			t.pgHeight = Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);

		if ( fs ) t.FS = ( fs > 0 ) ? 1 : 0;
		else t.FS = shutterSettings.FS || 0;

		if ( t.resizing ) t.resizing = null;
		window.onresize = new Function('shutterReloaded.resize("'+ln+'");');

		document.documentElement.style.overflowX = 'hidden';
		if ( ! t.VP ) {
			t._viewPort();
			t.VP = true;
		}

		if ( ! (S = t.I('shShutter')) ) {
			S = document.createElement('div');
			S.setAttribute('id','shShutter');
			document.getElementsByTagName('body')[0].appendChild(S);
			t.hideTags();
		}

		if ( ! (D = t.I('shDisplay')) ) {
			D = document.createElement('div');
			D.setAttribute('id','shDisplay');
			D.style.top = t.Top + 'px';
			document.getElementsByTagName('body')[0].appendChild(D);
		}

		S.style.height = t.pgHeight + 'px';

		var dv = t.textBtns ? ' | ' : '';
		if ( shutterLinks[ln].num > 1 ) {
			prev = shutterSets[shutterLinks[ln].set][shutterLinks[ln].num - 2];
			prevlink = ''+dv;
			previmg = new Image();
			previmg.src = shutterLinks[prev].link;
                        prevalt=shutterLinks[prev].alt;

		} else {
			prevlink = '';
		}

                if(!document.getElementById('ig1')){
                     ig=shutterSets[shutterLinks[ln].set].length;
                }else{

                    a=shutterSets[shutterLinks[ln].set][shutterLinks[ln].num - 1];

                     if(document.getElementById('ig1')){
                         ig1=document.getElementById('ig1').value;
                         igx1=document.getElementById('ig1').value;

                         if(a>=igx1 && a<igx2){
                            ig=igx2;
                         }

                     }

                     if(document.getElementById('ig2')){
                         ig1=document.getElementById('ig2').value;
                         igx2=parseInt(igx1)+parseInt(document.getElementById('ig2').value);

                         
                          if(a>0 && a<igx1){
                            ig=igx1;
                         }
                     }




                }
               

//		if ( shutterLinks[ln].num != -1 && shutterLinks[ln].num < (shutterSets[shutterLinks[ln].set].length) ) {

                if ( shutterLinks[ln].num != -1 && shutterLinks[ln].num < ig ) {
                        
                        



			next = shutterSets[shutterLinks[ln].set][shutterLinks[ln].num];
			nextlink = ''+dv;
			nextimg = new Image();
			nextimg.src = shutterLinks[next].link;
//                       nextalt=shutterSets[shutterLinks[ln].set][shutterLinks[ln].num].alt;

		} else {
			nextlink = '';
		}

		imgNum = ( (shutterLinks[ln].num > 0) && t.imageCount ) ? '<div id="shCount">(' + shutterLinks[ln].num + '/' + shutterSets[shutterLinks[ln].set].length + ')</div>' : '';




		NavBar = '<div class="close"></div><div id="shTitle"><div id="shPrev">' + prevlink + '</div><div id="shNext">' + nextlink + '</div><div id="shName">' + shutterLinks[ln].title + '</div>' + imgNum + '</div>';

                

		D.innerHTML = '<div id="shWrap">[img][/img]' + NavBar +'</div>';
		
		//Google Chrome 4.0.249.78 bug for onload attribute
		document.getElementById('shTopImg').src = shutterLinks[ln].link;
		
		window.setTimeout(function(){shutterReloaded.loading();},2000);
	},