//*************************************************
//			webtv.rs player ver. 2.0.0.1
//			www.webtv.rs	www.webtelevizija.rs
//			abies.net
//*************************************************
function PlayVideo(ClipId, ClipName, autoPlay, preRoll, midRoll, postRoll, TextAd, MediaId) { 
	if (autoPlay == "false"){
		autoPlay = false;
	}else{
		autoPlay = true;
	}
	
	var urlPlay = '';
	var urlClipToPlay = ClipName;
	var urlSplitResult = urlClipToPlay.split("/");
	for(i = 0; i < urlSplitResult.length; i++){
		if(i == urlSplitResult.length-1){
			ClipToPlay = urlSplitResult[i];
		}else{
			urlPlay = urlPlay + '/' + urlSplitResult[i];
		}
	}
   if (ClipToPlay.slice(0,4) == 'api:'){
   		plugs = 'YT';
   		_provider = 'youtube';
   		_urlResolvers = 'youtube';
   }else{
   		plugs = 'WTV';
   		_provider = 'lighttpd';
   		_urlResolvers = 'cluster';
   }
	document.getElementById("fms").style.width=w+"px";
	document.getElementById("fms").style.height=h+"px";
	document.getElementById('clipImage').style.visibility='hidden';
	if (plugs == 'WTV'){
		$f("a.webtvplayer", "/player/fp/flowplayer.commercial-3.2.7.swf", {
			key: '#$ed095f9125b339d8d94',
			logo: {
				url: '/player/logos/'+MediaId+'.png',
				top: w*0.02,
				left: h*0.05,
				width: '95%',
				height: '95%',
				opacity: 0.7, 
				fullscreenOnly: false,
				displayTime: 0
			},
			onStart: function(clip, isPreroll) {
				if (isPreroll.url == 'http://'+ server+'/'+ urlClipToPlay){
					$("#clipImage").load("/player/scripting/onplay.asp?oid=" + ClipId + "&mediaid="+ MediaId +"&servers="+ server);
				}
			},
			contextMenu: [
			{'About Web Televizija ...' : function() { 
			    window.open('http://www.webtv.rs/marketing.asp');
			}}, 
			'-', 
			'WebTV player 3.2.7',
			'-', 
			'Powered by Web Televizija',
			'-',
			{'Copyright © Web Televizija' : function() { 
			    window.open('http://www.abies.net');
			}}
			],
			clip: { 
			   autoPlay: autoPlay,
	       	   scaling: 'fit',
			   url: ClipToPlay,
		       provider: _provider,
		   	   urlResolvers: _urlResolvers
			},
		    plugins: {
				cluster: {
					url: '/player/fp/ver3.2.4/flowplayer.cluster-3.2.2.swf',
					hosts: [
						 'http://fs2.webtv.rs'+ urlPlay +'/',
						 'http://fs3.webtv.rs'+ urlPlay +'/',
						 'http://fs6.webtv.rs'+ urlPlay +'/',
						 'http://fs4.webtv.rs'+ urlPlay +'/',
						 'http://fs5.webtv.rs'+ urlPlay +'/'
					],
					loadBalance: true,
					onConnect: function(host, index) {
					server = host.substring(7,19);
					}
				},
		    	lighttpd: {
					url: '/player/fp/ver3.2.4/flowplayer.pseudostreaming-3.2.7.swf'
				},
				liverail: {
				// load the LiveRail plugin
				url: 'http://vox-static.liverail.com/swf/v4/plugins/flowplayer/LiveRailPlugin327.swf',
				//url: 'http://vox-static.liverail.com/swf/v4/plugins/flowplayer/LiveRailPlugin315.swf',
				// LiveRail specific configuration:
				LR_VERSION: '4.1',
				LR_PUBLISHER_ID: '1921',
				LR_TAGS: preRoll, //'inter_story_video',//preRoll, +','+ midRoll +','+ postRoll
				LR_VERTICALS: MediaId,
				PARTNER_ID: '1955'
				},
				gatracker: {
					url: "/player/fp/ver3.2.4/flowplayer.analytics-3.2.1.swf",
					labels: {
						start: "Start",	
						play: "Play",	
						pause: "Pause",	
						resume: "Resume",	
						seek: "Seek",	
						stop: "Stop",	
						finish: "Finish",	
						mute: "Mute",	
						unmute: "Unmute",	
						fullscreen: "Full Screen",	
						fullscreenexit: "Full Screen Exit"
					},
					debug: false,
					trackingMode: "AS3",
					googleId: "UA-6730923-2" // your Google Analytics id here
				},
				controls: {
					url: '/player/fp/flowplayer.controls-3.2.5.swf',
					buttonColor: 'rgba(0, 0, 0, 0.9)',
					buttonOverColor: '#000000',
					backgroundColor: '#D7D7D7',
					backgroundGradient: 'medium',
					sliderColor: '#FFFFFF',
					
					sliderBorder: '1px solid #808080',
					volumeSliderColor: '#FFFFFF',
					volumeBorder: '1px solid #808080',
					
					timeColor: '#000000',
					durationColor: '#535353'
				}
		    }
		});
	
	}else{
	//YT player
		$f("a.webtvplayer", "/player/fp/ver3.2.4/flowplayer.commercial-3.2.4.swf", {
			key: '#$ed095f9125b339d8d94',
			onStart: function(clip, isPreroll) {
				if ('api:'+isPreroll.url == urlClipToPlay){
					$("#info").load("/player/scripting/onplay.asp?oid=" + ClipId + "&mediaid="+ MediaId +"&servers=YouTube");
				}
			},
			clip: { 
			   autoPlay: autoPlay,
	       	   //scaling: 'fit',
			   url: ClipToPlay,
			   //captionUrl: "subtitle.srt",
		       provider: _provider,
		   	   urlResolvers: _urlResolvers
			},
		    plugins: {
			    youtube: {
		            url:'/player/fp/ver3.2.4/flowplayer.youtube-3.2.1.swf'
		        },
				gatracker: {
					url: "/player/fp/ver3.2.4/flowplayer.analytics-3.2.1.swf",
					labels: {
						start: "Start",	
						play: "Play",	
						pause: "Pause",	
						resume: "Resume",	
						seek: "Seek",	
						stop: "Stop",	
						finish: "Finish",	
						mute: "Mute",	
						unmute: "Unmute",	
						fullscreen: "Full Screen",	
						fullscreenexit: "Full Screen Exit"
					},
					debug: false,
					trackingMode: "AS3",
					googleId: "UA-6730923-2" // your Google Analytics id here
				},
				controls: {
					buttonColor: 'rgba(0, 0, 0, 0.9)',
					buttonOverColor: '#000000',
					backgroundColor: '#D7D7D7',
					backgroundGradient: 'medium',
					sliderColor: '#FFFFFF',
					
					sliderBorder: '1px solid #808080',
					volumeSliderColor: '#FFFFFF',
					volumeBorder: '1px solid #808080',
					
					timeColor: '#000000',
					durationColor: '#535353'
				}
		    }
		});
	

	}

}

