/**
 * flashembed 0.26. Adobe Flash embedding script
 * 
 * http://flowplayer.org/player/flash-embed.html
 *
 * Copyright (c) 2008 Tero Piirainen (tero@flowplayer.org)
 *
 * Released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * = Basically you can do anything but leave this header as is
 *
 * Version: 0.10 - 03/11/2008
 * Version: 0.20 - 03/20/2008
 * Version: 0.25 - 03/29/2008
 * Version: 0.26 - 04/06/2008
 */
function flashembed(g,h,j){
	if(typeof g=='string')
		g=document.getElementById(g);
	var k={src:'#',width:320,height:240,version:null,loadEvent:null,onFail:null,expressInstall:null,allowfullscreen:true,allowscriptaccess:'always',quality:'high',bgcolor:'#ffffff',type:'application/x-shockwave-flash',pluginspage:'http://www.adobe.com/go/getflashplayer'};
	extend(k,h);
	var l=k.loadEvent;
	k.loadEvent=null;

	if(l){
		g['on'+l]=function(){
			load()
		}
	}else{
		load()
	}

	function extend(a,b){
		if(b){
			for(key in b){
				a[key]=b[key]
			}
		}
	}

	var m=k.id;

	function load(){
		var a=getVersion();
		var b=k.version;
		var c=k.expressInstall;
		if(!b||isSupported(b)){
			k.onFail=k.version=k.expressInstall=null;
			g.innerHTML=getHTML()
		}else if(k.onFail){
			var d=k.onFail.call(k,getVersion(),j);
			if(d)
				g.innerHTML=d
		}else if(b&&c&&isSupported([6,0,65])){
			extend(k,{src:c});
			j={MMredirectURL:location.href,MMplayerType:'PlugIn',MMdoctitle:document.title};g.innerHTML=getHTML()
		}else{
			if(g.innerHTML!=''){
			}else{
				g.innerHTML="<h2>Flash version "+b+" or greater is required</h2>"+"<h3>"+(a[0]>0?"Your version is "+a:"You have no flash plugin installed")+"</h3>"+"<p>Download latest version from <a href='"+k.pluginspage+"'>here</a></p>"}
			}
			g['on'+l]=null
		}

		function isSupported(a){
			var b=getVersion();
			return b[0]>=a[0]&&b[1]>=a[1]&&(b[2]==null||b[2]>=a[2])
		}
		function getHTML(){
			var a="";
			if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
				a='<embed type="application/x-shockwave-flash" ';
				extend(k,{name:m});
				for(var b in k){
					if(k[b]!=null)a+=[b]+'="'+k[b]+'"\n\t'
				}
				if(typeof j=='function')
					j=j();
				if(j){
					a+='flashvars=\'';
					for(var b in j){
						a+=[b]+'='+asString(j[b])+'&'
					}
					a+='\''
				}
				a+='/>'
			}else{
				a='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
				a+='width="'+k.width+'" height="'+k.height+'"';
				if(k.id)
					a+=' id="'+k.id+'"';
					a+='>';
					a+='\n\t<param name="movie" value="'+k.src+'" />';
					k.id=k.src=k.width=k.height=null;
					for(var b in k){
						if(k[b]!=null)
							a+='\n\t<param name="'+b+'" value="'+k[b]+'" />'
					}
				if(typeof j=='function')
					j=j();
				if(j){
					a+='\n\t<param name="flashvars" value=\'';
					for(var b in j){
						a+=[b]+'='+asString(j[b])+'&'}a+='\' />'
					}
					a+="</object>"
				}
				return a
			}
			function getVersion(){var a=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var b=navigator.plugins["Shockwave Flash"].description;if(typeof b!="undefined"){b=b.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var c=parseInt(b.replace(/^(.*)\..*$/,"$1"),10);var d=/r/.test(b)?parseInt(b.replace(/^.*r(.*)$/,"$1"),10):0;a=[c,d]}}else if(window.ActiveXObject){try{var f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(e){try{var f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");a=[6,0];f.AllowScriptAccess="always"}catch(e){if(a[0]==6)return}try{var f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(e){}}if(typeof f=="object"){var b=f.GetVariable("$version");if(typeof b!="undefined"){b=b.replace(/^\S+\s+(.*)$/,"$1").split(",");a=[parseInt(b[0],10),parseInt(b[2],10)]}}}return a}function asString(b){switch(typeOf(b)){case'string':return'"'+b.replace(new RegExp('(["\\\\])','g'),'\\$1')+'"';case'array':return'['+map(b,function(a){return asString(a)}).join(',')+']';case'object':var c=[];for(var d in b){c.push('"'+d+'":'+asString(b[d]))}return'{'+c.join(',')+'}'}return String(b).replace(/\s/g," ").replace(/\'/g,"\"")}function typeOf(a){if(a===null||a===undefined)return false;var b=typeof a;return(b=='object'&&a.push)?'array':b}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function map(a,b){var c=[];for(var i in a){c[i]=b(a[i])}return c}flashembed.getVersion=getVersion;flashembed.isSupported=isSupported;return g}if(typeof jQuery=='function'){(function($){$.fn.extend({flashembed:function(a,b){return this.each(function(){new flashembed(this,a,b)})}})})(jQuery)
}
