
var previousWidth=0;$(document).ready(function()
{previousWidth=$(window).width();$(window).resize(adaptLayout);adaptLayout(true);});function adaptLayout(initialization){var contentContainer=$("#game-zone");if(contentContainer.length>0){$("#content-wrapper").css('width','100%');}
else{$("#content-wrapper").width($("#wrapper").width()-$("#advertisement-vertical").width()-30);}
var count=0;var thumbnailsWidth=104;var thumbnailsHeight=79;if($("#content-header-middle").length>0){count=($("#content-header-middle").width()-
$('#advertisement-top-square').width()-
150)/thumbnailsWidth;}
else{var blocwidth=parseInt(($("#content-wrapper").width()-$(".advertisement-top-square").width())/2);count=parseInt(blocwidth/thumbnailsWidth);$("#featured-games-block").width(count*thumbnailsWidth);$("#popular-games-block").width(count*thumbnailsWidth);count=count*(parseInt($(".advertisement-top-square").height()/thumbnailsHeight));}
$(".ui-widget-header").each(function(){if($(this).height()>100){$(this).css('background-position','0 0');}});if(initialization==true||$(window).width()!=previousWidth){loadFeaturedAndPopularGames(count);loadFavoriteGames(parseInt(($('#favorite-contents').width()/thumbnailsWidth)-1));}
previousWidth=$(window).width();}
var defaultSizeWasTooBig=false;var sizeWasModified=false;function CheckGameSize(gameData){var game=$("#game");var gameContainer=$(".game-frame-container");if(($("#toolbar").width()+gameContainer.width()+20)>$(".game-block").width()||defaultSizeWasTooBig&&!sizeWasModified){defaultSizeWasTooBig=true;var newWidth=$(".game-block").width()-$('#toolbar').width()-50;var widthRatio=gameData.width/newWidth;if((gameData.height*widthRatio)>($(window).height()-50))
{game.height(($(window).height()-100));widthRatio=gameData.height/game.height();game.width(gameData.width/widthRatio);}
else
{game.width(newWidth);game.height(gameData.height/widthRatio);}}}
