
function Slide(imageFilename, delay, transitionEffectId, link, linkText, alt)
{
   // properties:
	this.image=new Image();
	this.image.src=imageFilename;
	this.delay=delay;
	if (transitionEffectId==-1)
		this.transition=-1;
	if (transitionEffectId==-2)
		this.transition=-2;
	else if (transitionEffectId>=0 && transitionEffectId<Slide.prototype.numFilters)
  	   this.transition=Slide.prototype.filters[transitionEffectId];
	this.link=link;
	this.linkText=linkText;
	this.image.alt=alt;

	
	// functions to 
	this.isReady=function(){return this.image.complete;};
	// returns the current filter and rotates filter 
	this.getFilter=function()
	{
	  // -1 indicates no filter
 	  if (this.transition==-1)
 	  	return 0;
	  //  -2 indicates use any
	  if (this.transition && this.transition!=-2)
  	    return this.transition;
	  Slide.prototype.currentFilter++;
	  if (Slide.prototype.currentFilter>Slide.prototype.numFilters)
		 Slide.prototype.currentFilter=0;
	  return Slide.prototype.filters[Slide.prototype.currentFilter];
	};
	// returns the number of miliseconds of the delay value specified
	this.getDelay=function(){return this.delay*2000;};
	this.getImage=function(){return this.image;};
	this.getImageWidth=function(){return this.image.width;};
	this.getImageHeight=function(){return this.image.height;};
	this.getImageSrc=function(){return this.image.src;};
	this.getImageAlt=function(){return this.image.alt;};
	this.getSize=function(){return this.size;};
	this.getLink=function(){return this.link;};
	this.getLinkText=function()
	{
	  if (this.linkText=="")
	    return"&nbsp;";
	  return this.linkText;
	};
   // increment counter (counts how many slides there are)
	Slide.prototype.size++;	   
}

//**********************************
// When user click the link, this will opens a new window to 
// display the content of linked page
//**********************************
function openLink()
{
	var link=slides[curImage].getLink();
	if (link!=0)
	{
       window.open(link);
	}
}

// Static method.  It increments static variables "numFilters" and stores filters in "filters" static array
Slide.prototype.addFilter=function(filter){Slide.prototype.filters[Slide.prototype.numFilters++]=filter};
// how fast or slow the transition animation will play (in seconds)
var transitionSpeed=2;
var slides=new Array();
var curImage=-1;
// NO NEED TO CHANGE THIS PORTION
Slide.prototype.transitionSpeed=transitionSpeed;				// seconds
Slide.prototype.size=0;
Slide.prototype.numFilters=0;
Slide.prototype.currentFilter=0;
Slide.prototype.filters=new Array();
//********************************************
// LIST OF TRANSITIONS
// you may take out the ones you don't want to use or add more.
//*******************************************
Slide.prototype.addFilter("blendTrans(duration="+transitionSpeed+");");					  // 0 fade
Slide.prototype.addFilter("revealTrans(transition=5, duration="+transitionSpeed+");");  // 1 wipe down
Slide.prototype.addFilter("revealTrans(transition=0, duration="+transitionSpeed+");");  // 2 
Slide.prototype.addFilter("revealTrans(transition=1, duration="+transitionSpeed+");");  // 3
Slide.prototype.addFilter("revealTrans(transition=2, duration="+transitionSpeed+");");  // 4
Slide.prototype.addFilter("revealTrans(transition=3, duration="+transitionSpeed+");");  // 5
Slide.prototype.addFilter("revealTrans(transition=10, duration="+transitionSpeed+");"); // 6
Slide.prototype.addFilter("revealTrans(transition=11, duration="+transitionSpeed+");"); // 7
Slide.prototype.addFilter("revealTrans(transition=12, duration="+transitionSpeed+");"); // 8
Slide.prototype.addFilter("revealTrans(transition=4, duration="+transitionSpeed+");");  // 9
Slide.prototype.addFilter("revealTrans(transition=20, duration="+transitionSpeed+");"); // 10
Slide.prototype.addFilter("revealTrans(transition=14, duration="+transitionSpeed+");"); // 11

//*******************************************
// This function is the core of this application.
// It swaps the image contained in "myImage" object.
// You should therefore declare your image on the page like this:
// <IMG ID="myImage" width="0" height="0" src=""> so that 
// the first image will not be displayed.
// If you wish to set an initial image, you can use
// <IMG ID="myImage" src=imageName>.
//
// Calling method: uses "setTimeout()" to call itself
// periodically depending on
// the delay value specified on each picture.
// If the picture to be displayed has not been loaded yet,
// the function will call itself every 0.5 seconds
// until the picture is loaded.  
//********************************************
function slidePicture()
{
 	if (document.images)
	{
		var oldCurImage=curImage;
		curImage++;
		if (curImage>=slides[0].getSize())
			curImage=0;
	
		var canBeFiltered=false;
		if (document.images.myImage)// && 
		{
  		   target=document.images.myImage;
  		   if (document.images.myImage.style)// && document.images.myImage.style.filters)
  		   {
			  canBeFiltered=true;
			}
		}
		if (document.all && document.getElementById("myImage"))
		{
			target= document.getElementById("myImage");
			// If the browser doesn't support "style" or
			// if user specified filter value of 0, then do not use filter
			if (target.style && slides[curImage].getFilter()!=0)
				canBeFiltered=true;
		}
		
       // 	Check if the next image is loaded yet.
       // Note here, if you put an invalid filename on
       // your list, the slide might get stuck here,
       // So make sure all the image filenames are
       // correct.
		if (slides[curImage].isReady())
		{
			if (canBeFiltered)
			{
      			target.style.filter=slides[curImage].getFilter();
      			if (target.filters && target.filters[0])
      			{
		       	target.filters[0].Apply();
		       }
 	       }
 	       
			target.src=slides[curImage].getImageSrc();
			// netscape 4.8 doesn support these, so you might want to use
			// same sized image if you want it to look nice on that browser
			target.height=slides[curImage].getImageHeight();
			target.width=slides[curImage].getImageWidth();
			target.alt=slides[curImage].getImageAlt();
			
			// chane link text
			if (document.getElementById && document.getElementById("myImageLink"))
 				document.getElementById("myImageLink").innerHTML=slides[curImage].getLinkText();
 				
			if (canBeFiltered)
			{
			   	if (target.filters && target.filters[0])
			   	{
	  		      	target.filters[0].Play();
	  		    }
			}
			// This basically says:
			// Execute this function again after showing
			// the image for the time specified in the delay.
			setTimeout("slidePicture()", slides[curImage].getDelay());
		}	
		// Next image is not loaded yet, restore counter
		// and check back in 500 miliseconds
		else
		{
			curImage=oldCurImage;
			setTimeout("slidePicture()", 500);
			
		}
	}
}

function preloadPictures()
{
	slides[0]=new Slide("images/banner/animasi01.jpg", 5, -2, 0, 0, "Pro Dive Bali");
	slides[1]=new Slide("images/banner/animasi02.jpg", 5, -2, 0, 0, "Diving Cruise");
	slides[2]=new Slide("images/banner/animasi03.jpg", 5, -2, 0, 0, "Bali Adventure");
	slides[3]=new Slide("images/banner/animasi10.jpg", 5, -2, 0, 0, "Indonesia Adventure");
	slides[4]=new Slide("images/banner/animasi05.jpg", 5, -2, 0, 0, "Dive Cruise");
	slides[5]=new Slide("images/banner/animasi06.jpg", 5, -2, 0, 0, "Dive Site");
	slides[6]=new Slide("images/banner/animasi09.jpg", 5, -2, 0, 0, "Holiday in Bali");
	slides[7]=new Slide("images/banner/animasi08.jpg", 5, -2, 0, 0, "Dive Safari");
	
}

// Lihat konfigurasi dibawah edit by Anom Mahendra
//*********************************
//function preloadPictures()
//{
//  slides[0]=new Slide("images/image1.jpg", //imageFilename
//     5,                                    //delayInSeconds
//     0,                                    //transitionEffectId
//     "http://www.permadi.com",             //linkURL
//     "Slide 1 - Visit permadi.com."		 //textBelowImage
//	   "Go to Permadi.com");      			 //Image Description

//  slides[1]=new Slide("images/image2.jpg", 
//     5, 
//     1, 
//     0,                                    //linkURL (0 means no link)
//     "Slide 2"
//	   "Description");      			 //Image Description

//  slides[2]=new Slide("images/image3.jpg", 
//     5, 
//     -1,                                   //transitionEffectId -1 means none
//     "http://www.permadi.com/coky/", 
//     "Slide 3 - A dog from space..click here for info"
//	   "Description");      			 //Image Description

//  slides[3]=new Slide("images/image4.jpg", 
//     5, 
//     -2,                                   //transitionEffectId -2 means select any
//     "http://www.permadi.com/poster/swordsmen.html", 
//     "Slide 4 - Swordsman"
//	   "Description");      			 //Image Description

//}



