window.addEvent('domready', function() {
	OIIT.start();
});

var OIIT = {
carousel:"",	
	start: function(){
		if($('carousel')) OIIT.site_carousel();
	},
	
	site_carousel: function(hide_buttons){
					
		var buttons = $$('div#carousel .button');

		if(hide_buttons === true){
			buttons = '';
		}
		
		OIIT.carousel = new SimpleCarousel($('carousel'), $$('div#carousel .slide'), buttons, {
			rotateAction: 'click',
			slideInterval: 7000,
			rotateActionDuration: 700
		});
		
		$$('div#carousel .button').addEvent('click', function(event){
			event.stop();
		});
		
	}

};

function onYouTubePlayerReady(playerId) {
      ytplayer = document.getElementById("myytplayer");
      ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
      
    };

function pause() {
  if (ytplayer) {
    ytplayer.pauseVideo();
  }
}

function onytplayerStateChange(newState) {
   
   if (newState == 1 || newState == 3) {
   	OIIT.carousel.stop();
   	 
   }
}

