//Slideshow
// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully

// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = NewImg.length
var go = 0

var preLoad = new Array()
for (var i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = NewImg[i]

}

 function fShowDivSlide(boxid) {
   document.getElementById(boxid).className="slideshow";
}

function fHideDivSlide(boxid) {
   document.getElementById(boxid).className="hide";
}

function startSlideshow()
{
	go = 1
	fHideDivSlide('startSlideshow')
	fShowDivSlide('stopSlideshow')
	runSlideShow()
}

function stopSlideshow()
{
	go = 0
	fShowDivSlide('startSlideshow')
	fHideDivSlide('stopSlideshow')
	//runSlideShow()
}

function runSlideShow(){
   if (go==1)
   {
	   if (document.all){
		  document.getElementById('showphoto').style.filter="blendTrans(duration=2)"
	      document.getElementById('showphoto').style.filter="blendTrans(duration=crossFadeDuration)"
		  document.getElementById('showphoto').filters.blendTrans.Apply()      
	   }
	   document.getElementById('showphoto').src = preLoad[j].src
	   if (document.all){
		  document.getElementById('showphoto').filters.blendTrans.Play()
	   }
	   j = j + 1
	   if (j > (p-1)) j=0
	   t = setTimeout('runSlideShow()', slideShowSpeed)
   }
   else
   {
	   t = ""
   }
}

function chgImg(direction) 
	{
				ImgNum = ImgNum + direction;

				if (ImgNum > ImgLength) 
					{
						ImgNum = 0;
					}
				if (ImgNum < 0) 
					{
						ImgNum = ImgLength;
					}
				   if (document.all){
					  document.getElementById('showphoto').style.filter="blendTrans(duration=2)"
				      document.getElementById('showphoto').style.filter="blendTrans(duration=crossFadeDuration)"
					  document.getElementById('showphoto').filters.blendTrans.Apply()      
				   }     
		
					document.getElementById('showphoto').src = preLoad[ImgNum].src
				   if (document.all){
					  document.getElementById('showphoto').filters.blendTrans.Play()
				   }
	}

// AddLoadEvents
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

// Image Gallery
function swapImage(whichpic) {
	if (!document.getElementById) return true;
	document.getElementById('showphoto').src = whichpic.href;
	return false;
}
function swapImageBehaviour() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById("extraPhotos")) return false;
	var gallery = document.getElementById("extraPhotos");
	var links = gallery.getElementsByTagName("a");
	for ( var i=0; i < links.length; i++) {
		links[i].onclick = function() {
			return swapImage(this);
		}
	}
	return false;
}
addLoadEvent(swapImageBehaviour);
