function HideAllObjectsInPlayer(id){
	document.getElementById('oPlayerIE_div'+id).innerHTML = '';
	document.getElementById('oPlayerIE_div'+id).style.display = 'none';

	document.getElementById('oFlash_div'+id).innerHTML = '';
	document.getElementById('oFlash_div'+id).style.display = 'none';

	document.getElementById('oIPIX_div'+id).innerHTML = '';
	document.getElementById('oIPIX_div'+id).style.display = 'none';

	document.getElementById('oImg_div'+id).innerHTML = '';
	document.getElementById('oImg_div'+id).style.display = 'none';

	document.getElementById('player_title'+id).innerHTML = '';
	document.getElementById('player'+id).style.display = 'none';
}

function putVideo(file, AutoStart, id){
    if (id == null) id = '';
	output = '<object id="oPlayerIE'+id+'" name="oPlayerIE'+id+'" classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" style="width:580px;height:511px;margin:0; border:0 inset white;" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" STANDBY="Loading MicrosoftR Windows Media? Player components..." TYPE="application/x-oleobject" VIEWASTEXT="VIEWASTEXT">';
	output += '<param name="FileName" value="' + file + '" />';
	output += '<param name="Url" value="' + file + '" />';
	output += '<param name="AutoStart" value="' + AutoStart + '" />';
	output += '<param name="ShowCaptioning" value="0" />';
	output += '<param name="AutoSize" value="1" />';
	output += '<param name="AutoRewind" value="0" />';
	output += '<param name="ShowDisplay" value="0" />';
	output += '<param name="ShowControls" value="1" />';
	output += '<param name="ShowTracker" value="1" />';
	output += '<param name="EnableContextMenu" value="1" />';
	output += '<param name="ShowPositionControls" value="0" />';
	output += '<param name="ShowStatusBar" value="1" />';
	output += '<param name="Center" value="1" />';
	output += '<param name="StreamCount" value="0" />';
	output += '<param name="wmode" value="opaque" />';
	output += '<embed width="580" height="511" src="' + file + '" center="1" type="application/x-mplayer2" controls="ImageWindow" ShowStatusBar="1" PlayCount="1" ShowControls="1" ShowPositionControls="0" AutoSize="0" pluginspage="http://www.microsoft.com/Windows/MediaPlayer" AutoStart="' + AutoStart + '" displaysize="3"></embed>';
	output += '</object>';

	return output;
}

function SetPictureToPlayer(code, file, type, subtype, title, pic, id, AutoStart) {
    file = new String(file);
    if (id == null) id = '';
	HideAllObjectsInPlayer(id);
	
	document.getElementById('player'+id).style.display = 'block';
	
	// Просто вставляем код как есть
	if (type == 'object') {	    
	    document.getElementById('oPlayerIE_div'+id).innerHTML = '<div>' + code + '</div>';
	    document.getElementById('oPlayerIE_div'+id).style.display = 'block';
	} 
	
	// Нам дали ссылку на файл, по расширению файла или по подтипу определяем, на какой именно
	else if (type == 'file' || type == 'stream') {	    

	    // Простое изображение
	    if ((type == 'stream' && subtype == 'image') || (file.search(/\.jpg/i)!=-1 || file.search(/\.gif/i)!=-1 || file.search(/\.png/i)!=-1)) {
    		if (!document.getElementById('oImg'+id)) document.getElementById('oImg_div'+id).innerHTML = '<img id="oImg'+id+'" name="oImg'+id+'" src="' + file + '" />';
    		else document.getElementById('oImg'+id).src = file;
    		document.getElementById('oImg_div'+id).style.display = 'block';
	    }
	    
	    // Видео-файл
	    else if ((type == 'stream' && subtype == 'video') || (file.search(/\.avi/i)!=-1 || file.search(/\.wmv/i)!=-1)) {
            if (!document.getElementById('oPlayerIE'+id)) document.getElementById('oPlayerIE_div'+id).innerHTML = putVideo(file, AutoStart, id);
            document.getElementById('oPlayerIE_div'+id).style.display = 'block';
	    }
	    
	    // IPIX-панорама
	    else if ((type == 'stream' && subtype == 'ipix') || file.search(/\.ipx/i)!=-1) {
            if (document.getElementById('oIPIX'+id)) document.getElementById('oIPIX_div').innerHTML = '';
            document.getElementById('oIPIX_div'+id).innerHTML = '<object id="oIPIX'+id+'" width="100%" height="100%" classid="clsid:11260943-421B-11D0-8EAC-0000C07D88CF" codebase="http://www.ipix-i.com/download/ipixx.cab#version=6,2,0,5" name="IpixX1" vspace="0" hspace="0" border="0"><param name="_Version" value="65536"><param name="_ExtentX" value="11924"><param name="_ExtentY" value="9278"><param name="_StockProps" value="0"><param name="wmode" value="opaque" /><param name="IPXFILENAME" value="' + file +'"></object>';
            document.getElementById('oIPIX_div'+id).style.display = 'block';
	    }
	    
	    // Флешка
	    else if ((type == 'stream' && subtype == 'swf') || file.search(/\.swf/i)!=-1) {
	        if (!document.getElementById('oFlash'+id)) {
                document.getElementById('oFlash_div'+id).innerHTML = '<object id="oFlash'+id+'" name="oFlash'+id+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="580" height="511"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + file + '" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="wmode" value="opaque" /><param name="bgcolor" value="#ffffff" /><EMBED src="' + file + '" type="application/x-shockwave-flash" wmode="transparent" width="580" height="511" /></object>';
            }
            else document.getElementById('oFlash'+id).Movie = file;
            document.getElementById('oFlash_div'+id).style.display = 'block';
        }
        
        // Аудио-файл
        else if ((type == 'stream' && subtype == 'audio') || (file.search(/\.mp3/i)!=-1 || file.search(/\.wmv/i)!=-1)) {
			if (!document.getElementById('oPlayerIE'+id)) {
				document.getElementById('oPlayerIE_div'+id).innerHTML = '<OBJECT id="oPlayerIE'+id+'" name="oPlayerIE'+id+'" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab# Version=5,1,52,701" STANDBY="Loading Microsoft Windows® Media Player components..." TYPE="application/x-oleobject" width="280" height="46"><param name="fileName" value="' + file + '"><param name="animationatStart" value="true"><param name="transparentatStart" value="true"><param name="autoStart" value="true"><param name="wmode" value="opaque" /><param name="showControls" value="true"><param name="Volume" value="-300"><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="' + file + '" name="MediaPlayer1" width=280 height=46 autostart=1 showcontrols=1 volume=-300></OBJECT>';
			} else {
                document.getElementById('oPlayerIE'+id).FileName = file;
			}
			document.getElementById('oPlayerIE_div'+id).style.display = 'block';
        }

        // flv-файл
        else if ((type == 'stream' && subtype == 'flv') || (file.search(/\.iflv/i)!=-1 || file.search(/\.flv/i)!=-1)) {
            if (!document.getElementById('oPlayerIE'+id)) {
                document.getElementById('oPlayerIE_div'+id).innerHTML = '<object id="oPlayerIE'+id+'" name="oPlayerIE'+id+'" type="application/x-shockwave-flash" data="/player/uflvplayer_500x375-2.swf" height="440" width="580"><param name="bgcolor" value="#FFFFFF" /><param name="allowFullScreen" value="true" /><param name="movie" value="/player/uflvplayer_500x375-2.swf" /><param name="wmode" value="opaque" /><param name="FlashVars" value="way=' + file + '&amp;swf=/player/uflvplayer_500x375-2.swf&amp;w=580&amp;h=440&amp;pic=/files/' + pic + '&amp;autoplay=0&amp;tools=1&amp;skin=white&amp;volume=70&amp;q=&amp;comment=' + title + '" /></object>';
            } else {
                document.getElementById('oPlayerIE'+id).FileName = file;
            }
            document.getElementById('oPlayerIE_div'+id).style.display = 'block';
        }
	}
	
	// Нам дали нечно неопознанное
	else {
	    
	}

}

function showPlayer(arr){
	if (arr['act'] == 'start') {
		this.ID = arr['translation_pid'];
		this.translation_id = arr['translation_id'];
		this.translation = true;
		//document.getElementById('player_title').innerHTML = 'Прямая трансляция';
		SetPictureToPlayer(arr['code'], arr['file'], arr['type'], arr['subtype'], arr['title'], arr['pic'], '', 1);
		for (i in this.experts) {
			if (this.experts[i]) {
				if (this.experts[i]['id']) {
					if (document.getElementById('expert'+this.experts[i]['id'])) {
						document.getElementById('expert'+this.experts[i]['id']).style.display = 'block';
					}
				}
			}
		}
	} else if (arr['act'] == 'stop') {
		HideTranslation();
	} else {
	}
	this.refresh_time['player']['time'] = arr['time'];
}
