// JavaScript Document
var curImage=0;
var timerid=0;
function swapPicture(way, timeoutID)
{
  if (document.images)
  {
    var nextImage=curImage+way;
    if (nextImage>=numImages)
      nextImage=0;
	if (nextImage<0)
      nextImage=numImages-1;  
    if (dimages[nextImage] && dimages[nextImage].complete)
    {
      var target=0;
      if (document.images.myImage)
        target=document.images.myImage;
      if (document.all && document.getElementById("myImage"))
        target=document.getElementById("myImage");
  
      // make sure target is valid.  It might not be valid
      //   if the page has not finished loading
      if (target)
      {	
	    changeOpac(0, "myImage");
        target.src=dimages[nextImage].src;
		// add something like this in for different links. var href = dhref[nextImage]; 
        curImage=nextImage;
		opacity("myImage",0, 100, 1000);
      }
	  timerid = setTimeout("swapPicture(1, timerid)", 5500);
	  return timerid;
    }
  } 
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}
