Flowplayer = function(){

	return {

		init: function(selector, swf_url){
			Ext.select(selector||".rtf a").each(function(el){
				if(el.parent(".WGA-Item-Value-Unencoded"))
					return;		// ignore this images
				var href = el.dom.href||el.dom.src;
				href=href.split(";")[0];	// ignore ;jsessiond-s
				var a = href.split(".");
				if(a.length>1){
					var ext = a.pop().toLowerCase();
					if(ext=="mov" || ext=="mp4" || ext=="m4v"){
						var img = el.child("img");
						if(img){
							el.setStyle({
								display: "block",
								textDecoration: "none",
								height: img.getHeight()+"px",
								width: img.getWidth()+"px"
							})

							/*	This for some strange reasons the following code does not work in IE, so we do it by hand :-(
							var imgWrapper = el.createChild({
								tag: "div",
								cls: "video-img-wrapper",
								children: [{
									tag: "div",
									cls: "video-title",
									html: el.dom.title||img.dom.title
								}]
							}, img)
							*/
							
							var iw = document.createElement("div");
							iw.className = "video-img-wrapper";
							var iw_title = document.createElement("div");
							iw_title.className = "video-title";
							iw_title.innerHTML = el.dom.title||img.dom.title;
							iw.appendChild(iw_title);
							
							el.dom.insertBefore(iw, img.dom);
										
							var imgWrapper = Ext.fly(iw);
							imgWrapper.dom.title = "Klicken, um das Video zu starten ...";
							imgWrapper.setStyle({
								position: "absolute",
								opacity: 0,
								height: img.getHeight()+"px",
								width: img.getWidth()+"px"
							})
							if(Ext.isWebKit){
								// use transitions
								imgWrapper.setStyle("opacity", .6)
							}
							else {
								imgWrapper.pause(1).fadeIn({
									endOpacity: .6,
									duration: 1,
									afterStyle: "visibility:visible"
								});
							}
						}
						else el.update("");
						$f(el.dom, swf_url||"/plugin-flowplayer/file/distribution/flowplayer-3.2.5.swf", {
							clip: {
								onFinish: function () {
								    this.unload()										
								}
							}
						}).ipad();
					}
				}
			})
		}
	}
	
}()
