	function go_to(url)
	{
		location.href = url;
	}

	function get_el(id) { return document.getElementById(id); }

	function mOver(id)
	{
		get_el("img1").style.display = 'none';
		get_el("img2").style.display = 'none';
		get_el("img3").style.display = 'none';
		get_el("img"+id).style.display = 'block';

		get_el("a1").className = '';
		get_el("a2").className = '';
		get_el("a3").className = '';
		get_el("a"+id).className = 's';
	}

	function mOverFade( idx )
	{
		if ( loopTimer != null )
		{
			clearTimeout( loopTimer );
		}

		$("a.s" ).removeClass('s');
		$("#a" + idx).addClass('s');

		if ( $("#announce_area").children().children().attr("id") != "img" + idx )
		{
			$("#announce_area").html( $("#announce_0").html() );
			$("#announce_area").html( $("#announce_" + idx).html() );
			$("#announce_area").children().fadeIn(500);
		}
	}

	function initLoopSlideShow()
	{
		mOverFade( aSlideshowIdx[ loopSlideshowCount++] );

		if (loopSlideshowCount < 3)
			loopTimer = setTimeout('initLoopSlideShow()', 6000);
	}

	function OpenFile(url,width,height)
	{
		var Left = (screen.width - width) / 2 - 5;
		var Top = (screen.height - height) / 2 - 29;
		var Scroll = typeof(arguments[3])=='undefined'?'no':arguments[3];
		shown=window.open(url,"","top="+Top+",left="+Left+",width="+width+",height="+height+",scrollbars="+Scroll+",status=no,resizable=yes,high");

		return false;
	}

function myBookMark(url, title)
{
  if (!url) url = location.href;
  if (!title) title = document.title;

  //Gecko
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function"))
  {
	//  window.sidebar.addPanel (title, url, "");
  }
  //IE4+
  else if (typeof window.external == "object") window.external.AddFavorite(url, title);
  //Opera7+
  else if (window.opera && document.createElement)
  {
  }
  else
  	return false;
  var href = location.href;
  var host = href.substr( 0, href.indexOf( '/', 9 ) );
  var link = host + "/bitrix/redirect.php?event1=addToFavorites&goto="
  location.href = link + location.href;

  return true;
}

$(document).ready( init );

function init()
{
	//gameRedirect();
	if ( window.initComments && Function == window.initComments.constructor )
	{
		initComments();
	}

	if ( window.initVideoTrailer && Function == window.initVideoTrailer.constructor )
	{
		initVideoTrailer();
	}

	howToDownload();
	var menu = document.getElementById('menu_div');
	var main = document.getElementById('middle_div');

	if (menu && main)
	{
		if (menu.offsetHeight > main.offsetHeight) main.style.height = menu.offsetHeight + "px";
	}
}

// START: VIDEO TRAILER
function initVideoTrailer()
{
	$( "#watch" ).click( function() {
		video();
	} );
}

function video()
{
	if ( $("#video_cont").is(":visible") )
	{
		$("#video_cont").toggle();
		$("#watch").text( 'เ?ศเฤเลเฮ เฮเฯเศแ?ภเอเศเล' );

		var video0 = document.getElementById('video_0');

		if ( video0 )
			$("#video_0").html('');
	}
	else
	{
		$("#video_cont").toggle();
		$("#watch").text( 'เจเยเลแ?อแ???เยเศเฤเลเฮ' );

		var video0 = document.getElementById('video_0');
		var video1 = document.getElementById('video_1');

		if ( video0 && video1 )
			$("#video_0").html($("#video_1").html());
	}

	return false;
}
// END: VIDEO TRAILER

// START: GAME REDIRECT
function doRedirect( url )
{
	window.location = url;
}

function gameRedirect()
{
	if ( window.redirectRules && getRedirectCookie() == null )
	{
		var languageInfo = navigator.language ? navigator.language : navigator.browserLanguage;
		var langCode = languageInfo.substr( 0, 2 ).toLowerCase();
		jQuery.each( redirectRules, function( idx, val ) {
			if ( langCode == val[0].toLowerCase() )
			{
				doRedirect( val[1] );
			}
		} );
	}
}

function getRedirectCookie()
{
	if ( location.search.indexOf( "rd=1" ) != -1 )
	{
		setRedirectCookie( 'http://' + location.host );
	}
	return getCookie( "ALAWAR_REDIRECT_SITE" );
}

function setRedirectCookie( redirectUrl )
{
	setCookie( "ALAWAR_REDIRECT_SITE", redirectUrl, 365 );
}
// END: GAME REDIRECT

function howToDownload()
{
		var ie = '<img src="/bitrix/templates/alawar6/images/browsers/en/exp.gif">';

		var ff = '<img width="381" height="183" src="/bitrix/templates/alawar6/images/browsers/en/ff20.gif"><br>and then <br>'+
		    '<img width="390" height="300" src="/bitrix/templates/alawar6/images/browsers/en/ff20_2.gif"><br>';

		var opera = '<br><img src="/bitrix/templates/alawar6/images/browsers/en/opera.gif"><br/>';

	  if(jQuery.browser.msie == true)
		{
			$("#browser_howto").html(ie);
		}
		else if(jQuery.browser.mozilla)
		{
	     $("#browser_howto").html(ff);
	  }
		else if(jQuery.browser.opera)
		{
	     $("#browser_howto").html(opera);
	  }
}

function howToDownloadRu()
{
	var ie = '<img height="129" align="right" width="177" alt="" src="/bitrix/templates/alawar6/images/browsers/ru/ienew.jpg"/>';

	var ff = '<img height="260" align="right" width="190" alt="" src="/bitrix/templates/alawar6/images/browsers/ru/ffnew.jpg"/>';

	var opera = '<img height="156" align="right" width="184" alt="" src="/bitrix/templates/alawar6/images/browsers/ru/opnew.jpg"/>';
	if(jQuery.browser.msie == true)
	{
		$("#browser_p_howto").html(ie);
	}
	else if(jQuery.browser.mozilla)
	{
	 $("#browser_p_howto").html(ff);
	}
	else if(jQuery.browser.opera)
	{
	 $("#browser_p_howto").html(opera);
	}
}

function InstallationHelpRu()
{
	var ie = 	'<h3>เ?ฮเฬเฮแ??เย แ???ภเอเฮเยเสเล เศเรแ??/h3>'+
				'<p style="padding:5px 0;">เฏแ?ฮเมแ?แ?สเภแ?ภแ??เฯเฮเอแ?ภเยเศเยแ?????เศเรแ?? เอเภเฦเฬเศแ?ล เอเภ เสเอเฮเฯเสแ?า<strong>เจเสเภแ?ภแ??เศเรแ??/strong>าห เศเหเศ เวเลเหเลเอแ??เศเสเฮเอเสแ?แ?เมเลเหเฮเษ แ???ลเหเสเฮเษ แ??ฤเฮเฬ แ?เอเภเวเยเภเอเศเลเฬ เศเรแ?? <img src="http://ru.i.alawar.ru/bitrix/templates/alawar6/images/ico_04.gif" width="16" height="16" alt="" /></p>'+
				'<p style="padding:0;"><img src="/bitrix/templates/alawar6/images/browsers/ru/ienew.jpg" width="177" height="129" alt="" align="right" vspace="5" hspace="5" />เ?ฮแ?หเล แ??ฮเรเฮ เฮแ?สแ?ฮเลแ???เฤเศเภเหเฮเรเฮเยเฮเล เฮเสเอเฮ แ?เฯแ?ลเฤเหเฮเฦเลเอเศเลเฬ แ?สเภแ?ภแ??เศเหเศ เวเภเฯแ???ศแ??เศเรแ?? เ?ภเฦเฬเศแ?ล เอเภ เสเอเฮเฯเสแ?า<strong>เ?ภเฯแ???ศแ??/strong>าห (า<strong>Run</strong>าห)  เศ เฤเฮเฦเฤเศแ?ลแ?? เสเฮเรเฤเภ เวเภเสเฮเอแ?ศแ???เวเภเรแ??วเสเภ เศเรแ??เอเภ เยเภแ?เสเฮเฬเฯแ???ลแ? เ??ฮแ?ลแ??แ?สเภแ?ศเยเภเอเศแ?เศเรแ??เฬเฮเฦเลแ?เวเภเอแ???เฮแ?เอเลแ?สเฮเหแ?สเศแ?แ?ลเสแ?อเฤ เฤเฮ 20-30 เฬเศเอแ?? เย เวเภเยเศแ?ศเฬเฮแ??ศ เฮแ?แ?สเฮแ?ฮแ??ศ เยเภแ?ลเรเฮ เศเอแ?ลแ?อเลแ?แ?ฮเลเฤเศเอเลเอเศแ?</p>'+
				'<p>เ?ฮแ?หเล เวเภเยเลแ??ลเอเศแ?เวเภเรแ??วเสเศ เฮแ?สแ?ฮเลแ???เฤเศเภเหเฮเรเฮเยเฮเล เฮเสเอเฮ. เ?ภเฦเฬเศแ?ล เสเอเฮเฯเสแ?า<strong>เ??ฯเฮเหเอเศแ??/strong>าห (า<strong>Open</strong>าห), แ??ฮเมแ?แ???ภเอเฮเยเศแ??เศเรแ??เอเภ เยเภแ?เสเฮเฬเฯแ???ลแ?(แ?หเลเฤแ?ษแ?ล แ?สเภเวเภเอเศแ?ฬ เอเภ แ?สแ?ภเอเล).</p>'+
				'<p>เ?ฮแ?หเล เวเภเยเลแ??ลเอเศแ?แ???ภเอเฮเยเสเศ เอเภเฦเฬเศแ?ล เอเภ เสเอเฮเฯเสแ?า<strong>เ?ฮแ?ฮเยเฮ</strong>าห, แ??ฮเมแ?เอเภแ?ภแ??เศเรแ??</p><br /><br />'+
				'<span class="block02" style="width: 370px;">'+
				'<img src="/bitrix/templates/alawar6/images/kasp.gif" width="185" height="23" alt="เ??ฮเยเลแ?ลเอเฮ เ?อแ?ศเยเศแ???ฮเฬ เ?ภแ?ฯเลแ??สเฮเรเฮ " style="margin-top:3px;" />'+
				'</span>'+
				'<p style="font-size:10px;">เ??ล เศเรแ??เฯแ?ฮเยเลแ?ลเอแ?เภเอแ?ศเยเศแ???ฮเฬ เ?ภแ?ฯเลแ??สเฮเรเฮ</p><br />'+
				'<p><a href="javascript:history.go(-1)">&laquo; เ?ลแ?อแ?????/a></p>';

	var ff = 	'<h3>เ?ฮเฬเฮแ??เย แ???ภเอเฮเยเสเล เศเรแ??/h3>'+
				'<p style="padding:5px 0;">เฏแ?ฮเมแ?แ?สเภแ?ภแ??เฯเฮเอแ?ภเยเศเยแ?????เศเรแ?? เอเภเฦเฬเศแ?ล เอเภ เสเอเฮเฯเสแ?า<strong>เจเสเภแ?ภแ??เศเรแ??/strong>าห เศเหเศ เวเลเหเลเอแ??เศเสเฮเอเสแ?แ?เมเลเหเฮเษ แ???ลเหเสเฮเษ แ??ฤเฮเฬ แ?เอเภเวเยเภเอเศเลเฬ เศเรแ?? <img src="http://ru.i.alawar.ru/bitrix/templates/alawar6/images/ico_04.gif" width="16" height="16" alt="" /></p>'+
			    '<p style="padding:0;"><img src="/bitrix/templates/alawar6/images/browsers/ru/ffnew.jpg" width="190" height="260" alt="" align="right" vspace="5" hspace="5" />'+
				'เ?ฮแ?หเล แ??ฮเรเฮ เฮแ?สแ?ฮเลแ???เฤเศเภเหเฮเรเฮเยเฮเล เฮเสเอเฮ แ?เฯแ?ลเฤเหเฮเฦเลเอเศเลเฬ แ?สเภแ?ภแ??เศเหเศ เวเภเฯแ???ศแ??เศเรแ?? เ?ภเฦเฬเศแ?ล เอเภ เสเอเฮเฯเสแ?า<strong>เจเฮแ??ภเอเศแ??แ?ภเษเห</strong>าห (า<strong>Save file</strong>าห)  เศ เฤเฮเฦเฤเศแ?ลแ?? เสเฮเรเฤเภ เวเภเสเฮเอแ?ศแ???เวเภเรแ??วเสเภ เศเรแ??เอเภ เยเภแ?เสเฮเฬเฯแ???ลแ? เ??ฮแ?ลแ??แ?สเภแ?ศเยเภเอเศแ?เศเรแ??เฬเฮเฦเลแ?เวเภเอแ???เฮแ?เอเลแ?สเฮเหแ?สเศแ?แ?ลเสแ?อเฤ เฤเฮ 20-30 เฬเศเอแ?? เย เวเภเยเศแ?ศเฬเฮแ??ศ เฮแ?แ?สเฮแ?ฮแ??ศ เยเภแ?ลเรเฮ เศเอแ?ลแ?อเลแ?แ?ฮเลเฤเศเอเลเอเศแ?</p>'+
				'<p>เ?ฮแ?หเล เวเภเยเลแ??ลเอเศแ?เวเภเรแ??วเสเศ เฮแ?สแ?ฮเลแ???เฤเศเภเหเฮเรเฮเยเฮเล เฮเสเอเฮ. เ?ภเฦเฬเศแ?ล เสเอเฮเฯเสแ?า<strong>เ??สแ????/strong>าห (า<strong>Open</strong>าห), แ??ฮเมแ?แ???ภเอเฮเยเศแ??เศเรแ??เอเภ เยเภแ?เสเฮเฬเฯแ???ลแ?(แ?หเลเฤแ?ษแ?ล แ?สเภเวเภเอเศแ?ฬ เอเภ แ?สแ?ภเอเล).</p>'+
				'<p>เ?ฮแ?หเล เวเภเยเลแ??ลเอเศแ?แ???ภเอเฮเยเสเศ เอเภเฦเฬเศแ?ล เอเภ เสเอเฮเฯเสแ?า<strong>เ?ฮแ?ฮเยเฮ</strong>าห, แ??ฮเมแ?เอเภแ?ภแ??เศเรแ??</p><br /><br />'+
				'<span class="block02" style="width: 370px;"><img src="/bitrix/templates/alawar6/images/kasp.gif" width="185" height="23" alt="เ??ฮเยเลแ?ลเอเฮ เ?อแ?ศเยเศแ???ฮเฬ เ?ภแ?ฯเลแ??สเฮเรเฮ " style="margin-top:3px;" /></span>'+
				'<p style="font-size:10px;">เ??ล เศเรแ??เฯแ?ฮเยเลแ?ลเอแ?เภเอแ?ศเยเศแ???ฮเฬ เ?ภแ?ฯเลแ??สเฮเรเฮ</p><br />'+
				'<p><a href="javascript:history.go(-1)">&laquo; เ?ลแ?อแ?????/a></p>';

	var opera = '<h3>เ?ฮเฬเฮแ??เย แ???ภเอเฮเยเสเล เศเรแ??/h3>'+
				'<p style="padding:5px 0;">เฏแ?ฮเมแ?แ?สเภแ?ภแ??เฯเฮเอแ?ภเยเศเยแ?????เศเรแ?? เอเภเฦเฬเศแ?ล เอเภ เสเอเฮเฯเสแ?า<strong>เจเสเภแ?ภแ??เศเรแ??/strong>าห เศเหเศ เวเลเหเลเอแ??เศเสเฮเอเสแ?แ?เมเลเหเฮเษ แ???ลเหเสเฮเษ แ??ฤเฮเฬ แ?เอเภเวเยเภเอเศเลเฬ เศเรแ?? <img src="http://ru.i.alawar.ru/bitrix/templates/alawar6/images/ico_04.gif" width="16" height="16" alt="" /></p>'+
				'<p style="padding:0;"><img src="/bitrix/templates/alawar6/images/browsers/ru/opnew.jpg" width="184" height="156" alt="" align="right" vspace="5" hspace="5" />เ?ฮแ?หเล แ??ฮเรเฮ เฮแ?สแ?ฮเลแ???เฤเศเภเหเฮเรเฮเยเฮเล เฮเสเอเฮ แ?เฯแ?ลเฤเหเฮเฦเลเอเศเลเฬ แ?สเภแ?ภแ??เศเหเศ เวเภเฯแ???ศแ??เศเรแ?? เ?ภเฦเฬเศแ?ล เอเภ เสเอเฮเฯเสแ?า<strong>เ?ภเฯแ???ศแ??/strong>าห (า<strong>Run</strong>าห)  เศ เฤเฮเฦเฤเศแ?ลแ?? เสเฮเรเฤเภ เวเภเสเฮเอแ?ศแ???เวเภเรแ??วเสเภ เศเรแ??เอเภ เยเภแ?เสเฮเฬเฯแ???ลแ? เ??ฮแ?ลแ??แ?สเภแ?ศเยเภเอเศแ?เศเรแ??เฬเฮเฦเลแ?เวเภเอแ???เฮแ?เอเลแ?สเฮเหแ?สเศแ?แ?ลเสแ?อเฤ เฤเฮ 20-30 เฬเศเอแ?? เย เวเภเยเศแ?ศเฬเฮแ??ศ เฮแ?แ?สเฮแ?ฮแ??ศ เยเภแ?ลเรเฮ เศเอแ?ลแ?อเลแ?แ?ฮเลเฤเศเอเลเอเศแ?</p>'+
				'<p>เ?ฮแ?หเล เวเภเยเลแ??ลเอเศแ?เวเภเรแ??วเสเศ เฮแ?สแ?ฮเลแ???เฤเศเภเหเฮเรเฮเยเฮเล เฮเสเอเฮ. เ?ภเฦเฬเศแ?ล เสเอเฮเฯเสแ?า<strong>เ??สแ????/strong>าห (า<strong>Open</strong>าห), แ??ฮเมแ?แ???ภเอเฮเยเศแ??เศเรแ??เอเภ เยเภแ?เสเฮเฬเฯแ???ลแ?(แ?หเลเฤแ?ษแ?ล แ?สเภเวเภเอเศแ?ฬ เอเภ แ?สแ?ภเอเล).</p>'+
				'<p>เ?ฮแ?หเล เวเภเยเลแ??ลเอเศแ?แ???ภเอเฮเยเสเศ เอเภเฦเฬเศแ?ล เอเภ เสเอเฮเฯเสแ?า<strong>เ?ฮแ?ฮเยเฮ</strong>าห, แ??ฮเมแ?เอเภแ?ภแ??เศเรแ??</p><br /><br />'+
				'<span class="block02" style="width: 370px;"><img src="/bitrix/templates/alawar6/images/kasp.gif" width="185" height="23" alt="เ??ฮเยเลแ?ลเอเฮ เ?อแ?ศเยเศแ???ฮเฬ เ?ภแ?ฯเลแ??สเฮเรเฮ " style="margin-top:3px;" /></span>'+
				'<p style="font-size:10px;">เ??ล เศเรแ??เฯแ?ฮเยเลแ?ลเอแ?เภเอแ?ศเยเศแ???ฮเฬ เ?ภแ?ฯเลแ??สเฮเรเฮ</p><br />'+
				'<p><a href="javascript:history.go(-1)">&laquo; เ?ลแ?อแ?????/a></p>';

	if(jQuery.browser.msie == true)
	{
		$("#div_installation_help").html(ie);
	}
	else if(jQuery.browser.mozilla || jQuery.browser.safari)
	{
		$("#div_installation_help").html(ff);
	}
	else if(jQuery.browser.opera)
	{
		$("#div_installation_help").html(opera);
	}
}

// Check subscriber in cookie and hide subscribe form
function showSubscribeForm()
{
	if (window.location.href.indexOf('?referer1=Newsletter&referer2') != -1 )
	{
	    $.cookie("ALAWAR_RU_SUBSCRIBED", "1");
	}

	if ($.cookie("ALAWAR_RU_SUBSCRIBED")==null )
	{
		$("#block-newsletter").show();
	}
}

function shuffle( array )
{
	for (var j, x, i = array.length; i; j = parseInt(Math.random() * i), x = array[--i], array[i] = array[j], array[j] = x);
	return true;
}

function function_exists( function_name )
{
	if ( typeof function_name == 'string' )
	{
		return ( typeof window[function_name] == 'function' );
	}
	else
	{
		return ( function_name instanceof Function );
	}
}
