$(document).ready(function () {
	$("a.nobel-video").wrap('<div class="vodcontainer"></div>').before('<div class="streaming-video">Loading video...<img src="/modules/omponents/classes/admin/loading-white.gif" alt="loading" /></div><br />').prepend("download ").each(function() {
		var originalHref = $(this).attr("href");
		var regEx = new RegExp('https?:\/\/(.+)\/([^\.]+)\.(.+)','');
//		var regEx = new RegExp('(.+)\/([^\.]+)\.(.+)','');

		var serverName = 'rtmp://' + originalHref.replace(regEx, "$1");
//		var serverName = 'rtmp://tardis.gac.edu' + originalHref.replace(regEx, "$1");
		var movieName = originalHref.replace(regEx, "$2");
		var extension = originalHref.replace(regEx, "$3");

/*		Downloaded mp4's aren't recognized by Quicktime for whatever reason... so I guess we have to name it as .mov, and then tell FMS that the prefix is 'mp4:'
*/
		var fmsPrefix = extension;
		if(fmsPrefix == 'mov')
			fmsPrefix = 'mp4';
		var mySrc = '/modules/flash/flowplayer/FlowPlayerDark.swf';

		var myVideoFile = serverName + '/' + fmsPrefix + ':' + movieName + '.' + extension;
			
		$(this).append(" (" + extension + ")").parent('.vodcontainer').children('.streaming-video').text('').flashembed({src: mySrc, width: 550, height: 412, allowfullscreen: true, version: [9,114]}, {config: { autoPlay: false, autoBuffering: true, controlBarBackgroundColor:'0x333333', initialScale: 'scale', videoFile: myVideoFile}});
	});
});

