$(document).ready(function(){
	
	
	$('.play_video').click(function(){
			var video = $(this).attr('href');
			video = video.replace('.mp4', ''); //Remove extension as we'll add it in on the append for either mp4 or ogg
			var flash_video = video.slice(video.lastIndexOf('/')+1);
			$('#tba_playlist').hide();
			$('#video').show()
			.html('<video autoplay="true" width="708" height="322" controls="controls"><source src="'+video+'.mp4" type="video/mp4" /><source src="'+video+'.ogg" type="video/ogg" /><embed flashvars="file=../videos/'+flash_video+'.flv&autostart=true&skin=/flash/glow.zip&controlbar.position=over" allowfullscreen="true" wmode="opaque" allowscripaccess="always" id="player1" name="player1" src="/flash/player.swf" width="708" height="322"/></video>')
			.append('<li><a id="close-button" href="#">Close Video</a></li>');
			return false; //disable the link
		});

		$('#video').delegate('#close-button', 'click', function(){
			$('#video').empty().hide();
			$(this).remove();
			$('#tba_playlist').show();
			return false;
		});
		
	$('ul.pro_links li').hover(function(){
		$('#'+$(this).attr('id')+'_info').show();
	}, function(){
		$('#'+$(this).attr('id')+'_info').hide();
	});
	
	$('#tba_hero_banner .tba_tag', this).each(function(index){
		var tag_width = $(this).width(),
			this_tag = $(this);
		this_tag.css('left', '-'+tag_width+'px');
		this_tag.css('visibility', 'visible');
		
		setTimeout(function(){
			this_tag.animate({left: '0px'}, 1000, 'easeOutExpo');
		},index*200);  
	});
	
	$('#tba_hero_text').delay(500).fadeIn(2000);
	
	function _rotate_hero(){
		var this_hero = $('#tba_hero_banner .tba_hero').first().css({'right': '-50px', 'display':'block'});
			this_hero.animate({right: '0px', opacity: '1'}, 2000);
			
			setTimeout(function(){
				this_hero.animate({opacity: '0'}, 2000, function(){
					this_hero.clone().appendTo('#tba_hero_banner');
					this_hero.remove();
					_rotate_hero();
				});
			}, 5000);
			
	}
	
	_rotate_hero();
});
