/*
	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 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, "");
	}
	else if(window.chrome)
	{
		alert('Press ctrl+D to bookmark (Command+D for macs) after you click Ok');
		return false;
	}
	//IE4+
	else if (typeof window.external == "object")
	{
		window.external.AddFavorite(url, title);
	}
	//Opera
	else if (window.opera && document.createElement && window.print)
	{
		try {
		    var elem = document.createElement('a');
		    elem.setAttribute('href',url);
		    elem.setAttribute('title',title);
		    elem.setAttribute('rel','sidebar');
		    elem.click();
		} catch (e) { return false;	}
	}
	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 && menu.offsetHeight > main.offsetHeight) main.style.height = menu.offsetHeight + 20 + "px";
}

// START: VIDEO TRAILER
function initVideoTrailer()
{
	$( "#watch" ).click( function() {
		video();
	} );
}

function video()
{
	if ( $("#video_cont").is(":visible") )
	{
		$("#video_cont").toggle();
		$("#watch").text( 'Watch Video' );

		var video0 = document.getElementById('video_0');

		if ( video0 )
			$("#video_0").html('');
	}
	else
	{
		$("#video_cont").toggle();
		$("#watch").text( 'Close Video' );

		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();
		if ( langCode == 'he' )
		{
			langCode = 'il';
		}
		if ( langCode == 'ko' )
		{
			langCode = 'kr';
		}
		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 isMacPlatform()
{
	if (navigator.platform.indexOf('Mac') != -1 )
	{
		return true;
	}
	return false;
}

function function_exists( function_name )
{
	if ( typeof function_name == 'string' )
	{
		return ( typeof window[function_name] == 'function' );
	}
	else
	{
		return ( function_name instanceof Function );
	}
}

