// Global Variables

var counter = 1;
var links = new Array();

// Alter 'picPath' to include the path only of the images
// NOTE: all images in this folder should be named image1, image2, etc
// An example of a path would be '../images/' or '../' or 'ui/graphics/'

var picPath = 'images/slideshow/';

// Alter 'extension' to select which type of picture to display
// All images must be saved with the same extension (ie. gif, jpg, png)

var extension = 'jpg';

// Alter 'timeToDiplay' to lengthen the time each picture is displayed before a blend happens
// Alter 'lengthofBlend' to lengthen the blend effect
// NOTE: 'timeToDisplay' MUST BE >= TO 'lengthOfBlend' or flicker will occur

var timeToDisplay = 2000;
var lengthOfBlend = 2000;

// Set the URL for each clickable blend image
// Make one item per each picture
// Array MUST start with links[0].

links[0] = 'portfolio/index.php?project=1';
links[1] = 'portfolio/index.php?project=1';
links[2] = 'portfolio/index.php?project=1';
links[3] = 'portfolio/index.php?project=1';
links[4] = 'portfolio/index.php?project=1';
links[5] = 'portfolio/index.php?project=1';
links[6] = 'portfolio/index.php?project=1';
links[7] = 'portfolio/index.php?project=1';
links[8] = 'portfolio/index.php?project=1';


// Function to blend the images together
// DO NOT ALTER ANY CODE BELOW THIS POINT

function blend(id, bkgrnd, opacStart, opacEnd)
{
	//speed for each frame
	var speed = Math.round(lengthOfBlend / 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++;
		}
		document.getElementById(bkgrnd).style.background='url('+picPath+'image'+counter+'.'+extension+') no-repeat';
		// document.getElementById('link').href = (links[counter-1]);

		setTimeout("blend('"+id+"', '"+bkgrnd+"', 0, 100, "+lengthOfBlend+")", lengthOfBlend);
	}
	else if(opacStart < opacEnd)
	{
		for(i = opacStart; i <= opacEnd; i++)
		{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
		document.getElementById(id).style.background='url('+picPath+'image'+counter+'.'+extension+') no-repeat';
		counter++;
		if(counter > links.length)
		{
			// counter = 1;
                   return false;
		}
		setTimeout("blend('"+id+"', '"+bkgrnd+"', 100, 0, "+lengthOfBlend+")", timeToDisplay);
	}
}

//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 + ")";
}
