$(document).ready(function() {
	$('#carousel li img').css('cursor', 'pointer');

	$('#carousel li img').click(function(){
		var id = $(this).attr('id').replace('video_', '');
		var filename = $(this).attr('title');
		var splash = $(this).attr('src');
		var text = $(this).attr("rel");
		open_video(id, filename, splash, text, 500, 378);
		return false;
  });

	//Call First Video
	$("#carousel li:first img").click();
});

function open_video(id, filename, splash, text, width, height){
	$("#reel .content_cms").html(text);
	$('#video').flashembed({
	    src: '/swf/player.swf',
	    width: width, 
	    height: height
	  },{
	    config: {
	      videoFile: '/uploads/videos/'+id+'/'+filename,
	      splashImageFile: splash.replace('thumb_', 'big_'),
	      controlBarBackground: 0x000000,
	      initialScale: 'fill',
	      initialVolumePercentage: 100,
	      loop: false,
	      menuItems: [true, true, true, true, true, false],
	      autoPlay: true,
	      autoBuffering: true
	    }
	});
}
