var image = new Array();

image[0] = ['images/main_image_1.jpg',''];
image[1] = ['images/main_image_2.jpg',''];
image[2] = ['images/main_image_3.jpg',''];
image[3] = ['images/main_image_4.jpg',''];
image[4] = ['images/main_image_5.jpg',''];

var j = 1;
var p = image.length

var imagePause = 2000;
var fadingDuration = 2000
var frameRate = 10;
var opacitySteps = 100;
var dir = true;
var o = fadingDuration;

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = image[i][0];
}

function playSlideshow(){
   if (document.all){
         document.images.SlideShow.filters.alpha.opacity = (o / fadingDuration * 100);	
   }
   else
      document.images.SlideShow.style.opacity = o / fadingDuration;
   
   if(o<0)
   {
	   document.images.SlideShow.src = preLoad[j].src;  
	   //document.getElementById('link').href = image[j][1];
	   o = 0;
	   dir=true;
	   j = j + 1
	   if (j > (p-1)) j=0
	   setTimeout('playSlideshow()', frameRate)
	   
   }
   else{
	if(o>fadingDuration && dir){		
	   dir = !dir;
	   setTimeout('playSlideshow()', imagePause)
	}
	else
	{
   	if(dir)
   		o=o+opacitySteps;
	else
		o=o-opacitySteps;
		
	setTimeout('playSlideshow()', frameRate)
	}
   }	
}