// JavaScript Document

var currentPhoto = 0;
var secondPhoto = 1;

var currentOpacity = new Array();

var FADE_STEP = 4;
var FADE_INTERVAL = 200;
var pause = false;

function init() {
	currentOpacity[0]=99;
	
	for(i=1;i<15;i++)currentOpacity[i]=0;

	var thisImg = "bikeLatest_"+currentPhoto;

	if(document.all) {
		document.getElementById(thisImg).style.filter="alpha(opacity=100)";
	} else {
		document.getElementById(thisImg).style.MozOpacity = .99;
	}

	mInterval = setInterval("crossFade()",FADE_INTERVAL);
}

function crossFade() {
	var zIndexCount = 10;
	if(pause)return;
	currentOpacity[currentPhoto]-=FADE_STEP;
	currentOpacity[secondPhoto] += FADE_STEP;

	document.getElementById("bikeLatest_"+currentPhoto).style.visibility 	= "visible";
	document.getElementById("bikeLatest_"+secondPhoto).style.visibility 	= "visible";
	document.getElementById("bikeLatest_"+secondPhoto).style.zindex 		= zIndexCount;

	if(document.all) {
		document.getElementById("bikeLatest_"+currentPhoto).style.filter = "alpha(opacity=" + currentOpacity[currentPhoto] + ")";
		document.getElementById("bikeLatest_"+secondPhoto).style.filter = "alpha(opacity=" + currentOpacity[secondPhoto] + ")";
	} else {
		document.getElementById("bikeLatest_"+currentPhoto).style.MozOpacity = currentOpacity[currentPhoto]/100;
		document.getElementById("bikeLatest_"+secondPhoto).style.MozOpacity =currentOpacity[secondPhoto]/100;
	}

	if(currentOpacity[secondPhoto]/100>=.98) {
		currentPhoto = secondPhoto;
				
		secondPhoto++;
		document.getElementById("bikeLatest_"+secondPhoto).style.visibility = "hidden";
		if(secondPhoto == 10)secondPhoto=0;
		pause = true;
		xInterval = setTimeout("pause=false",2000);
	}
}

function doPause()  {
	if(pause) {
		pause = false;
	} else {
		pause = true;
	}
}