(function($) {
	$(document).ready(function() {

        	function getFlashVersion() {
        		var version = '0,0,0';
                	try {
                    		try { 
                        		var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
                        		try { 
                        			axo.AllowScriptAccess = 'always'; 
                        		}
                        		catch (e) { 
                        			version = '6,0,0'; 
                        		}
                    		} 
                    		catch (e) { 
                    		}
                    		version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
                	} 
                	catch (e) {
                    		try {
                        		if (navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
                            			version = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
                        		}
                    		} 
                    		catch (e) {
                    		}
                	}
                	return version.split(',').shift();
            	}
	
		$('.flashLink').click(function() {
			return false;
		})
		.dialog({
			lang: {
				header: 'Video Player'
			},
			onContentLoad: function(obj, dialog) {
				if (getFlashVersion() >= 10) { 
					dialog.css({ 'height' : '337px' }).parent().css({ 'width' : '514px' });
					var tag = $(obj);
					var href = tag.attr('href');
					var loading = $(document.createElement('div')).addClass('sys_loading').text('Processing... Please wait.');
					var dlg = dialog.append(loading);

					if ($.browser.msie) {
						str = '<object data="' + href + '" type="application/x-shockwave-flash" width="514" height="332">';
						str += '<param name="movie" value="' + href + '" />';
						str += '</object>';
						dialog.html(str);
					} else {
						var flash_player = $(document.createElement('object')).attr({
							'data': href,
							'height': '332',
							'type': 'application/x-shockwave-flash',
							'width': '514'
						}).append(
							$(document.createElement('param')).attr({
								'name': 'movie',
								'value': href
							})
						);
						dialog.append(flash_player)	
						loading.remove();
					}
				} else {
					dialog.append('<p>This video requires a new version of the Adobe Flash player to function correctly.</p><p>Please visit the <a href="http://get.adobe.com/flashplayer" title="Download the latest version of the Adobe Flash player">Adobe Website</a> to update your software to the latest version.</p>');
				}	
			}
		});
	});
})(jQuery);	