/*
 * Copyright (c) 2007-2008 Maximilian Antoni. All rights reserved.
 * http://www.maxantoni.de
 *
 * Arguments:
 *
 * requireFlashVersion: the required flash version
 * noFlash: 			html page to load if flash is not present or version is
 *						smaller than requireFlashVersion.
 * data: 				the movie data.
 * width: 				the width of the movie.
 * height: 				the height of the movie.
 */
function includeFlash(args) {
	var flashinstalled = 0;
	var flashversion = 0;
	if (navigator.plugins && navigator.plugins.length) {
		x = navigator.plugins["Shockwave Flash"];
		if (x) {
			flashinstalled = 2;
			if (x.description) {
				y = x.description;
				flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
		else {
			flashinstalled = 1;
		}
		if (navigator.plugins["Shockwave Flash 2.0"]) {
			flashinstalled = 2;
			flashversion = 2;
		}
	}
	else if (navigator.mimeTypes && navigator.mimeTypes.length) {
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		flashinstalled = (x && x.enabledPlugin) ? 2 : 1;
	}
	else {
		for(var i=10; i>0; i--) {
			try {
				var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
				flashversion = i;
				flashinstalled = 2;
				break;
			}
			catch(e) {
			}
		}
	}

	if (flashinstalled == 2) {
		if (flashversion >= args.requireFlashVersion) {
			document.write('<object type="application/x-shockwave-flash" data="' + args.data + '" width="' + args.width + '" height="' + args.height + '"><!--[if IE]><param name="movie" value="' + args.data + '"><![endif]--></object>');
		}
		else if(args.noFlash) {
			window.location.href = args.noFlash + "?flashversion=" + flashversion + "&required=" + args.requireFlashVersion;
		}
	}
	else if(args.noFlash) {
		window.location.href = args.noFlash;
	}

}