/*
2009/11/03 - 16:19:15
*/

$(function(){window.focus();});var online={gamepage:{box_ad_container:'#ol_game_window',box_ad_outer:'#ol_pregame',box_ad_inner:'#ol_pregame div.box8',box_ad_stuff:'#ol_pregame_scripted',box_waiting:'#ol_pregame_waiting',box_image:'#ol_pregame_image',box_ol_dlbar:'#ol_dlgame',image_video:false,image_video_shell:$.cfg.paths.gl_gurl+'/images/bfg/all/flash/bfg_player.swf',active_x_required:false,total_width:730,has_dl_bar:false,dl_src_query:'',play_message:null,linked_feature:null,alkan:null,game_width:0,game_height:0,game_id:null,game_title:null,ad_time:15000,bartok:String.fromCharCode,_ad_image:function(){if(this.image_video){if($().flash.hasFlash()){$(this.box_image).flash({src:this.image_video_shell,width:300,height:225,AllowScriptAccess:"always",flashvars:{videoinfo:this.image_video}});}else{$(this.box_image).animate({height:"150px"}).append(this.linked_feature);}}else{$(this.box_image).append(this.linked_feature);}},_allow_play:function(){var og=online.gamepage;$(og.box_waiting).animate({opacity:0},400,function(){$(og.box_waiting).empty().append(og.play_message).animate({opacity:1},200,function(){$(og.box_waiting+' a').click(function(event){event.preventDefault();online.recent_games.add_game(og.game_id,og.game_title);online.gamepage._show_game();});});});},_up_playcount:function(){$.getJSON($.cfg.paths.hurl+'/'+$.cfg.paths.oldir+'/rest.php?playcount='+this.game_id+'&callback=?',function(data){});},_show_dl_bar:function(){if(this.has_dl_bar){$(this.box_ad_container).append($(this.box_ol_dlbar));$(this.box_ol_dlbar).show('slow');}},_show_game:function(){var og=online.gamepage;$(og.box_waiting).animate({opacity:'0'},200,function(){$(og.box_waiting).css('visibility','hidden');$(og.box_ad_outer).animate({opacity:'0'},400,function(){var inH=$(og.box_ad_inner).height();if(inH!=og.game_height){$(og.box_ad_inner).animate({height:og.game_height+'px'},400);}
$(og.box_ad_outer).empty().removeClass().css({'opacity':'1','margin-left':og.pregame_margin_left+'px'}).append('<iframe src="'+og.alkan+'" width="'+og.game_width+'" height="'+og.game_height+'" align="center" scrolling="no" marginheight="0" marginwidth="0" vspace="0" frameborder="0" id="olgamewindow"></iframe>');og._show_dl_bar();online.gamepage=null;});});og._up_playcount();},start:function(){if(this.active_x_required&&(!$.browser.msie||!$.ajax_enabled())){$(this.box_waiting).remove();$(this.box_ad_outer).remove();$(this.box_ad_container).append(this.active_x_required);this._show_dl_bar();}else{$(this.box_aXreq).remove();$(this.box_ad_stuff).css({visibility:'visible'});this._ad_image();setTimeout('online.gamepage._allow_play()',this.ad_time);}}},recent_games:{pref_key:'olrecent',pref_cookie:'weekPrefs',add_game:function(gameID,gameTitle){if(!gameID||!gameTitle){return false;}
var max_amount='5';var cookie_info=$.userPrefs._get_cookie_settings(online.recent_games.pref_cookie);var cur_list=$.userPrefs.getPrefs(online.recent_games.pref_key,cookie_info.cookie_name)||[];if(cur_list.length>0){$.each(cur_list,function(cKey,cVal){if($.ct(cVal)&&cVal!==null){if(!$.ct(cVal.gameID)||(cVal.gameID==gameID)||!$.ct(cVal.title)){cur_list.splice(cKey,1);}}});}
cur_list.unshift({gameID:gameID,title:gameTitle});if(cur_list.length>=parseInt(max_amount)){cur_list.splice(max_amount,(cur_list.length-parseInt(max_amount)));}
return $.userPrefs.savePrefs(online.recent_games.pref_key,cur_list,online.recent_games.pref_cookie);},get_list:function(){return $.userPrefs.getPrefs("olrecent","weekPrefs");}},after_playcount:{_functions:[],add:function(func){if($.isFunction(func)){this._functions.push(func);}},run:function(){$.each(this._functions,function(k,v){v();});online.after_playcount=null;}}};online.after_playcount.add(function(){$("#ol_playercount strong").html(online._totalcount);$("#ol_playercount").appendTo("div#subnav_outer").show();});if($('#ol_top10').length>0){online.after_playcount.add(function(){var top_5_links=$("#ol_top10 a");var top10ord=$("#ol_top10 dl").sort(function(a,b){var gid1=$(a).find("dd span.ol_count").html().replace(",","");var gid2=$(b).find("dd span.ol_count").html().replace(",","");return(parseInt(gid2)-parseInt(gid1));},true);$("#ol_top10 dl").remove();var count=1;$.each(top10ord,function(){$(this).find("dt span").empty().html(count);count++;});$("#ol_top10 .mod_cap_inner").append(top10ord);$("#ol_top10 dl:last").addClass("ol_top10_last");if($("#ol_top10").hasClass("pointy_tips")){$.pointy_tips.game_links("#ol_top10 a");}});}if($('div#online_top10_genre').length>0){online.after_playcount.add(function(){$("div#online_top10_genre .ol_counts dl dd a").attributeSort({triggerSort:".tsortPlayers",toggleSort:false,actions:{tsortPlayers:[".tsortPlayers","gameCounts","DESC","SORT_NUMERIC"]},sortkeys:{gameLink:"href",gameHtml:"html",gameCounts:function(ele){return parseInt(online._game_counts[$(ele).attr("gameid")]);},title_holder:"title_holder",rev:"rev",rel:"rel"}});});}if($('#online_recently_played').length>0){online.after_playcount.add(function(){var gameList=online.recent_games.get_list();$("#online_recently_played p").remove();$("#online_recently_played ul").remove();if(gameList&&(gameList.length>0)){var outList="<ul>";$.each(gameList,function(game,ginfo){outList+="<li><a href=\""+$.cfg.paths.hurl+"/online-games/"+escape(ginfo.gameID)+"/"+ginfo.title+"/index.html\">"+ginfo.title+"</a></li>";});outList+="</ul>";$(outList).hide().insertAfter("#online_recently_played h4").slideDown(1000);}else{$("<p>You haven't played any online games yet.</p>").hide().insertAfter("#online_recently_played h4").slideDown(300);}});}if($('.genreGames').length>0){online.after_playcount.add(function(){$(".ol_counts").find("UL").each(function(){$(this).height($(this).parent().height());});$(".genreGames li a").attributeSort({triggerSort:".sortName",toggleSort:false,actions:{sortName:[".sortName","gameTitle","ASC","SORT_STRING"],sortDate:[".sortDate","gameRelease","DESC","SORT_NUMERIC"],sortPlayers:[".sortPlayers","gameCounts","DESC","SORT_NUMERIC"],beforeSort:function(){$(".sortContainer").hide("slow");$(".genreGames li a").each(function(){if($(this).attr("title_holder")){$(this).attr("title",$(this).attr("title_holder"));$(this).removeAttr("title_holder");}});},afterSort:function(){$(".sortContainer").show("slow");$("#ol_lists").find("UL").each(function(){$(this).height($(this).parent().height());});}},sortkeys:{gameID:"gameid",gameTitle:"gametitle",gameRelease:"release",gameLink:"href",gameHtml:"html",gameCounts:function(ele){return parseInt(online._game_counts[$(ele).attr("gameid")]);},title:"title",title_holder:"title_holder",rev:"rev",rel:"rel",data_gtip:"data-gtip"}});$("ul#sortGenre").toggle();});}