
var clipId = -1;

// generic configuration switcher
function setConfig(config) {
	$("#demo")[0].setConfig(getConfig(config));
}

// called when page loads
$(function() {


	flashembed("player", {
			src:'video/FlowPlayerDark.swf',
			width:'380',
			height:'250',
			bgcolor: '#000000',
			id: 'demo',
			loadEvent: 'click'
		},
		getConfig
	);

	// quick demo links
	$("#thumbs img").each(function(index) {
		var el = $(this);

		el.fadeTo(1, 0.4).filter(".selected").fadeTo(1, 1.0);

		el.hover(
			function() {
				if (!$(this).is(".selected")) $(this).fadeTo(10, 0.8);
			},
			function() {
				if (!$(this).is(".selected")) $(this).fadeTo(500, 0.4);
			}
		);


	});


});

// flowplayer dynamic configuration (beware: this function is far from nice piece of code)
function getConfig(conf) {

	var video = 'typography.mp4';
	if (conf == null) conf = {};



	var defaults = {
		autoPlay: true,
		autoBuffering: true,
		autoRewind:true,
		loop:false,
		playList: [
			{ url: 'img/splash.jpg', overlayId: 'play' },
			{ url: video,  duration: 104}
		],
		initialScale: 'scale',
		useNativeFullScreen: false,
		showFullScreenButton: false,
		showScrubber: true,
		emailPostUrl: false,
		showMenu: false,
		controlBarGloss: 'hight',
		controlBarBackgroundColor: '0x343434',
		useHwScaling:true
	};

	$.extend(defaults, conf);
	var returned = $("embed, object").length == 0 ? {config: defaults} : defaults;
	return returned;

}

