var so=new SWFObject("/_/swf/banner.swf","main_flash_banner_swf","691","163","8");so.addParam("menu","false");so.write("main_flash_banner");var gameCache=new Array();var newType;$(document).ready(function(){$('#panel_left div.submenu li a').click(function(){var oldType=$('#panel_left div.submenu li.active');newType=$(this).parent();oldType.removeClass('active');var gameType=$(this).html().toLowerCase();if(gameCache[gameType]===undefined)
{$.ajax({type:"GET",dataType:"xml",url:"/games/ajaxGameType/"+gameType,beforeSend:function(){$('div.game_mesh_small div.game').fadeTo("fast",0.5);$('div.game_mesh_small div.games_loading').show();},success:function(xml){gameCache[gameType]=xml;readGameXML(xml);},error:function(){oldType.addClass('active');$('div.game_mesh_small div.game').fadeTo("fast",1);},complete:function(){$('div.game_mesh_small div.games_loading').animate({opacity:1.0},1000).fadeOut();}});}
else
{readGameXML(gameCache[gameType]);}
return false;});setInterval(loadNewUserActions,10000);});var lastActionId="";var waitingActions=new Array();var showActionTimeout;function loadNewUserActions()
{$.ajax({type:"GET",dataType:"json",url:"/main/ajaxNewUserActions/"+lastActionId,success:function(data){$.each(data,function(i,item){if(lastActionId==""||item.id>lastActionId)
{lastActionId=item.id;}
waitingActions.push(item);});showNewAction();},error:function(XMLHttpRequest,textStatus,errorThrown){}});}
function showNewAction()
{if(waitingActions.length>0)
{action=waitingActions.shift();$('#user_actions').prepend("<li style='display:none'>"+"<a href='/profile/"+action.login+"'><img src='"+action.avatar+"' alt='"+action.login+"' class='avatar'/></a>"+"<div class='action_info'><a href='/profile/"+action.login+"'>"+action.login+"</a> "+action.text+"</div>"+"<div class='clear'></div>"+"<div class='date'>"+action.date+"</div></li>");$('#user_actions li:eq(0)').slideDown("slow");$('#user_actions li:gt(5)').remove();clearTimeout(showActionTimeout);showActionTimeout=setTimeout(showNewAction,(Math.random()*2000)+1000);}}
function readGameXML(xml)
{newType.addClass('active');var gameNum=0;$(xml).find('game').each(function(){var gid=$(this).find('id').text();var gname=$(this).find('name').text();var gdesc=$(this).find('desc').text();var glink=$(this).find('glink').text();var gadded=$(this).find('added').text();var gvotes=$(this).find('votes').text();var gviews=$(this).find('views').text();var gcomments=$(this).find('comments').text();var grating=$(this).find('rating').text();var gratingType=$(this).find('ratingType').text();var gameDiv=$('div.game_mesh_small div.game:eq('+gameNum+')');gameDiv.stop().fadeTo("slow",0,function(){gameDiv.find('h2 a').html(gname);gameDiv.find('p.description').html(gdesc);gameDiv.find('p.date').html(gadded);gameDiv.find('div.screenshot img').attr('src','/_/img/thumbs/'+gid+'-0.jpg');gameDiv.find('a').attr('href',glink);gameDiv.find('span.views').html(gviews);gameDiv.find('span.votes').html(gvotes);gameDiv.find('span.comments').html(gcomments);gameDiv.find('div.small_box div.bottom').html(grating);gameDiv.find('div.small_box').attr('class','small_box '+gratingType);}).animate({opacity:0},250*gameNum).fadeTo("slow",1);gameNum++;if(gameNum==4)
{return;}});$("div.game_mesh_small div.game h2 a").bigTarget({clickZone:'div:eq(0)'});}