/* Replacement calls. Please see documentation for more information. */

/*if(typeof sIFR == "function"){
// replaces gotham light heads for carousel
	sIFR.replaceElement(named({sSelector:".heroContent strong", sFlashSrc:"/flash/gothamlight.swf", sColor:"#FFFFFF", sLinkColor:"#000000", sBgColor:"#FFFFFF", sHoverColor:"#FFFFFF", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0", sWmode:"transparent"}));
}; */

// Create new carousel
function runCarousel() {
	hCarousel = new UI.Carousel("filmstrip");
}

Event.observe(window, "load", runCarousel);

// highlight the proper tab at the end of the slide
document.observe('carousel:scroll:ended', function(event) {
	var slideIndex = Math.round(hCarousel.currentIndex());
	if(slideIndex == 0) {
			$('btn-1').addClassName('active');
	} else if(slideIndex == 1) {
			$('btn-2').addClassName('active');
	} else if(slideIndex == 2) {
			$('btn-3').addClassName('active');
	} else if(slideIndex == 3) {
			$('btn-4').addClassName('active');
	} else if(slideIndex == 4) {
			$('btn-5').addClassName('active');
	} else if(slideIndex == 5) {
			$('btn-6').addClassName('active');
	}
	
	//starts the carousel timer
	timeCarousel(maxElements);
});

// remove the highlight at the start
document.observe('carousel:scroll:started', function(event) {
	// Decide which tab to make active based on which slide is currently being displayed (currentIndex)
	var slideIndex = Math.round(hCarousel.currentIndex());
	if(slideIndex == 0) {
			$('btn-1').removeClassName('active');
	} else if(slideIndex == 1) {
			$('btn-2').removeClassName('active');
	} else if(slideIndex == 2) {
			$('btn-3').removeClassName('active');
	} else if(slideIndex == 3) {
			$('btn-4').removeClassName('active');
	} else if(slideIndex == 4) {
			$('btn-5').removeClassName('active');
	} else if(slideIndex == 5) {
			$('btn-6').removeClassName('active');
	}
});


// event that shows/hides the carousel's previous/next buttons
Event.observe(window, 'load', function(){
        $$('#filmstrip').each(function(el){
              el.onmouseover  = function(){ this.addClassName('show-buttons'); }
              el.onmouseout  = function(){  this.removeClassName('show-buttons');  }
        });
		//starts the timer
		timeCarousel(maxElements);
    });

//activate relevant listeners
listenToCarousel($('filmstrip'));

