
/* Copyright (c) 2008 Tero Piirainen (tero@flowplayer.org)
 *
 * $LastChangedDate: 12.03.2008
 * Version: 0.1.1
 * 
 * Tested with: jQuery 1.2.3+
 */
(function($){$.fn.extend({flashembed:function(a,b){return this.each(function(){new $.flashembed(this,a,b)})}});$.flashembed=function(a,b,c){this.init(a,b,c)};$.extend($.flashembed.prototype,{init:function(a,b,c){var p={src:'#',width:320,height:240,expressInstall:null,version:null,allowfullscreen:true,allowscriptaccess:'always',quality:'high',bgcolor:'#ffffff',type:'application/x-shockwave-flash',pluginspage:'http://www.adobe.com/go/getflashplayer'};$.extend(p,b);this.id=p.id;this.width=p.width;this.height=p.height;this.src=p.src;this.version=this.getVersion();var d=p.version;var e=p.expressInstall;p.width=p.id=p.height=p.src=p.version=p.expressInstall=null;this.params=p;this.flashvars=c;if(!d||this.isSupported(d)){$(a).html(this.getHTML()).show()}else if(d&&e&&this.isSupported([6,0,65])){$.extend(this.params,{src:e});this.flashvars={MMredirectURL:location.href,MMplayerType:'PlugIn',MMdoctitle:$('title').text()};$(a).html(this.getHTML()).show()}else{a=$(a);if(a.html()!='')a.show();else a.html("<h2>Flash version "+d+" or greater is required</h2>"+"<h3>"+(this.version[0]>0?"Your version is "+this.version:"You have no flash plugin installed")+"</h3>"+"<p>Download latest version from <a href='"+this.params.pluginspage+"'>here</a></p>")}},isSupported:function(a){var b=this.version;return b[0]>=a[0]&&b[1]>=a[1]&&(b[2]==null||b[2]>=a[2])},getHTML:function(){var a="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){a='<embed type="application/x-shockwave-flash" ';var b={width:this.width,height:this.height,src:this.src,id:this.id};$.extend(b,this.params);for(var c in b){if(b[c]!=null)a+=[c]+'="'+b[c]+'"\n\t'}if(this.flashvars){a+='flashvars=\'';for(var c in this.flashvars){a+=[c]+'='+this.asString(this.flashvars[c])+'&'}a+='\''}a+='/>'}else{a='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';a+='width="'+this.width+'" height="'+this.height+'"';if(this.id)a+=' id="'+this.id+'"';a+='>';a+='\n\t<param name="movie" value="'+this.src+'" />';for(var c in this.params){if(this.params[c]!=null)a+='\n\t<param name="'+c+'" value="'+this.params[c]+'" />'}if(this.flashvars){a+='\n\t<param name="flashvars" value=\'';for(var c in this.flashvars){a+=[c]+'='+this.asString(this.flashvars[c])+'&'}a+='\' />'}a+="</object>"}return a},getVersion:function(){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},asString:function(b){var c=this;switch(typeOf(b)){case'string':return'"'+b.replace(new RegExp('(["\\\\])','g'),'\\$1')+'"';case'array':return'['+$.map(b,function(a){return c.asString(a)}).join(',')+']';case'object':var d=[];for(var e in b){d.push('"'+e+'":'+c.asString(b[e]))}return'{'+d.join(',')+'}'}return String(b)}});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(){}})}})(jQuery);
