(function($){
	/*
		$(function(){
			$('.t-max').wsFlash();
		});
	*/
	$.fn.wsFlash=function(o){
		return this.each(function(){
			new $ws(this,o);
		});
	};
	$.wsFlash = function(e,o){
		this.o = $.extend({
			e:e,
			version:'',
			target:'',
			width:100,
			height:100,
			bgcolor:'',
			path:'',
			base:'',
			align:'',
			allowFullScreen:false,
			flashvars:'',
			loop:false,
			menu:false,
			play:false,
			quality:'autohigh',
			scale:false,
			scriptAccess:'always',
			swLiveConnect:true
		},o||{});
		this.embed();
	};
	var $ws = $.wsFlash;
	$ws.fn=$ws.prototype={wsFlash:'0.0.1'};
	$ws.fn.extend=$.extend;
	$ws.fn.extend({
		embed:function(){
			var o=this.o;
			if(!$(o.e))return false;
			if(this.detect()){
				for(var i=0;i<o.length;i++){
					if(o[i].match(/width|height/)){o[i]=parseFloat(o[i]);}
					if(o[i].match(/path/)){o[i]=o[i].toString();var q=o[i].split('?')[1];if(q)o['flashvars']=q;}
				}
				if(o.path)$(o.e).html('<!--[if !IE]> --><object type="application/x-shockwave-flash" data="'+o.path+'" width="'+o.width+'" height="'+o.height+'"><!-- <![endif]--><!--[if IE]><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+o.target+'" width="'+o.width+'" height="'+o.height+'"><param name="movie" value="'+o.path+'" /><!--><!--ws--><param name="loop" value="'+o.loop+'" /><param name="menu" value="'+o.menu+'" /><param name="quality" value="'+o.quality+'" /><param name="wmode" value="'+o.wmode+'" /><param name="flashVars" value="'+o.flashvars+'" /><param name="base" value="'+o.base+'"><param name="AllowScriptAccess" value="'+o.scriptAccess+'"><param name="scale" value="'+o.scale+'"></object><!-- <![endif]-->');
				return true;
			}
			return false;
		},
		detect:function(){
			var o=this.o,t=o.target.split(','),v=o.version=this.version().match(/\d+/g);
			if(v.length){
				for(var i=0;i<t.length;i++){
					v[i]=parseInt(v[i]||0);
					t[i]=parseInt(t[i]||0);
					if(v[i]<t[i])return false;//<
					if(v[i]>t[i])return true; //>
				}
			}
			return true;
		},
		version:function(){
			try { // ie
				return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g,',').match(/^,?(.+),?$/)[1];
			}
			catch(e){ 
				try { // others
					if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
						return(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g,",").match(/^,?(.+),?$/)[1];
					}
				}
				catch(e){}
			}
			return '0,0,0';
		}
	});
})(jQuery);
