// This script will add the Player preference box on video pages.  Based on the selection, it will load the appropriate player and play the video. HJB
var gstrPlayer = "";
var gstrSpeed = "";
var gstrWidth = "";
var gstrHeight = "";
var gstrLang = "";
var gstrVid = "";
var gstrErr = "";
// following are for displaying the text in the createWindow box
var gstrParagraph = "Выберите плеер и скорость соединения:‎";
var gstrHeadingSpeed = "Скорость соединения";
var gstrHeadingPlayer = "Медиаплеер";
var gstrSpeedHigh = "Высокая (256k и более)‎";
var gstrSpeedStandard = "Обычная (менее 256k)‎";
var gstrSelect = "OK";
var gstrErr = "Для просмотра этого файла на вашем компьютере должна быть установлена программа Adobe Flash Player.";

	window.onload=selectPlayer;

function selectPlayer() {
		//collects the video name and language symbols from the filename
		var urlPath = window.location.pathname.split("/");
		var file = urlPath[urlPath.length-1];
		gstrVid = file.substring(0,6);
		document.getElementById("player").innerHTML = "<div class=\"select\"><p>" + gstrParagraph + "</p><form><h4>" + gstrHeadingPlayer + "</h4><input type=\"radio\" name=\"player\" id=\"flash\" value=\"Flash Player\" checked>Flash Player<br><input type=\"radio\" name=\"player\" id=\"real\" value=\"RealPlayer\">RealPlayer<br><input type=\"radio\" name=\"player\" id=\"wmp\" value=\"Windows Media Player\">Windows Media Player<hr><h4>" + gstrHeadingSpeed + "</h4><input type=\"radio\" name=\"speed\" id=\"standard\" value=\"Standard\" checked>" + gstrSpeedStandard + "<br><input type=\"radio\" name=\"speed\" id=\"high\" value=\"High\">" + gstrSpeedHigh + "<br><br><input type=\"button\" id=\"select\" value=\"" + gstrSelect + "\" title=\"" + gstrSelect + "\" onClick=\"javascript:makePlayer();\"></form></div>";
}

//adds the appropriate player
function  makePlayer() {
	if (document.getElementById("flash").checked == true){
	gstrPlayer = ".swf";
	}
	if (document.getElementById("wmp").checked == true){
	gstrPlayer = ".wvx";
	}
	if (document.getElementById("real").checked == true){
	gstrPlayer = ".rpm";
	}
	if (document.getElementById("standard").checked == true){
	gstrSpeed = "240180";
		if(document.getElementById("flash").checked == true){
				gstrWidth = "262";
				gstrHeight = "231";
			}else if(document.getElementById("real").checked == true){
				gstrWidth = "240";
				gstrHeight = "180";
			}else{
				gstrWidth = "240";
				gstrHeight = "256";
			}
	}
	if (document.getElementById("high").checked == true){
	gstrSpeed = "320240";
		if(document.getElementById("flash").checked == true){
				gstrWidth = "342";
				gstrHeight = "291";
			}else if(document.getElementById("real").checked == true){
				gstrWidth = "320";
				gstrHeight = "240";
			}else{
				gstrWidth = "320";
				gstrHeight = "316";
			}	
	}

	if(gstrPlayer == ".swf") {
			document.getElementById('player').innerHTML = "<a href=\"javascript:history.go(0)\"><img src=\"/images/refresh.gif\" width=\"30\" height=\"24\" border=\"0\"></a><br><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + gstrWidth + "\" height=\"" + gstrHeight + "\" id=\"FLVPlayer\"><param name=\"movie\" value=\"" + gstrVid + gstrSpeed + gstrPlayer + "\"><param name=\"salign\" value=\"lt\"><param name=\"quality\" value=\"high\"><param name=\"scale\" value=\"noscale\"><param name=\"allowscriptaccess\" value=\"sameDomain\"><param name=\"FlashVars\" value=\"&MM_ComponentVersion=1&skinName=Halo_Skin_2&streamName=" + gstrVid + gstrSpeed + "&autoPlay=true&autoRewind=false\"><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"" + gstrVid + gstrSpeed + gstrPlayer + "\" width=\"" + gstrWidth + "\" height=\"" + gstrHeight + "\" id=\"FLVPlayer\"><param name=\"salign\" value=\"lt\"><param name=\"quality\" value=\"high\"><param name=\"scale\" value=\"noscale\"><param name=\"allowscriptaccess\" value=\"sameDomain\"><param name=\"FlashVars\" value=\"&MM_ComponentVersion=1&skinName=Halo_Skin_2&streamName=" + gstrVid + gstrSpeed + "&autoPlay=true&autoRewind=false\"><!--<![endif]--><p>" + gstrErr +"</p><!--[if !IE]>--></object><!--<![endif]--></object>";
		}

	if(gstrPlayer == ".wvx") {
			document.getElementById('player').innerHTML = "<a href=\"javascript:history.go(0)\"><img src=\"/images/refresh.gif\" width=\"30\" height=\"24\" border=\"0\"></a><br><object classid=\"clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6\" width=\"" + gstrWidth + "\" height=\"" + gstrHeight + "\" id=\"wmp10\" type=\"application/x-oleobject\"><param name=\"url\" value=\"" + gstrVid + gstrSpeed + gstrPlayer + "\"><param name=\"showcontrols\" value=\"true\"><param name=\"autostart\" value=\"true\"><param name=\"ShowDisplay\" value=\"false\"><param name=\"uiMode\" value=\"full\"><param name=\"loop\" value=\"false\"><embed type=\"application/x-mplayer2\" src=\"" + gstrVid + gstrSpeed + gstrPlayer + "\" width=\"" + gstrWidth + "\" height=\"" + gstrHeight + "\" showcontrols=\"1\" showdisplay=\"0\" autostart=\"1\" loop=\"false\"></embed></object>";
		}

	if(gstrPlayer == ".rpm") {
			document.getElementById('player').innerHTML = "<a href=\"javascript:history.go(0)\"><img src=\"/images/refresh.gif\" width=\"30\" height=\"24\" border=\"0\"></a><br><object classid=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" width=\"" + gstrWidth + "\" height=\"" + gstrHeight + "\" id=\"rmp\"><param name=\"src\" value=\"" + gstrVid + gstrSpeed + gstrPlayer + "\"><param name=\"controls\" value=\"ImageWindow\"><param name=\"autostart\" value=\"true\"><param name=\"console\" value=\"video\"><embed src=\"" + gstrVid + gstrSpeed + gstrPlayer + "\" name=\"RealPlayer\" width=\"" + gstrWidth + "\" height=\"" + gstrHeight + "\" controls=\"ImageWindow\" autostart=\"true\" console=\"video\"></embed></object><object classid=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" width=\"" + gstrWidth + "\" height=\"20\"><param name=\"controls\" value=\"ControlPanel\"><param name=\"console\" value=\"video\"><embed src=\"" + gstrVid + gstrSpeed + gstrPlayer + "\" name=\"RealPlayer\" width=\"" + gstrWidth + "\" height=\"20\" controls=\"ControlPanel\" console=\"video\"></embed></object>";
		}

}
