function update_page(game_id,cur_shot,lang)
{
    var first_el = 1;
    var last_el = 3;
    if (cur_shot > first_el)var prev_shot = cur_shot-1; else prev_shot = cur_shot;
    if (cur_shot < last_el)var next_shot = cur_shot+1; else next_shot = cur_shot;
    var navi = '';
    var next = 'Next';
	var prev = 'Previous';
	if(lang == 'ru'){
		next = 'Следующий';
		prev = 'Предыдущий';
	}
	if (cur_shot > first_el)pref_pr = 'class="shots_panel_btn" onclick="ch_shot('+game_id+','+prev_shot+',\''+lang+'\');" onmousemove="this.style.cursor=\'pointer\';"';
	else pref_pr = 'class="shots_panel_btn_disabled"';    
    navi = '<div '+pref_pr+' style="width:120px"> << '+prev+' </div>';
    for (i=first_el; i<=last_el; i=i+1)
    {
	//if (i == cur_shot)var pref = 'style="background-color:#ffff00;colo"';else pref = '';
	if (i == cur_shot){ch_class = '_choosed'; act='';}else{ch_class = '';act=' onclick="ch_shot('+game_id+','+i+',\''+lang+'\')" onmousemove="this.style.cursor=\'pointer\';"';}
	navi += '<div class="shots_panel_btn'+ch_class+'"'+act+'>'+i+'</div>';
    }
    if (cur_shot < last_el)pref_n = 'class="shots_panel_btn" onclick="ch_shot('+game_id+','+next_shot+',\''+lang+'\');" onmousemove="this.style.cursor=\'pointer\';"';
	else pref_n = 'class="shots_panel_btn_disabled"';
    navi += '<div '+pref_n+' style="width:120px;"> '+next+' >> </div>';
    document.getElementById('shots_navi').innerHTML = navi;
    
}

function show_shots(game_id,cur_shot,lang,file,info)
{
    var x = 0;
	var y = 0;
	var scroll_y = 0;
	var scroll_x = 0;
	var file_name = 'http://www.myplaycity.com/gn/screen_640x480/'+game_id+'_screen_'+cur_shot+'_640x480.jpg';
	document.getElementById('shots_pic').innerHTML = '<img src="'+file_name+'" width="640" height="480" border="0">';
	document.getElementById('shots_down').innerHTML = '<a href="'+file+'"><img src="/i/common/preview_button_'+lang+'.jpg" width="200" height="42" border="0"></a>';
	document.getElementById('shots_downinf').innerHTML = info;
    //alert(browserVersion().name);
	
	if(browserVersion().name == "MSIE"){
	    x = document.documentElement.offsetWidth*0.5 - 340 + document.documentElement.scrollLeft + document.body.scrollLeft;
        y = document.documentElement.offsetHeight*0.5 - 302 + document.documentElement.scrollTop + document.body.scrollTop;
	    if (y<0)y = document.documentElement.scrollTop + document.body.scrollTop;
	    if (x<0)x = document.documentElement.scrollLeft + document.body.scrollLeft;
	    scroll_y = document.documentElement.scrollTop + document.body.scrollTop;
	    scroll_x = document.documentElement.scrollLeft + document.body.scrollLeft;
	}
	if(browserVersion().name == "Firefox"){
            x = window.innerWidth*0.5 - 340 + window.scrollX;
            y = window.innerHeight*0.5 - 302 + window.scrollY;
	    scroll_y = window.scrollY;
	    scroll_x = window.scrollX;
        }
	if(browserVersion().name == "Opera"){
            x = window.innerWidth*0.5 - 340 + document.documentElement.scrollLeft + document.body.scrollLeft;
            y = window.innerHeight*0.5 - 302 + document.documentElement.scrollTop + document.body.scrollTop;
	    scroll_y = document.documentElement.scrollTop + document.body.scrollTop;
	    scroll_x = document.documentElement.scrollLeft + document.body.scrollLeft;
        }
	
	if(x==0){
		x = window.innerWidth*0.5 - 340 + window.scrollX;
		y = window.innerHeight*0.5 - 302 + window.scrollY;
		scroll_y = window.scrollY;
		scroll_x = window.scrollX;
	}
	//alert(scroll_x+'|'+scroll_y);
	win_height = document.body.clientHeight;
	win_width = document.body.clientWidth;
	var bg = document.getElementById('s_shots_bg');
	bg.style.width = win_width+"px";
	bg.style.height = win_height+"px";
	bg.style.display = 'block';
	
	if (y<0)y=1;
	var load = document.getElementById('shots_div');
	load.style.left = x+"px";
	load.style.top = y+"px";
        if ((x > 0)&&(y > 0))load.style.display = 'block';
	update_page(game_id,cur_shot,lang);	
	if(browserVersion().name != "MSIE")show_id('shots_div',30,98);
}

function hide_shots()
{
    if(browserVersion().name != "MSIE"){hide_id('shots_div',98);}
	else document.getElementById('shots_div').style.display = 'none';
    document.getElementById('s_shots_bg').style.display = 'none';
}

function ch_shot(game_id,cur_shot,lang)
{
    var file_name = 'http://www.myplaycity.com/gn/screen_640x480/'+game_id+'_screen_'+cur_shot+'_640x480.jpg';
    document.getElementById('shots_pic').innerHTML = '<img src="'+file_name+'" width="640" height="480" border="0">';
    update_page(game_id,cur_shot,lang);
}

var is_popup = 0;

function drop_menu(elem_id,begin,end)
{
	begin=begin+1;
	document.getElementById(elem_id).style.height=begin+"px";
	t = setTimeout("drop_menu(\""+elem_id+"\","+begin+","+end+")",1);
	if (begin>=end) clearTimeout(t);
}

function show_menu()
{
        is_popup = 1;
	var menu = document.getElementById('lang_menu');
	if((browserVersion().name == "MSIE")&&(parseInt(browserVersion().version) <= 7))menu.style.margin = "0px 0 0 -105px";
        if (menu.style.display != 'block') menu.style.display = 'block';
                else menu.style.display = 'none';
	//drop_menu('lang_menu',0,90);
}

function hide_menu()
{
        if(is_popup == 0)
	    if(document.getElementById('lang_menu'))document.getElementById('lang_menu').style.display = 'none';
}

function from_menu()
{
	is_popup = 0;
}

function on_menu(evnt)
{
	var el = document.getElementById(evnt.id);
	el.style.backgroundColor = "#ccc";
}

function off_menu(evnt)
{
	document.getElementById(evnt.id).style.backgroundColor = "#ffffff";
}

function go(url)
{
	//alert(url);
	window.location.href = url;
}
