function Slide(imageFilename, delay, transitionEffectId, link, linkText)
{
   // 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;
	
	// 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*1000;};
	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.getSize=function(){return this.size;};
	this.getLink=function(){return this.link;};
	this.getLinkText=function()
	{
	  if (this.linkText=="")
	    return"";
	  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=4;
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

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();
			
			// 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("/image_slide/home1.jpg", 10, 0, 0, 0);
	slides[1]=new Slide("/image_slide/home2.jpg", 10, 0, 0, 0);
	slides[2]=new Slide("/image_slide/home3.jpg", 10, 0, 0, 0);
	slides[3]=new Slide("/image_slide/home4.jpg", 10, 0, 0, 0);
}
