/* player 2009-04-15 - 2011-01-05T13:39 */
var sdt_res=false, debug_video=false;
var playVideo={}, dataMessage=['426794','426795'];
var player={
	divID:'player',wmpID:'WMPlayerO1',tr:3300,obj:null,
	statu:null,object_id:'',format_id:'',website_id:'',vortal_id:'',video_format_profile_id:'',request_id:'',xslt:'player/playreq.jso.xslt',mod:'',type:'',player_size:'normal',play_mode:'',video_movie_type:'1',player_type:'',player_ver:'1',
	sub_pl:'',sub_en:'',
	media:null,unique_id:'',user_id:'',sarg:'',
	data:'',
	request_no:0,
	infoTextRequest:function(){return '<br /><a href="" onclick="loadVideo(\'player\',playVideo); return false">Spr\u00F3buj ponownie</a>'},
	setFormat:function(format_id,mod){this.format_id=format_id;this.mod=mod;},
	setObject:function(format_id,obj){
		this.format_id=format_id; this.mod=obj.mod||'';
		this.object_id=obj.object_id||''; this.player_size=obj.player_size||''; this.play_mode=obj.play_mode||''; this.player_type=obj.player_type||''; this.player_ver=obj.player_ver||'1';
		this.video_format_profile_id=obj.video_format_profile_id||''; this.type=this.type||obj.type;this.video_movie_type=obj.video_movie_type||'1';
		this.sub_pl=obj.sub_pl||''; this.sub_en=obj.sub_en||'';
	},
	update:function(divID,objVideo,htmlObj){
		this.divID=divID;
		this.object_id=objVideo.object_id;
		this.format_id=objVideo.format_id;
		this.obj=dojo.byId(htmlObj)||dojo.byId(divID);
	},
	loadHTML:function(data,divID){
		var divID=divID||this.divID;
		var div=dojo.byId(divID);
		div.style.display = 'block';
		div.innerHTML='<div class="clr">&nbsp;</div>'+data+' <div class="clr">&nbsp;</div>';
	},
	info2html:function(data,divID){
		var divID=divID||this.divID;
		var div=dojo.byId(divID);
		div.style.display = 'block';
		div.innerHTML+='<div class="clr">&nbsp;</div>'+data+' <div class="clr">&nbsp;</div>';
//		div.innerHTML='<div id="loadBarBg"><span id="loadBarBgDone">...</span></div>&nbsp;';
	},
	updateHTML:function(data,divID){
		var divID=divID||this.divID;
		var div=dojo.byId(divID);
		try{
			div.style.display = 'block';
			div.innerHTML='<div class="clr">&nbsp;</div>'+data+' <div class="clr">&nbsp;</div>';
		} catch(ex){}
	},
	putHTML:function(divID){
		this.loadHTML('<div id="playerF"></div><div class="playerInfo"><div class="mvTop">&nbsp;</div><div id="playerInfo"><div id="playerInfoText" class="infoTx">&nbsp;</div><div id="playerErrText" class="err">&nbsp;</div>&nbsp;</div><div id="loadBarBg"><span id="loadBarBgDone">...</span></div></div>&nbsp;</div>');
	},
	playerType:function(objVideo){
		var player_type=readCookie('TVP_PLAYER_TYPE');
		if(player_type == 'mp' && this.player_type=='sl'){
			this.player_type='mp';this.player_size='width-max';
		}
		//createCookie('TVP_PLAYER_TYPE','mp',1);
	}
}

function object2strRAS(objx,ext){
	var str='dd ',ext=ext||' cci ';
	dojo.byId('allInfo').innerHTML+=ext+' ::--- '+ dojo.toJson(objx,true)+' \x3Chr /\x3E ';
}

function setLanguageCode(lang){
	var LCID = new Array(
		"or","es", "cs", "da", "de", "et", "el", "en", "fr", "it",  
		"lv","lt", "hu", "mt", "nl", "pl", "pt", "sk", "sl", "fi",  
		"sv","ro", "bg", "af", "sq", "am", "ar", "hy", "as", "en-gb", 
		"ar-dz", "ar-bh", "ar-eg", "ar-iq", "ar-jo", "ar-kw", "ar-lb", "ar-ly", "ar-ma", "ar-om",
		"ar-qa", "ar-sy", "ar-tn", "ar-ae", "ar-ye", "az", "az-az", "eu", "be",
		"bs", "my", "ca", "zh", "zh-sg", "zh-tw", "zh-hk", "zh-mo", "hr", "bs",
		"dv", "nl-be", "en-au", "en-bz", "en-ca", "en-cb", "en-ie", "en-jm", "en-ph", "en-za",
		"en-za", "fo", "fa", "fr-be", "fr-ca", "fr-lu", "fr-ch", "ff", "mk", "ga",
		"gd", "gl", "ka", "de-at", "de-li", "de-lu", "de-ch", "gn", "gu", "ha",
		"he", "hi", "is", "id", "iu", "it-ch", "ja", "kn", "ks", "kk",
		"km", "ko", "lo", "la", "ms-my", "ms-bn", "ml", "mr", "mn", "ne",
		"no-nn", "no-nb",  "om", "ps", "pt-br", "pa", "qu", "rm", "ro-mo",
		"ru", "ru-mo", "sa", "sr", "sd", "si", "so", "es-ar", "es-bo", "es-cl",
		"es-co", "es-cr", "es-do", "es-ec" , "es-gt" , "es-hn", "es-mx" , "es-ni" , "es-pa", "es-pe",
		"es-pr", "es-py", "es-sv", "es-uy", "es-ve", "st", "sw", "tg", "ta", "tt",
		"te", "th", "bo", "ti", "ts", "tn", "tr", "tk", "ug", "uk",
		"ur", "uz", "ve", "vi", "cy", "xh", "yi", "yo");
		LCID["or"] = 1077;LCID["es"] = 1034;LCID["cs"] = 1029;LCID["da"] = 1030;LCID["de"] = 1031;
		LCID["et"] = 1061;LCID["el"] = 1032;LCID["en"] = 2057;LCID["fr"] = 1036;LCID["it"] = 1040;
		LCID["lv"] = 1062;LCID["lt"] = 1063;LCID["hu"] = 1038;LCID["mt"] = 1082;LCID["nl"] = 1043;
		LCID["pl"] = 1045;LCID["pt"] = 2070;LCID["sk"] = 1051;LCID["sl"] = 1060;LCID["fi"] = 1035;
		LCID["sv"] = 1053;LCID["ro"] = 1048;LCID["bg"] = 1026;
		LCID["af"] = 1078;			//Afrikaans
		LCID["sq"] = 1052;			//Albanian
		LCID["am"] = 1118;			//Amharic - Ethiopia
		LCID["hy"] = 1067;			//Armenian - Armenia
		LCID["as"] = 1101;			//Assamese
		LCID["en-us"] = 1033;		//English - United States
		LCID["ar"] = 1025;			//Arabic - Algeria 
		LCID["ar-dz"] = 5121;		//Arabic - Saudi Arabia
		LCID["ar-bh"] = 15361;		//Arabic - Bahrain
		LCID["ar-eg"] = 3073;		//Arabic - Egypt
		LCID["ar-iq"] = 2049;		//Arabic - Iraq
		LCID["ar-jo"] = 11265;		//Arabic - Jordan
		LCID["ar-kw"] = 13313;		//Arabic - Kuwait
		LCID["ar-lb"] = 12289;		//Arabic - Lebanon
		LCID["ar-ly"] = 4097;		//Arabic - Libya
		LCID["ar-ma"] = 6145;		//Arabic - Morocco
		LCID["ar-om"] = 8193;		//Arabic - Oman
		LCID["ar-qa"] = 16385 ;		//Arabic - Qatar
		LCID["ar-sy"] = 10241;		//Arabic - Syria
		LCID["ar-tn"] = 7169;		//Arabic - Tunisia
		LCID["ar-ae"] = 14337;		//Arabic - U.A.E.(Arabic - United Arab Emirate))
		LCID["ar-ye"] = 9217;		//Arabic - Yemen
		LCID["az"] = 1068;			//Azeri (Latin)
		LCID["az-az"] = 2092;		//Azeri (Cyrillic)
		LCID["eu"] = 1069;			//Basque
		LCID["be"] = 1059;			//Belarusian
		LCID["bn"] = 1093;			//Bengali (India)
		LCID["bs"] = 5146;			//Bosnian (Bosnia/Herzegovina)
		LCID["my"] = 1109;			//Birman (burmese))
		LCID["ca"] = 1027;			//Catalan
		LCID["zh"] = 2052;			//Chinese - China
		LCID["zh-sg"] = 4100;		//Chinese - Singapore
		LCID["zh-tw"] = 1028;		//Chinese - Taiwan
		LCID["zh-hk"] = 3076;		//Chinese - Hong Kong SAR
		LCID["zh-mo"] = 5124;		//Chinese - Macao SAR
		LCID["hr"] = 1050;			//Croatian
		LCID["bs"] = 5146;			//Croatian (Bosnia/Herzegovina)
		LCID["dv"] = 1125;			//Div�hi (Maldivien)
		LCID["nl-be"] = 2067;		//Dutch - Belgium
		LCID["en-au"] = 3081;		//English - Australia
		LCID["en-bz"] = 10249;		//English - Belize
		LCID["en-ca"] = 4105;		//English - Canada
		LCID["en-cb"] = 9225;		//English - Caribbean
		LCID["en-ie"] = 6153;		//English - Ireland
		LCID["en-jm"] = 8201;		//English - Jamaica
		LCID["en-nz"] = 5129;		//English - New Zealand
		LCID["en-ph"] = 13321;		//English - Phillippines
		LCID["en-za"] = 7177; 		//English - Southern Africa
		LCID["en-tt"] = 11273; 		//English - Trinidad
		LCID["fo"] = 1080;			//Faroese (F�ro�en)
		LCID["fa"] = 1065;			//Farsi
		LCID["fr-be"] = 2060;		//French - Belgium
		LCID["fr-ca"] = 3084;		//French - Canada
		LCID["fr-lu"] = 5132;		//French - Luxembourg
		LCID["fr-ch"] = 4108;		//French - Switzerland
		LCID["ff"] = 1127;			//Fulfulde - Nigeria
		LCID["mk"] = 1071;			//F.Y.R.O. Macedonia
		LCID["ga"] = 2108;		    //Gaelic - Ireland
		LCID["gd"] = 1084;			//Gaelic - Scotland
		LCID["gl"] = 1110;			//Galician
		LCID["ka"] = 1079;			//Georgian
		LCID["de-at"] = 3079;		//German - Austria
		LCID["de-li"] = 5127;		//German - Liechtenstein
		LCID["de-lu"] = 4103;		//German - Luxembourg
		LCID["de-ch"] = 2055;		//German - Switzerland
		LCID["gn"] = 1140;			//Guarani - Paraguay
		LCID["gu"] = 1095;			//Gujarati
		LCID["he"] = 1037;			//Hebrew
		LCID["hi"] = 1081;			//Hindi
		LCID["is"] = 1039;			//Icelandic
		LCID["id"] = 1057;			//Indonesian
		LCID["iu"] = 1117;			//Inuktitut (esquimau)
		LCID["it-ch"] = 2064;		//Italian - Switzerland
		LCID["ja"] = 1041;			//Japanese
		LCID["kn"] = 1099;			//Kannada, Canara
		LCID["ks"] = 2144;			//Kashmiri, Cachemiri
		LCID["kk"] = 1087;			//Kazakh
		LCID["km"] = 1107;			//Khmer
		LCID["ko"] = 1042;			//Korean
		LCID["lo"] = 1108;			//Lao
		LCID["la"] = 1142;			//Latin
		LCID["ms-my"] = 1086;		//Malay - Malaysia
		LCID["ms-bn"] = 2110;		//Malay - Brunei
		LCID["ml"] = 1100;			//Malayalam
		LCID["mr"] = 1102;			//Marathi
		LCID["mn"] = 2128;			//Mongolian (Mongolian)
		LCID["ne"] = 1121;			//Nepali
		LCID["no-nn"] = 1044;		//Norwegian Nynorsk
		LCID["no-nb"] = 2068;		//Norwegian Bokmal
		//LCID["or"] = 1096;			//Oriya
		LCID["om"] = 1138;			//Oromo, Galla
		LCID["ps"] = 1123;			//Pashto (Pachtou)
		LCID["pt-br"] = 1046;		//Portuguese - Brazil
		LCID["pa"] = 1094;			//Punjabi(Pendjabi)
		LCID["qu"] = 3179;			//Qu�chua (Kitchoua) perou
		LCID["rm"] = 1047;			//Raeto-Romance
		LCID["ro-mo"] = 2072;		//Romanian - Republic of Moldova
		LCID["ru"] = 1049;			//Russian
		LCID["ru-mo"] = 2073;		//Russian - Republic of Moldova
		LCID["sa"] = 1103;			//Sanskrit
		LCID["sr"] = 3098;			//Serbian
		LCID["sd"] = 2137;			//Sindhi - Pakistan
		LCID["si"] = 1115;			//Sinhalese - Sri Lanka
		LCID["so"] = 1143;			//Somali
		LCID["es-ar"] = 11274;		//Spanish - Argentina
		LCID["es-bo"] = 16394;		//Spanish - Bolivia
		LCID["es-cl"] = 13322;		//Spanish - Chile
		LCID["es-co"] = 9226;		//Spanish - Colombia
		LCID["es-cr"] = 5130;		//Spanish - Costa Rica
		LCID["es-do"] = 7178;		//Spanish - Dominican Republic
		LCID["es-ec"] = 12298;		//Spanish - Ecuador
		LCID["es-gt"] = 4106;		//Spanish - Guatemala
		LCID["es-hn"] = 18442;		//Spanish - Honduras
		LCID["es-mx"] = 2058;		//Spanish - Mexico
		LCID["es-ni"] = 19466;		//Spanish - Nicaragua
		LCID["es-pa"] = 6154;		//Spanish - Panama
		LCID["es-pe"] = 10250;		//Spanish - Peru
		LCID["es-pr"] = 20490;		//Spanish - Puerto Rico
		LCID["es-py"] = 15370;		//Spanish - Paraguay
		LCID["es-sv"] = 17418;		//Spanish - El Salvador
		LCID["es-uy"] = 14346;		//Spanish - Uruguay
		LCID["es-ve"] = 8202;		//Spanish - Venezuela
		LCID["st"] = 1072;			//Sotho, Southern
		LCID["sw"] = 1089;			//Swahili
		LCID["tg"] = 1064;			//Tajik
		LCID["ta"] = 1097;			//Tamil
		LCID["tt"] = 1092;			//Tatar
		LCID["te"] = 1098;			//Telugu
		LCID["th"] = 1054;			//Thai
		LCID["bo"] = 2129;			//Tibetan
		LCID["ti"] = 2163;			//Tigrinya
		LCID["ts"] = 1073;			//Tsonga
		LCID["tn"] = 1074;			//Tswana
		LCID["tr"] = 1055;			//Turkish
		LCID["tk"] = 1090;			//Turkmen
		LCID["ug"] = 1152;			//Uighur - China
		LCID["uk"] = 1058;			//Ukrainian
		LCID["ur"] = 1056;			//Ukrainian
		LCID["uz"] = 2115;			//Uzbek
		LCID["ve"] = 1075;			//Venda
		LCID["vi"] = 1066;			//Vietnamese
		LCID["cy"] = 1106;			//Welsh (gallois)
		LCID["xh"] = 1076;			//Xhosa
		LCID["yi"] = 1085;			//Yiddish
		LCID["yo"] = 1130;			//Yoruba	
}

function loadVideo(divID,obj,htmlObj){
	var div=dojo.byId(divID),xslt=obj.xslt||'player/playreq.jso.xslt',bitrate=obj.bitrate||'false',sdt_version=obj.sdt_version||'1',autoplay=obj.autoplay||'true';
	player.update(divID,obj,htmlObj);
	player.setObject(obj.format_id,obj);
	player.playerType(obj);
	if(typeof obj.website_id != 'undefined'){player.website_id=obj.website_id;}
	if(typeof obj.vortal_id != 'undefined'){player.vortal_id=obj.vortal_id;}
	/*
	if(obj.play_mode && obj.play_mode == 'NONE'){
		player.updateHTML('<div id="playerErrTextImg" class="img-err"><img src="http://s.v3.tvp.pl/images/0/0/0/uid_000000-material-jest-niedostepny_width_450_play_0_pos_3_gs_0.jpg" alt="Przepraszamy. Wideo nie jest dost\u0119pne."/></div>');
	}
	*/
	if(obj.format_id != ''){
		var bindArgs={
			content:{
				object_id:obj.object_id,
				format_id:obj.format_id,
				play_mode:obj.play_mode,
				mod:obj.mod,
				type:obj.type,
				player_size:obj.player_size,
				player_type:player.player_type,
				player_ver:player.player_ver,
				video_format_profile_id:player.video_format_profile_id,
				sdt_version:sdt_version,
				//get_play_url:'true',
				autoplay:autoplay,
				video_movie_type:player.video_movie_type,
				sub_pl:player.sub_pl,
				sub_en:player.sub_en,
				bitrate:bitrate,
				website_id:player.website_id,
				vortal_id:player.vortal_id,
				path_id:obj.path_id,
				xslt:xslt
			},
			url:'/pub/sess/playrequest',
			handleAs:'json',
			handle:function(response,ioArgs) {
				if(typeof response.window_text != 'undefined'){
					player.updateHTML('<div id="playerInfoText" class="err">' + response.window_text + '</div>','playerInfo');
				}
				bindArgs.content.get_play_url='';
				player.media=response.play_url;
				
				processMaterialData(response);
			},
			error:function(response,ioArgs){
				console.error('HTTP status code: ',ioArgs.xhr.status);
				player.updateHTML('<div id="playerErrText" class="err">Przepraszamy. Wyst\u0105pi\u0142 b\u0142\u0105d. </div>','playerInfo');
			}
		};
		dojo.xhrGet(bindArgs);
	} else {
		var postArgs={
			content:{
				format_id:obj.format_id,
				object_id:obj.object_id,
				odsylacz:document.location,
				data:'',
				xslt:xslt
			},
			url:'/v3/bledyplayera.php',
			handle:function(response,ioArgs) {
			},
			error:function(response,ioArgs){
				console.error('HTTP status code: ',ioArgs.xhr.status);
			}
		};
		dojo.xhrPost(postArgs);
	}
}

function playrequest(request_id){
	var xslt=player.xslt||'player/playreq.jso.xslt';
	var bindArgs={
		content:{
			request_id:request_id,
			mod:player.mod,
			type:player.type,
			player_size:player.player_size,
			player_type:player.player_type,
			xslt:xslt
		},
		url:'/pub/sess/playrequest',
		handleAs:'json',
		handle:function(response,ioArgs) {
			processMaterialData(response);
//			return;
		},
		error:function(response,ioArgs){
			console.error('HTTP status code: ',ioArgs.xhr.status);
//			player.updateHTML('<div id="playerInfoText" class="err">Przepraszamy. Wyst\u0105pi\u0142 b\u0142\u0105d podczas lokalizacji materia\u0142u wideo. '+ player.infoTextRequest() +'</div>','playerInfo');

		}
	};
	dojo.xhrGet(bindArgs);
}

function showAccessInfo(object_id){
	var div=dojo.byId('videoBox');
	var bindArgs={
		content:{
			object_id:object_id,
			poutput:'xhtml',
			top:'false',
			xslt:'portal/default/news/news_simple.xslt'
		},
		url:'/pub/stat/details',
		load:function(response,ioArgs) {
			if(div == null){
				div=dojo.byId('mainContent');
			} else {
				div.innerHTML='';
			}
			div.innerHTML=response;
		},
		error:function(response,ioArgs){
			console.error('HTTP status code: ',ioArgs.xhr.status);
			console.error('Obiekt: ',div);
		}
	};
	dojo.xhrGet(bindArgs);
}

function processMaterialData(responseData){
	if(responseData.status == 'NOT_STARTED' || responseData.status == 'PROCESSING' || responseData.status == 'DEFFERED'){
		var trim=window.setTimeout('playrequest("'+responseData.request_id+'")',1500);
		dojo.style('loadBarBgDone','width',responseData.pct_done+'%');
	}else if(responseData.status == 'ERROR'){
		dojo.style('loadBarBgDone','width',responseData.pct_done+'%');
		if(responseData.error_type=='limit' || responseData.error_type=='access'){
			player.loadHTML(responseData.window_text);
		}else{
			if(player.request_no < 1){
				player.request_no++;
				player.loadHTML(responseData.window_text,'player');
				var tt1=window.setTimeout("loadVideo('"+ player.divID +"',{format_id:'"+ player.format_id +"'})",3000);
			}else{
				player.putHTML('player');
				player.updateHTML('<div id="playerInfoText" class="err">Przepraszamy. Wyst\u0105pi\u0142 b\u0142\u0105d podczas lokalizacji materia\u0142u wideo. '+ player.infoTextRequest() +'</div>','playerInfo');
			}
		}
	}else if(responseData.status == 'NOT_AUTHORIZED'){
		showAccessInfo(dataMessage[0]);
	}else if(responseData.status == 'NO_VIDEO_SUBSCRIPTION'){
		showAccessInfo(dataMessage[1]);
	}else if(responseData.status == 'OUTDATED'){
		dojo.style('loadBarBgDone','width',responseData.pct_done+'%');
		if(player.request_no < 2){
			player.request_no++;
			var tt1=window.setTimeout("loadVideo('"+ player.divID +"',{format_id:'"+ player.format_id +"'})",3000);
		}else{
			player.request_no=0;
			player.updateHTML('<div id="playerInfoText" class="err">Przepraszamy. Wyst\u0105pi\u0142 b\u0142\u0105d podczas lokalizacji materia\u0142u wideo... '+ player.infoTextRequest() +'</div>','playerInfo');
		}
	}else if(responseData.access_mode == 'DOWNLOAD' && (responseData.type != 'video/mp4' || responseData.type != 'video/x-flv')){
			player.updateHTML('<div id="playerDownloadFile">' + responseData.window_text + '</div>','player'); 
	}else if(responseData.status == 'DYNAMIC' || responseData.status == 'SUPERCACHED' || responseData.status == 'CACHED'){
		dojo.style('loadBarBgDone','width',responseData.pct_done+'%');
		if(responseData.type == 'video/x-flv'){
			// Usuniecie obslugi mp4 w playerze flash
			loadFlashVideo(responseData.request_id);
		}else if(responseData.window_text.substring(1,7) == 'object' || responseData.player_type == 'sl'){
			player.loadHTML(responseData.window_text);
		}else {
			player.updateHTML('<div id="playerInfoText" class="err">'+ responseData.window_text +'</div>','playerInfo');
			document.getElementById( 'loadBarBg' ).style.display = 'none';
		}
	} else{
		;//
	}
	try{
			var strdebug='';
			if(/\?dete=1/.test(document.location.href)){
				strdebug='\x3cdiv> - DEBUG INFO: \x3cbr/>'
					+ 'access_mode: ' + responseData.access_mode + '\x3cbr/>'
					+ 'format_id: ' + responseData.format_id + '\x3cbr/>'
					+ 'request_id: ' + responseData.request_id + '\x3cbr/>'
					+ 'status: ' + responseData.status + '\x3cbr/>'
					+ 'error_type: ' + responseData.error_type + '\x3cbr/>'
					+ 'error_code: ' + responseData.error_code + '\x3cbr/>'
					+ 'error_message: ' + responseData.error_message + '\x3cbr/>'
					+ 'mod: ' + responseData.mod + '\x3cbr/>'
					+ 'player_size: ' + responseData.player_size + '\x3cbr/>'
					+ 'player_type: ' + responseData.player_type + '\x3cbr/>'
					+ 'type: ' + responseData.type + '\x3cbr/>'
					+ 'play_url: ' + responseData.play_url + '\x3cbr/>'
					+ 'url: ' + document.location + '\x3cbr/>'
					+ 'browser: ' + navigator.userAgent + '\x3cbr/>'
					+ 'date: ' + (new Date()) + '\x3cbr/>'
					+ '\x3c/div>';
				var ddiv=dojo.byId('debug-video')||dojo.byId('contentVideo')||dojo.byId('player');
				dojo.place(strdebug,ddiv,'after');
			}
	}
	catch(e){;}
	if(sdt_res){roomer(responseData);}
	if((responseData.status == 'DYNAMIC' || responseData.status == 'SUPERCACHED' || responseData.status == 'CACHED') && (responseData.sarg)){
		try {gemius_sarg_hit(responseData.sarg+playVideo.unique_id);}
		catch(ex){;}
	}
}

function loadFlashVideo(request_id){
	var owidth,oheight;
	owidth='100%';//(player.player_size=='max')?'100%':'620';
	oheight='100%';//(player.player_size=='max')?'100%':'420';
	var fpSwfPath = 'http://s.v3.tvp.pl/files/portal/ss2/voice-of-poland/swf/FlashVideoPlayer.swf';
	var htmlContainerID = "playerF";
	var swfVersionStr = "10.2.0";
	var fpFlashVars = {};
	fpFlashVars.source = player.media;
	//fpFlashVars.adServerURL = 'http://s.v3.tvp.pl/files/slp/201011/adservers-links-adocean.php';
    //fpFlashVars.vortalID = "691";
    //fpFlashVars.websiteID = "882";
    //fpFlashVars.pathID = "33012;27;26;25;5";
    var fpParams = {};
	fpParams.wmode = "opaque";
	fpParams.quality = "high";
	fpParams.menu = "false";
	fpParams.allowscriptaccess = "always";
    fpParams.allowfullscreen = "true";
	fpParams.allownetworking = "all";
	var fpAttributes = {};
	swfobject.embedSWF(
                fpSwfPath, htmlContainerID,
                owidth, oheight,
                swfVersionStr, false,
                fpFlashVars, fpParams, fpAttributes);
	dojo.place('<img alt="" class="stats" style="width:1px; height:1px; position:absolute; top:1px; left:1px;" src="/pub/sess/viewvideorequest?object_id=' + player.format_id + '"/>', htmlContainerID, 'after');
}

function ageConfirmed(co){
	document.getElementById('div_AgeConfirmation').style.display='none';
	document.getElementById('div_forEveryone').style.display='block';
	if(co == 'true'){initAvdPlayer();}
	else {loadVideo('player',playVideo);}
//	return false;
}

/* tester */
function roomer(res){
	var str_res=' req_id: '; str_res+=res.request_id; if(sdt_res){dojo.byId('infoVideo').innerHTML='copy '+str_res;} sdt_res=false;
}

function silverlightObjectRef(refName){
	if(document.getElementById(refName)){
		return document.getElementById(refName);
	} else {
		return false;
	}
}

// ustawianie trybu playera (Vod, Live)
function slPlayerSetMode(mode) {
    var pluginObject = document.getElementById("silverlightObject");
    pluginObject.Content.Player.SetMode(mode);
}

// ustawia url do odtwarzanego materialu, oraz automatycznie przechodzi do pozycji pauza
function slPlayerSetUrl(url) {
	var pluginObject = document.getElementById("silverlightObject");
	pluginObject.Content.Player.SetUrl(url);
}

// dekomponuje asx, przekazany jako parametr wejsciowy, odczytuje z niego adres(y) materialu
// oraz przekazuje je do playera
function slPlayerSetAsx(url) {
	var pluginObject = document.getElementById("silverlightObject");
	pluginObject.Content.Player.SetAsx(url);
}

// odwoluje sie do uslugi wydajacej asx'y pod adres wskazany jako parametr wejsciowy,
// dekomponuje otrzymany asx, odczytuje z niego adres materialu oraz przekazuje go do playera
function slPlayerSetUrlFromAsx(url) {
    var pluginObject = document.getElementById("silverlightObject");
    pluginObject.Content.Player.SetUrlFromAsx(url);
}

// ustawia parametry wyswietlane w warstwie dodatkowych informacji
function slPlayerSetDesc(title, timeString, description) {
	var pluginObject = document.getElementById("silverlightObject");
	if(pluginObject){pluginObject.Content.Player.SetInfo(title, timeString, description);}
}

// zatrzymanie odtwarzania
function slPlayerStop() {
	var pluginObject = document.getElementById("silverlightObject");
	pluginObject.Content.Player.Stop();    
}

// rozpoczecie odtwarzania
function slPlayerStart() {
	var pluginObject = document.getElementById("silverlightObject");
	pluginObject.Content.Player.Start();    
}

// wstrzymanie odtwarzania
function slPlayerPause() {
	var pluginObject = document.getElementById("silverlightObject");
	pluginObject.Content.Player.Pause();    
}

// ustawianie aspect ratio (proporcji obrazu)
function slPlayerSetRatio(ratio) {
	var pluginObject = document.getElementById("silverlightObject");
	pluginObject.Content.Player.SetRatio(ratio);
}

// resetowanie aspect ratio (proporcji obrazu)
function slPlayerResetRatio() {
	var pluginObject = document.getElementById("silverlightObject");
	pluginObject.Content.Player.ResetRatio();
}

// ustawianie stretch (rozciagania obrazu)
function slPlayerSetStretch(stretch) {
    var pluginObject = document.getElementById("silverlightObject");
    pluginObject.Content.Player.SetStretch(stretch);
}

// funkcja wolana po nacisnieciu przycisku pokaz podobne.
function slPlayerEventOnShowSimilar() {
	return;
	alert("slPlayerEventOnShowSimilar");
}

// funkcja wolana po nacisnieciu przycisku przeslij link.
function slPlayerEventOnSendAndShare() {
	return;
	alert("slPlayerEventOnSendAndShare");
}

// funkcja wolana po nacisnieciu przycisku pomoc.
function slPlayerEventOnHelp() {
	document.location.href='http://www.tvp.pl/pomoc/czeste-pytania';
}

// funkcja wolana po zaladowaniu obiektu
function slPlayerEventOnLoad() {
	var advInfo=document.getElementById('addInfoplayerStat');
	if(typeof playVideo != 'undefined'){
		slPlayerSetMode(playVideo.play_mode);
		slPlayerSetRatio(slPlayerData.ratio);
		slPlayerSetUrlFromAsx(slPlayerData.host + slPlayerData.asx);
		slPlayerSetDesc(slPlayerData.title,slPlayerData.timeString,slPlayerData.description);
//		slPlayerSetStretch(false);
	}
	if(typeof playVideo.adv_info_stat != 'undefined' && advInfo){
		advInfo.innerHTML=playVideo.adv_info_stat;
	}
}

// funkcja wolana po kliknieciu na metarial reklamowy.
function slPlayerEventOnAdvertClick(url) {
	if(url.length > 0){
		window.open(url,'adv_site');
//		alert("slPlayerEventOnAdvertClick: " + url + ' = ' + url.length);
	}
}

function onSilverlightError(sender, args) {
	var appSource = "";
	if (sender != null && sender != 0) {
		appSource = sender.getHost().Source;
	}
	var errorType = args.ErrorType;
	var iErrorCode = args.ErrorCode;
	if (errorType == "ImageError" || errorType == "MediaError") {
		return;
	}
	var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;
	errMsg += "Code: "+ iErrorCode + "    \n";
	errMsg += "Category: " + errorType + "       \n";
	errMsg += "Message: " + args.ErrorMessage + "     \n";
	if (errorType == "ParserError") {
		errMsg += "File: " + args.xamlFile + "     \n";
		errMsg += "Line: " + args.lineNumber + "     \n";
		errMsg += "Position: " + args.charPosition + "     \n";
	}
	else if (errorType == "RuntimeError") {           
		if (args.lineNumber != 0) {
				errMsg += "Line: " + args.lineNumber + "     \n";
				errMsg += "Position: " +  args.charPosition + "     \n";
		}
		errMsg += "MethodName: " + args.methodName + "     \n";
	}
	throw new Error(errMsg);
}

var advURL='', WMPinfo='';
function wmpMediaChange(Item){var wmp=document.getElementById(player.wmpID);advURL=wmp.currentMedia.getItemInfo("bannerInfoURL");}
function ClickAdvert(nButton, nShiftState, fX, fY){if(advURL!='' && nButton==1){window.open(advURL, '_blank');}}

/** ad */
function adStatsGem(loc_gemius_identifier){
	var gemius_proto;
	if(document.location && document.location.protocol) { gemius_proto = 'http'+((document.location.protocol=='https:')?'s':'')+':'; }
	else { gemius_proto = 'http:'; }
	var gemius_url = gemius_proto+'//pro.hit.gemius.pl/_'+(new Date()).getTime()+'/redot.gif?l=11&id='+loc_gemius_identifier+gemius_parameters();
	if (typeof window.gemius_images == 'undefined') { window.gemius_images = new Array(); }
	var gemius_l = window.gemius_images.length;
	if (typeof gemius_sem == 'undefined') { gemius_sem=0; }
	if (gemius_l<=gemius_sem) { window.gemius_images[gemius_l]=new Image(); window.gemius_images[gemius_l].src = gemius_url; }
	gemius_sem++;
}

function playmobile_campaign_friends(){
_gde_veghlninyx = new Image(1,1);
_gde_veghlninyx.src='http://gde-default.hit.gemius.pl/_'+(new Date()).getTime()+'/redot.gif?id=d2CaqEuqY5cQe8l204orOcPazQ._IWb.DWroSVpF9h7.P7/stparam=veghlninyx';
adStatsGem('.XbqJiN1IwK3cfGbtkrJ7ZXmrmGdteciMh7stOxpF7D.C7');
}
function playmobile_campaign_wind(){
_gde_sepiqmjgdk = new Image(1,1);
_gde_sepiqmjgdk.src='http://gde-default.hit.gemius.pl/_'+(new Date()).getTime()+'/redot.gif?id=d2CaqEuqY5cQe8l204orOcPazQ._IWb.DWroSVpF9h7.P7/stparam=sepiqmjgdk';
adStatsGem('B3LgwqsNt8xbf1DGqRtwbqSfDqr6Tqdwd5amJZIO79P.P7');
}
function uni_campain(grab){
if(grab == 'danonki_campaign'){
_gde_zglopxqlkh = new Image(1,1);
_gde_zglopxqlkh.src='http://gde-default.hit.gemius.pl/_'+(new Date()).getTime()+'/redot.gif?id=zUCaqCOt47I8WyjCBwC5eMSs76D_KKd_19TTwQmsxWH.17/stparam=zglopxqlkh';
}
}
function danonki_campaign(){
	uni_campain('danonki_campaign');
}

var bbs=screen,bbn=navigator,bbh;
bbh='&ubl='+bbn.browserLanguage+'&ucc='+bbn.cpuClass+'&ucd='+bbs.colorDepth+'&uce='+bbn.cookieEnabled+'&udx='+bbs.deviceXDPI+'&udy='+bbs.deviceYDPI+'&usl='+bbn.systemLanguage+'&uje='+bbn.javaEnabled()+'&uah='+bbs.availHeight+'&uaw='+bbs.availWidth+'&ubd='+bbs.bufferDepth+'&uhe='+bbs.height+'&ulx='+bbs.logicalXDPI+'&uly='+bbs.logicalYDPI+'&use='+bbs.fontSmoothingEnabled+'&uto='+(new Date()).getTimezoneOffset()+'&uti='+(new Date()).getTime()+'&uui='+bbs.updateInterval+'&uul='+bbn.userLanguage+'&uwi='+bbs.width;
dojo.addOnLoad(function(){
if(typeof(bburlparam)=='string') { bbh+='&'+bburlparam; }
if(typeof(bbkeywords)=='string') { bbh+='&keywords='+escape(bbkeywords); }
});

function getBBElementsData() {
	if (bbh != null && bbh.length > 0) {
		return bbh;
	} else {
		return "";
	}
}

document.write('\x3Cscript type="text/javascript" src="/gemius/gemiussarg.js"\x3E\x3C/script\x3E');

