var MWEmbed = {
		settings:{
			container:'placePlayer',
			file:{flash:'',rtsp:'',http:''},
			image:'',
			width:400,
			height:300,
			noFlashMessage:'<a href="http://get.adobe.com/flashplayer/">Stáhněte si zde</a> poslední verzi Flashového přehrávače.'
		},
		createPlayer:function(){
			MWEmbed.mode = MWEmbed.detectMode();
			switch(MWEmbed.mode){
				case 'rtsp':MWEmbed.setupHTML(MWEmbed.settings.file.rtsp,MWEmbed.settings.image,MWEmbed.settings.width,MWEmbed.settings.height,MWEmbed.settings.container,true);break;
				case 'http':MWEmbed.setupHTML(MWEmbed.settings.file.http,MWEmbed.settings.image,MWEmbed.settings.width,MWEmbed.settings.height,MWEmbed.settings.container);break;
				case 'flash':MWEmbed.setupFlash();break;
			}
		},
		setupHTML:function(file,image,w,h,c,linkOnly){
			linkOnly = linkOnly || false;
			if(linkOnly){
				var txt='<a href = "'+file+'"><img src="'+image+'" width="'+w+'px" height="'+h+'px"/></a>';
			}else{
				var txt = '<video src="'+file+'" width="'+w+'"  height="'+h+'" autoplay="true" controls="controls" poster="'+image+'" onclick="this.play()">';
				txt+='<a href = "'+file+'"><img src="'+image+'" width="'+w+'px" height="'+h+'px"/></a>';		
				txt+='</video>';			
			}
			
			document.getElementById(c).innerHTML=txt;	
			
		},
		setupFlash:function(){
			document.getElementById(MWEmbed.settings.container).innerHTML=MWEmbed.settings.noFlashMessage;
			var flashvars = { file:MWEmbed.settings.file.flash,skin:'http://player.mediawork.cz/skin/hope.zip',image:MWEmbed.settings.image,watermark:'false',controlbar:'over',bufferlength: '5' };
			var params = { allowfullscreen:'true', allowscriptaccess:'always',wmode:'opaque' };
			var attributes = { id:MWEmbed.settings.container, name:MWEmbed.settings.container };
			swfobject.embedSWF('http://player.mediawork.cz/hopetv/player2.2.2.swf',MWEmbed.settings.container,MWEmbed.settings.width,MWEmbed.settings.height,'10','false',flashvars, params, attributes);
		
		},
		init : function (options){
			for (var i in options) {
				if (MWEmbed.settings.hasOwnProperty(i)){
					MWEmbed.settings[i] = options[i];
				}
			}
		},
		mode:'flash',
		ua:undefined,			
		rtsp:['Android','Bada','Symbian'],
		http:['iPhone','iPod','iPad'],
		getUA: function(){return navigator.userAgent;},
		detectMode:function(){MWEmbed.ua = MWEmbed.getUA(); var mode=''; if(MWEmbed.isRTSP(MWEmbed.ua)){mode = 'rtsp';}else if(MWEmbed.isApple(MWEmbed.ua)){mode='http';}else{mode='flash';} return mode;},
		isRTSP:function(ua){  for(var i in MWEmbed.rtsp){ if (ua.indexOf(MWEmbed.rtsp[i]) != -1) return true;} return false;},
		isApple:function(ua){  for(var i in MWEmbed.http){ if (ua.indexOf(MWEmbed.http[i]) != -1) return true;} return false;}
		
	};
