window.movingFilms = 'no';

window.currentFilms = "mB1";
window.fadingFilms = "no";

// ONLOAD SETUPS

document.observe("dom:loaded", function() {
	var newWidth = (window.numberFilms * 87) + 'px';
	$('movieRibbonBox').setStyle({ width: newWidth });
	var hideFilms = $$('.movieBig');
	hideFilms.each(function(elem) {
		elem.setStyle({ 
		zIndex: 1,
		top: '0px',
		opacity: 0.0
		});
	});
	$('mB1').setStyle({ zIndex: 5, opacity: 1.0 });
	$('mB1Overlay').setStyle({ top: '-65px' });
});


// BANNER BIG IMAGE

function movieHide(nextFlick) {
	lastFlick = window.currentFilms;
	nextOverlay = nextFlick + "Overlay";
	
	if ((nextFlick != lastFlick) && (window.fadingFilms == 'no')) {
		window.fadingFilms = 'yes';
		$(window.currentFilms).setStyle({ zIndex: 5 });
		$(nextFlick).setStyle({ zIndex: 4, opacity: 1.0, top: '0px' });
		$(nextOverlay).setStyle({ top: '0px' });
		new Effect.Parallel([
			new Effect.Move(lastFlick, { sync: true, x: 0, y: 232, mode: 'relative' }), 
			new Effect.Opacity(lastFlick, { sync: true, from: 1, to: 0 }) ], 
			{ 
			duration: 1.5,
			queue: 'end', 
			afterFinish: function() { 
				window.fadingFilms = 'no';
				window.currentFilms = nextFlick;
			}
		});
		new Effect.Move(nextOverlay, { x: 0, y: -65, queue: 'end' });
	}
}

// BANNER SLIDER

function movieSlide(direction) {
	
	var maxLeft = (window.numberFilms - 9) * -87;
	var maxRight = 0;
	var currentLeft = document.getElementById('movieRibbonBox').offsetLeft;
	
	if ((direction == 'left') && (currentLeft > maxLeft) && (window.movingFilms == 'no')) {
		window.movingFilms = 'yes';
		new Effect.Move('movieRibbonBox', { 
			x: -87, 
			transition: Effect.Transitions.sinoidal, 
			queue: 'end', 
			afterFinish: function() { 
				window.movingFilms = 'no';
			}
		});
	}
	
	if ((direction == 'right') && (currentLeft < maxRight) && (window.movingFilms == 'no')) {
		window.movingFilms = 'yes';
		new Effect.Move('movieRibbonBox', { 
			x: 87, 
			transition: Effect.Transitions.sinoidal, 
			queue: 'end', 
			afterFinish: function() { 
				window.movingFilms = 'no';
			}
		});
	}
}

// ANCIENT & VENERABLE IMAGE ROLL

function normRoll(imgname, imgsrc) {
	imgsrc = "imgNew/" + imgsrc;
	document.images[imgname].src = imgsrc;
	return true;
}

// CAPTCHA FUNCTIONALITY

function oC(whichbox) {
	if (whatsopen != "") {
		document.getElementById(whatsopen).style.backgroundPosition = "0px 0px";
	}
	document.getElementById(whichbox).style.backgroundPosition = "-50px 0px";
	whatsopen = whichbox;
	for (var i = 0; i <= howMany; i++) {
		if (currentDivs[i] == whichbox) {
			document.stuff.moo.value = currentFruits[i];
		}
	}
	document.getElementById("youselected").innerHTML = "i spy... a " + document.stuff.moo.value;
}

