var main_menu_id = 0;

function SelectMenu(sub_id)
{
        var i = 1;
        var sub_tr = document.getElementById('sub_'+sub_id+'_'+i);
        while (sub_tr)
        {
                sub_tr.style.display = '';
                i++;
                sub_tr = document.getElementById('sub_'+sub_id+'_'+i);
        }

        var menu_item = document.getElementById('menu_'+sub_id);
        if (menu_item)
        {
                if (menu_item.className == 'menu_left')
                {
                        menu_item.className = 'menu_left_selected';
                }
        }
}

function ChangeImage(img_id)
{
	var img  = document.getElementById('change_image');
	var div1 = document.getElementById('change_div');
	var div2 = document.getElementById('change_img');

	if (img_id == 0)
	{
		div1.style.display = '';
		div2.style.display = 'none';
	}
	else
	{
		img.src = "/img/page"+img_id+".jpg";
		div1.style.display = 'none';
		div2.style.display = '';
	}
}

function ChangeSelectedItem(item_id, item_set)
{
	var image_id = (item_set) ? item_id : 0;
	ChangeImage(image_id);

	var head = document.getElementById('head_'+item_id);
	if (head)
	{
		head.className = (item_set == false) ? 'not_selected': 'selected';
	}

	var resume = document.getElementById('resume_'+item_id);
	if (resume)
	{
		resume.className = (item_set == false) ? 'text_resume': 'text_resume_selected';
	}
}

function ChangeLocation(doc_id)
{
	location.href = '/cntnt/'+doc_id+'.html';
}

function GetFlashEnabled()
{
	var UseFlash = -1;
	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])
	{
		var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
		if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1))>=4)
			UseFlash = 1;
	}
	else if (navigator.mimeTypes.length == 0 && navigator.plugins.length == 0)
	{
		for(var i=10; i>4; i--)
		{
			try
			{
				var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
				UseFlash = i;
				break;
			}
			catch(e){}
		}//for
	}

	return UseFlash;
}
var isFlash = (GetFlashEnabled() > 0) ? true : false;

function EchoFlash()
{
	if (isFlash)
	{
		document.write('<div style="margin: 0px; padding: 0px;" id="change_div">');
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="350" height="346" id="yf11" align="middle">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="movie" value="/img/flash.swf?pic_id=0" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="bgcolor" value="#ffdf8c" />');
		document.write('<embed src="/img/flash.swf?pic_id=0"  quality="high" bgcolor="#ffdf8c" width="350" height="346" name="yf11" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object>');
		document.write('</div>');
	}
	else
	{
		document.write('<div style="margin: 0px; padding: 0px;" id="change_div"><img src="/img/page0.jpg" alt="" border="0" id="change_image" width="350" height="346" /></div>');
	}

	document.write('<div style="margin: 0px; padding: 0px; display: none;" id="change_img"><img src="/img/page0.jpg" alt="" border="0" id="change_image" width="350" height="346" /></div>');
}

function MainMenu(item_id, item_set)
{
	var img = document.getElementById('main_menu_0_'+item_id);
	if (img)
	{
		img.src = (item_set) ? "/img/menu_0.gif" : "/img/spacer.gif";
	}
	var item = document.getElementById('main_menu_2_'+item_id);
	if (item)
	{
		item.className = (item_set) ? "main_menu_selected" : "main_menu";
	}

	img = document.getElementById('main_menu_1_'+item_id);
	if (img)
	{
		img.src = (item_set) ? "/img/menu_1.gif" : "/img/spacer.gif";
	}
}

function Menu(item_id, item_set)
{	var item = document.getElementById('menu_'+item_id);
	if (item)
	{
		if (item.className != 'menu_left_selected')
		{
			item.className = (item_set) ? "menu_left_hover" : "menu_left";
		}
	}
}

function SubMenu(main_id, item_id, item_set)
{	var item = document.getElementById('menu_sub_'+main_id+'_'+item_id);
	if (item)
	{
		if (item.className != 'menu_sub_selected')
		{
			item.className = (item_set) ? "menu_sub_hover" : "menu_sub";
		}
	}
}

function SelectItem(doc_num)
{	if (doc_num > 0)
	{		var item = document.getElementById('menu_sub_'+main_menu_id+'_'+doc_num);
		if (item)
		{
			item.className = 'menu_sub_selected';
		}
	}
}

function SetMainMenuID(main_menu)
{	main_menu = main_menu ? main_menu : 0;
	main_menu_id = main_menu;
}

function doPic(imgPic)
{	var img = document.getElementById('img_preview');
	if (img)
	{		img.src = imgPic;
	}
}

var img_count = 0;
function WriteImage(imgName)
{
	if ((imgName != '/engine/pics/catalog/0.gif')&&(imgName != ''))
	{
		document.write('<img src="'+imgName+'" alt="" class="img_preview" border="0" />');
	}
}

function WriteTrailer(filePath, fileImg)
{
	if (filePath.indexOf('.flv') > 0)
	{
		if (isFlash)
		{
			flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="215" height="215" id="test" align="middle">'
			      +   '<param name="movie" value="/VPlayer.swf?flvURL='+filePath+'" />'
                              +   '<param name="allowScriptAccess" value="sameDomain" />'
                              +   '<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'
                              +   '<embed src="/VPlayer.swf?flvURL='+filePath+'" quality="high" bgcolor="#ffffff" width="215" height="215" name="VPlayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
                              + '</object>';
         		document.write(flash);
		}
		else
		{
			document.write('<img src="'+fileImg+'" border="0" class="img_big" alt="" style="margin-top: 5px;" />');
			document.write('<br /><a href="'+filePath+'" target="_blank">Скачать трейлер</a>');
		}
	}
	else
	{
		if (filePath != '')
		{
			document.write('<img src="'+fileImg+'" border="0" class="img_big" alt="" style="margin-top: 5px;" />');
			document.write('<br /><a href="'+filePath+'" target="_blank">Скачать трейлер</a>');
		}
		else
		{
			document.write('<img src="'+fileImg+'" border="0" class="img_big" alt="" style="margin-top: 5px;" />');
		}
	}
}