// slideshow, image swap and nav function used by all photo tour galleries


function swap(imgIndex) {
	document['imgMain'].src = aryImages[imgIndex];
	TheText = blurb[imgIndex];
	document.getElementById('blurbarea').innerHTML=TheText;
	thisImage=imgIndex;
	getButtons(aryImages.length);
}

function getButtons(aryLength){
	var ePrevImage = document.getElementById('prev_image');
	var eNextImage = document.getElementById('next_image');
	var idxPrev = parseInt(thisImage) -1;
	var idxNext = parseInt(thisImage) +1;
	
	if(idxPrev < 0){
		ePrevImage.innerHTML = '&nbsp;';
		}
	else {
		ePrevImage.innerHTML = '<a href="javascript:swap(' + idxPrev + ');" onMouseOver="showStatus(' + idxPrev + '); return true;" onMouseOut="clearStatus(); return true;"><img src="/img/shared/but_leftarrow.gif" border="0" alt="Previous Image" /></a>';
		}
		
	if(idxNext >= aryLength){
		eNextImage.innerHTML = '&nbsp;';
		}
	else {
		eNextImage.innerHTML = 	'<a href="javascript:swap(' + idxNext + ');" onMouseOver="showStatus(' + idxNext + '); return true;" onMouseOut="clearStatus(); return true;"><img src="/img/shared/but_rightarrow.gif" border="0" alt="Next Image" /></a>';
		}	

	}

function showStatus(idx){
	window.status=blurb[idx];
	}

function clearStatus(){
	window.status = "";
	}


var t;
var i = 0;
var p = aryImages.length;

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 3500;

// Duration of crossfade (seconds)
var crossFadeDuration = 4;

// switch used to stop slide show
var stopShow = 0;

function runSlideShow(){
	if(stopShow==0){
		doSlideShow();
	}
}

function doSlideShow(){
	stopShow=0;
   if (document.all){
	  showLink('on');
      document['imgMain'].style.filter="blendTrans(duration=2)";
      document['imgMain'].style.filter="blendTrans(duration=crossFadeDuration)";
      document['imgMain'].filters.blendTrans.Apply();    
   }

   document['imgMain'].src = aryImages[i];
   TheText = blurb[i];
	
   if (document.all){
	  document['imgMain'].filters.blendTrans.play();
	  document.getElementById('blurbarea').innerHTML = TheText;
   }   
   
   i = i + 1;
   if (i > (p-1)) i=0;
   t = setTimeout('runSlideShow()', slideShowSpeed);
}

function stopSlideShow(){
	showLink('off');
	document['imgMain'].filters.blendTrans.stop();
	stopShow=1;
	}

function showLink(toggle){
	var eSlideShow = document.getElementById('slideshow');
	if(toggle == 'off'){
		var eSlideShow = document.getElementById('slideshow');
		eSlideShow.innerHTML= '<a href="javascript:stopShow=0;runSlideShow();" style="text-decoration: none; font-size: 11px;">View Slide Show</a>';
		}
	if(toggle == 'on'){
		eSlideShow.innerHTML= '<a href="javascript:stopSlideShow();" style="text-decoration: none; font-size: 11px;">Stop Slide Show</a>';
		}
	}

