function iCanDoCSSAnimations() { 
	return Modernizr.csstransitions;
}

// start inview listens for animation triggers
$(function() {
	
	$('#crater-alien-scene, #crater-steam-scene, #astronaughts-scene, #cannon-scene, #rocket-scene, #springman-scene').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
		var el = $(this);
		
		// if element is now visible in the viewport
		if (isInView) {
			// check both top/bottom y axis in view?
			if (visiblePartY == 'both') {
				// set phasers to stun!
				transIn(el);
			}
		} else {
			// element has gone out of viewport, fade away.
			transOut(el);
		}
	});
    
});

//REMOVE THIS WHEN THERE'S MORE DIRECTORS

$('#directors div.odd:last').addClass('tempfix');

// select animation to transform for "In" animations
function transIn(animation) {
	animation.addClass('animating');
	
	switch(animation.attr('id')) {
		case "crater-alien-scene": doAnimationCraterAlienIn(); break;
		case "crater-steam-scene": doAnimationCraterSteamIn(); break;
		case "astronaughts-scene": doAnimationAstronaughtsIn(); break;
		case "cannon-scene": doAnimationCannonIn(); break;		
		case "rocket-scene": doAnimationRocketIn(); break;
		case "springman-scene": doAnimationSpringmanIn(); break;
		default: break;
	}
}

// select animation to transform for "Out" animations
function transOut(animation) { 
	animation.removeClass('animating');

	switch(animation.attr('id')) {
		case "crater-alien-scene": doAnimationCraterAlienOut(); break;
		case "crater-steam-scene": doAnimationCraterSteamOut(); break;
		case "astronaughts-scene": doAnimationAstronaughtsOut(); break;
		case "cannon-scene": doAnimationCannonOut(); break;		
		case "rocket-scene": doAnimationRocketOut(); break;
		case "springman-scene": doAnimationSpringmanOut(); break;
		default: break;
	}
}


/* Author: 

*/
$('.director').clickable();

/* IE */
$('.oldie .director').click(function() {
	var hash = document.location.hash;
	$(hash).show();
});

/* IE */
$('.oldie .close').click(function() {
	$(this).parent().parent().parent().hide();
});


$('a.nav').bind('click',function(event){
	var $anchor = $(this);
	$('html, body').stop().animate({
		scrollTop: $($anchor.attr('href')).offset().top + 100
	}, 1500,'easeInOutExpo');
	event.preventDefault();
});

var $window = $(window);
var windowHeight = $window.height();
var pos = $window.scrollTop();

function newPos(x, windowHeight, pos, adjuster, inertia){
	return x + "% " + (-((windowHeight + pos) - adjuster) * inertia)  + "px";
}

$window.resize(function(){Move();});	

$window.bind('scroll', function(){Move();});

var $starsBG = $('#stars');
$starsBG.css({'backgroundPosition': newPos(50, windowHeight, pos, 800, 0.6)});

function Move(){ 
	var pos = $window.scrollTop();
	$starsBG.css({'backgroundPosition': newPos(50, windowHeight, pos, 800, 0.6)});
}

if ( $('html').hasClass('audio') ) {

var directorSound = new Audio();
directorSound.src = Modernizr.audio.ogg ? 'assets/sounds/beep.ogg' : 'assets/sounds/beep.mp3';

$('.director').hover(
	function () {
    	directorSound.play();
   	}
);

}

var videoArray = [];
var directorArray = [];

$('.overlay').each(function(){
	directorArray.push('#' + $(this).attr('id'));
	videoArray.push($('.video_holder', this).html());
});

/*$('.director').bind('click', function(event){
	var directorId = $(this).find('a').attr('href');
	if($(this).parent().parent().parent().parent().parent().find(directorId).find('.inner').hasClass('played')){
		var tempNum = 0;
		var newHtml = '';
		for(i=0;i<directorArray.length;i++){
			if(directorId == directorArray[i]){
				tempNum = i;
				newHtml = videoArray[i];
			}
		}
		$(this).parent().parent().parent().parent().parent().find(directorId).find('.video_holder').html(newHtml);
	}
});*/

/*$('.close').bind('click', function(event){
	$(this).parent().find('.video_player').remove();
	$(this).parent().addClass('played');
});*/

