var slides = new Array();
var activeSshow = -1;
var activeSlide = new Array();

function slide(showId, dir) {  // slide
	if(dir>0) {  // next
		if(activeSlide[showId] < slides[showId].length) showSlide(showId, activeSlide[showId]+dir);
	}
	else {  // prev
		if(activeSlide[showId]) showSlide(showId, activeSlide[showId]+dir);
	}
}

function showSlide(showId, slideId) {  // display a slide
	if(!slides.length || !slides[showId] || !slides[showId].length) return;
	activeSshow = showId;
	activeSlide[showId] = slideId;
	setSlidebuttons(showId);
	for(var i=0; i<slides[showId].length; i++) {
		thisSlide = slides[showId][i];
		if(activeSlide[showId] == i) {
			document.getElementById('slide'+thisSlide).style.display = 'block';
		}
		else {
			document.getElementById('slide'+thisSlide).style.display = 'none';
		}			
	}
}

function setSlidebuttons(showId, demo) {  // display slidebuttons
	sButtons = '<table class="slideButtons"><tr>';
	sButtonPrev = '<a href="javascript:slide('+showId+',-1)"><img name="slideButtonPrevImg" src="'+docPath+'imgref/N_slide_prev_dark.gif/$FILE/slide_prev_dark.gif" alt="&lt;&lt;" width="23" height="23" border="0"></a>';
	sButtonNext = '<a href="javascript:slide('+showId+',1) "><img name="slideButtonNextImg" src="'+docPath+'imgref/N_slide_next_dark.gif/$FILE/slide_next_dark.gif" alt="&gt;&gt;" width="23" height="23" border="0"></a>';

	if(demo) {
		sButtons += '<td><img name="slideButtonPrevImg" src="'+docPath+'imgref/N_slide_prev_dark.gif/$FILE/slide_prev_dark.gif" alt="&lt;&lt;" width="23" height="23" border="0"></td>';
		sButtons += '<td class="slideIndexActive">X&nbsp;/&nbsp;Y</td>';
		sButtons += '<td><img name="slideButtonNextImg" src="'+docPath+'imgref/N_slide_next_dark.gif/$FILE/slide_next_dark.gif" alt="&gt;&gt;" width="23" height="23" border="0"></td>';
	}
	else {	
		if(!slides[showId] || slides[showId].length < 2) document.getElementById('slidebuttons'+showId).style.display = 'none';
		else document.getElementById('slidebuttons'+showId).style.display = 'block';
		if(activeSlide[showId] == 0) sButtons += '<td><img src="/icons/ecblank.gif" width="23" height="23"></td>';
		else sButtons += '<td>'+sButtonPrev+'</td>';
		sButtons += '<td class="slideIndexActive">'+(activeSlide[showId]+1)+'&nbsp;/&nbsp;'+slides[showId].length+'</td>';
		if(activeSlide[showId] < slides[showId].length-1) sButtons += '<td>'+sButtonNext+'</td>';
		else sButtons += '<td><img src="/icons/ecblank.gif" width="23" height="23"></td>';
	}
	sButtons += '</tr></table>';
	document.getElementById('slidebuttons'+showId).innerHTML = sButtons;
}

