

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000;

// Duration of crossfade (seconds)
var crossFadeDuration = 3;

// Specify the image files
var Slide = new Array();
var Icon = new Array();
var Link = new Array();

// to add more images, just continue
// the pattern, adding to the array below
Slide[0] = "images/coma.jpg";
Slide[1] = "images/pro1.jpg";
Slide[2] = "images/pro3.jpg";


Link[0] = "company.asp";
Link[1] = "product.asp";
Link[2] = "product.asp";


Icon[0] = "images/slideshow_off.gif";
Icon[1] = "images/slideshow_on.gif";

var t;
var j = 0;
var p = Slide.length;
var q = Icon.length;
var isActive = true;

// Define and pre-load the slide show images ...
var preLoadSlide = new Array();
for (i = 0; i < p; i++) {
   preLoadSlide[i] = new Image();
   preLoadSlide[i].src = Slide[i];
}

// Define and pre-load the slide show indicator images ...
var preLoadIcon = new Array();
for (i = 0; i < q; i++){
   preLoadIcon[i] = new Image();
   preLoadIcon[i].src = Icon[i];
}

// Displays the image with a cross-fade effect under IE6. Effect
// degrads gracefully for browsers that don't support it.
function displaySlideShowImage(whichImage) {
	if (document.all) {
		document.images.SlideShow.style.filter="blendTrans(duration=2)";
		document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
		document.images.SlideShow.filters.blendTrans.Apply();
	}

	// Deactive the old idicator icon ...
	for (i = 0; i < p; i++) {
		whichIcon = "slide" + (i + 1);
		document.images[whichIcon].src = preLoadIcon[0].src;
	}

	// Active the current indicator icon ...
	whichIcon = "slide" + (whichImage + 1);
	document.images[whichIcon].src = preLoadIcon[1].src;

	// Display the new slideshow image ...
	document.images.SlideShow.src = preLoadSlide[whichImage].src;

	if (document.all){
		document.images.SlideShow.filters.blendTrans.Play();
	}
}

function displayLink() {
	whichLink = Link[j];
	linkWindow = window.open(whichLink, "link_window");
}

// Advances the slideshow one frame foward. The automated rotation
// is stopped if the action is triggered manually.
function slideShowNext(manual) {
	if (manual) isActive = false;
	j = j + 1;
	if (j > (p - 1)) j = 0;
	displaySlideShowImage(j);
}

// Rolls the slideshow one frame backward. The automated rotation
// is stopped if the action is triggered manually.
function slideShowPrevious(manual) {
	if (manual) isActive = false;
	j = j - 1;
	if (j < 0) j = (p - 1);
	displaySlideShowImage(j);
}

// The timer that drives the automated rotation of images.
function runSlideShow() {
	t = setTimeout('advanceSlideShow()', slideShowSpeed);
}

// Automatically advance the slideshow forward until the user
// iteracts with the elements.
function advanceSlideShow() {
	if (isActive) {
		slideShowNext(false);
		runSlideShow();
	}
}
