
RegisterNamespaces("Inpl.Itv");

Inpl.Itv=new function() {

	this.$=function(x){return document.getElementById(x)}

	this.insertWmp=function(url) {
		try{
			if (streamIsBlocked==2)
			{
			 $('mplayer').innerHTML = '<img src="../img/player/screen_ipblocked.gif" class="nostream" alt="Strumien jest niedostepny" width="394px" height="330px"/>';
			 $('mplayerControls').style.display = 'none';
			}
			else if (streamIsBlocked)
			{
			 $('mplayer').innerHTML = '<img src="../img/player/screen_notavailable.gif" class="nostream" alt="Strumien jest niedostepny" width="394px" height="330px"/>';
			 $('mplayerControls').style.display = 'none';
			}
			else if (INTPL('isIe'))
			{
			 $('mplayer').innerHTML = '<OBJECT ID="wmp" width="385" height="290" \
				classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6"\
				CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"\
				standby="Loading Microsoft Windows Media Player components..."\
				type="application/x-oleobject">\
				<PARAM NAME="AutoStart" VALUE="True">\
				<PARAM NAME="FileName" VALUE="' + url + '">\
				<PARAM NAME="Url" VALUE="' + url + '">\
				<PARAM NAME="fullScreen" VALUE="false">\
				<PARAM NAME="animationatStart" VALUE="true">\
				<PARAM NAME="defaultFrame" VALUE="UrlTagFrame">\
				<param name="captioningId" value="ClipData">\
				<param name="invokeURLs" value="' + (INTPL('isIe')?false:true) + '" />\
				<param name="windowlessvideo" value="false" />\
				<param name="volume" value="'+(this.volume*10)+'" />\
				<param name="stretchToFit" value="true" />\
				<param name="uiMode" value="' + (INTPL('isIe')?'none':'mini') + '" />\
				<param name="ShowCaptioning" value="false" />\
				<param name="ShowTracker" value="false" />\
				<PARAM NAME="ShowControls" VALUE="false" />\
				<PARAM NAME="ShowStatusBar" VALUE="true" />\
				<param name="enableContextMenu" value="true" />\
				<param name="EnableFullScreenControls" value="true" />\
				<param name="Mute" value="false" />\
				</OBJECT>';
			 $('mplayerControls').style.display = 'block';
			 $('mplayerControlsCommon').style.display = 'inline';
			 $('mplayerControlsIE').style.display = 'inline';
			}
			else if (INTPL('isOpera'))
			{
	$('mplayer').innerHTML = '<EMBED type="application/x-ms-wmp"\
					pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"\
					SRC="'+url+'"\
					name="MediaPlayer1"\
					width="385"\
					height="290"\
					autostart="1"\
					defaultFrame="UrlTagFrame"\
					windowlessvideo="false"\
					volume="100"\
					stretchToFit="true"\
					invokeURLs="false"\
					uiMode="none"\
					enableContextMenu="false"\
					ShowCaptioning="0"\
					captioningId="ClipData"\
					ShowControls="0" \
					ShowAudioControls="0"\
					ShowDisplay="0"\
					ShowGotoBar="0"\
					ShowPositionControls="0"\
					ShowStatusBar="0"\
					ShowTracker="0"\
					mute="0"\
				</EMBED>';
				$('mplayerControls').style.display = 'block';
				$('mplayerControlsCommon').style.display = 'inline';
				$('mplayerControlsIE').style.display = 'none';
				if (url) $('playerStateInfo').src="img/player/anim_odtwarzanie.gif"
			}
			else
			{
				//http://lokal.itvp.pl/asx/6/6/217.74.64.247.44b26a182fa281.71716066.asx
				$('mplayer').innerHTML = '<EMBED type="application/x-ms-wmp"\
					pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"\
					SRC="'+url+'"\
					name="MediaPlayer1"\
					width="385"\
					height="290"\
					autostart="1"\
					defaultFrame="UrlTagFrame"\
					windowlessvideo="TRUE"\
					volume="100"\
					stretchToFit="true"\
					invokeURLs="' + (INTPL('isIe')?false:true) + '"\
					uiMode="' + (INTPL('isIe')?'none':'none') + '"\
					enableContextMenu="false"\
					ShowCaptioning="0"\
					captioningId="ClipData"\
					ShowControls="0" \
					ShowAudioControls="0"\
					ShowDisplay="0"\
					ShowGotoBar="0"\
					ShowPositionControls="0"\
					ShowStatusBar="0"\
					ShowTracker="0"\
					mute="0"\
				</EMBED>';
				$('mplayerControls').style.display = 'block';
				$('mplayerControlsCommon').style.display = 'inline';
				$('mplayerControlsIE').style.display = 'none';
				if (url) $('playerStateInfo').src="img/player/anim_odtwarzanie.gif"
			};

		} catch(e) {}
	}//insertWmp(url)

	this.WmpDoFullScreen = function() {
		try { document.wmp.fullScreen='true'; }
		catch (e) { $('wmp').DisplaySize = 3; };
	}//WmpDoFullScreen
	
	this.infoInsert = function(url) {
		try { document.wmp.fullScreen='true'; }
		catch (e) { $('wmp').DisplaySize = 3; };
	}//WmpDoFullScreen

	this.flInsert = function(url, width, height, obj, trans,FlashVars) {



		var flCode = ' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
		flCode += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
		flCode += ' width="'+width+'" height="'+height+'" ';
		flCode += '  align="middle">';
		flCode += '         <param name="allowScriptAccess" value="sameDomain" />';
		flCode += '         <param name="movie" value="'+url+'" />';
		flCode += '         <param name="quality" value="high" />';
		if (trans) flCode += '         <param name="wmode" value="transparent"/>';
		flCode += '         <param name="FlashVars" value="flashId='+document.flashId+(FlashVars ? '&'+FlashVars:'')+'"/>';
		flCode += '         <embed ';
		flCode += '          src="'+url+'"';
		flCode += '          quality="high" width="'+width+'" height="'+height+'"';
		flCode += '          align="middle" allowScriptAccess="sameDomain"';
		flCode += '          type="application/x-shockwave-flash" ';
		if (trans) flCode += '          wmode="transparent"';
		flCode += '          FlashVars="flashId='+document.flashId+(FlashVars ? '&'+FlashVars:'')+'"';
		flCode += '          pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		flCode += ' </object>';

		document.getElementById(obj).innerHTML = flCode;

	}


	this.volume = 10

	this.setVolume = function (amount) {
		if (amount == 'up' && this.volume < 10){
			this.volume++
			this.$('volumeLevel').src = '../img/player/vol_'+this.volume+'.gif';
		}
		else if (amount == 'down' && this.volume > 0) {
			this.volume--
			this.$('volumeLevel').src = '../img/player/vol_'+this.volume+'.gif';
		}
		try {
				document.wmp.settings.volume=this.volume*10;
				$('mutebutton').src="../img/player/silence"+(document.wmp.settings.mute ? "_off":"")+".gif";
			} catch(e) { };
	}

	this.play = function () {
		try { document.wmp.controls.play(); }
		catch(e)
		 {
			changeBitrate(currentBitrate,true);
			$('playerStateInfo').src="../img/player/anim_odtwarzanie.gif"
		 };
	}

	this.stop = function () {
		try { document.wmp.controls.stop(); }
		catch(e)
		 {
			$('mplayer').innerHTML = '\
			 <div align="center">\
			 	<img src="../img/player/screen_stopped.gif"/>\
			 </div>\
			';
			$('playerStateInfo').src="../img/player/anim_stop.gif"
		 };
	}

	this.mute = function () {
		try {
				document.wmp.settings.mute = !document.wmp.settings.mute;
				$('mutebutton').src="../img/player/silence"+(document.wmp.settings.mute ? "_off":"")+".gif";
		} catch(e) { };
	}
    	this.pause = function () {
		try { document.wmp.controls.pause(); }
		catch(e)
		 {
			changeBitrate(currentBitrate,true);
			$('playerStateInfo').src="../img/player/anim_odtwarzanie.gif"
		 };
	}

}//Inpl.Itv

