// JavaScript Document


start = true;
opacityA = 1.0;
opacityB = 0.0;
counter = 0;
counterB = 1;
counterP = 0;
INCREMENT = 0.02; // controls shift
TIME = 40;        // controls hold

function slideShow() {
	projectorA = document.getElementById('showA');
	projectorB = document.getElementById('showB');
	slideA = document.getElementById('sliderA');
	slideB = document.getElementById('sliderB');

	if (counterB > 0) {
		counter++;
		if (counter >= TIME) {
			counter = TIME;
			opacityA -= INCREMENT;
			opacityA = parseFloat(opacityA.toFixed(2));
			opacityB += INCREMENT;
			opacityB = parseFloat(opacityB.toFixed(2));
			if (opacityA <= 0) {
				counterB *= -1;
				counterP ++;
				slideA.setAttribute('style', 'bottom:' + (counterP * 333 % 1665) + 'px;');
			}
		}
	} else {
		counter--;
		if (counter <= 0) {
			counter = 0;
			opacityA += INCREMENT;
			opacityA = parseFloat(opacityA.toFixed(2));
			opacityB -= INCREMENT;
			opacityB = parseFloat(opacityB.toFixed(2));
			if (opacityA >= 1) {
				counterB *= -1;
				slideB.setAttribute('style', 'bottom:' + (counterP * 333 % 1665) + 'px;');
			}
		}
	}
	projectorA.setAttribute('style','opacity:' + opacityA + '; filter:alpha(opacity=' + (opacityA * 100) + ');');
	projectorB.setAttribute('style','opacity:' + opacityB + '; filter:alpha(opacity=' + (opacityB * 100) + ');');
	// opacity: 0.55;
	// filter: alpha(opacity=55);
}

function speed() {
	window.setInterval( function() {slideShow();}, 50 );
}

window.onload = function start() {
    speed();
}
