var movieWidth = 320;
var movieHeight = 240;

function video(flvPath, JPG, smallJPG, caption){
	this.flvPath = flvPath;
	this.JPG = JPG;
	this.smallJPG = smallJPG;
	this.caption = caption;
}
function chooser(epi) {
	jQuery('#player').flash(
		{
			src: '/common/mediaplayer.swf',
			width: movieWidth,
			height: movieHeight,
			id: 'mpl',
			name: 'mpl',
			allowscriptaccess: 'always',
			allowfullscreen: 'true',
			wmode: 'transparent',
			flashvars: {
				width: movieWidth,
				height: movieHeight,
				file: videos[epi].flvPath,
				image: videos[epi].JPG,
				shuffle: false,
				autostart: true,
				enablejs: true
			}
		},
		{ version: 8 }
	);
}
jQuery(
	function(){
		jQuery('#movie-selector form').append('<select name="archive" id="archive"></select>');
		for ( var i = 0; i < videos.length; i++ ) {
			jQuery('#archive').append('<option value="' + i + '">' + videos[i].caption + '</option>');
		}
		chooser(jQuery('#archive > option:first').val());
		jQuery('#archive').change(
			function(){
				jQuery('#archive > option:selected').each(
					function () {
						jQuery('#player').children().remove();
						chooser(jQuery(this).val());
					}
				);
			}
		);
	}
);
