var timeOutId=0;var ttt='';$(document).ready(function(){$.ajaxSetup({cache:false});$(".img_box img, .img_box2 img").live("hover",function(e){if(e.type=='mouseover'){ttt=$(this).attr('title');timeOutId=0;showDetail(this);}
if(e.type=='mouseout'){$(this).attr('title',ttt);$(this).parent('a').attr('title',ttt);clearTimeout(timeOutId);timeOutId=-1;$("#gametooltip").stop(true,true).delay(200).fadeOut();}});$("#gametooltip").live("hover",function(e){if(e.type=='mouseover'){$("#gametooltip").stop(true,true);}
if(e.type=='mouseout'){clearTimeout(timeOutId);timeOutId=-1;$("#gametooltip").stop(true,true).delay(200).fadeOut();}});$('.tab_off').live("click",function(e){$(".tab_on").attr('class','tab_off');$(".htab_on").attr('class','htab_off');$(this).attr('class','tab_on');$(this).prev('div').attr('class','htab_on');loadRecent($(this).attr('title'));});$('#searchBig, #searchSmall').attr('value','games search');$('#searchBig, #searchSmall').focus(function(){$(this).css('color','#000');if(trim($(this).val())=='games search')$(this).val('');});$('#searchBig, #searchSmall').blur(function(){var st=trim($(this).val());if(st.length==0){$(this).css('color','#999');$(this).val('games search');}});$('#formSearchSmall, #formSearchBig').submit(function(){var st=trim($(this).children(':text').val());if((st=='')||(st.toLowerCase()=='games search')){alert("Please enter text to search");return false;}});$('#langSel').hover(function(){var pos=$(this).position();var y=(pos.top+$(this).outerHeight()+4)+'px';var x=pos.left+'px';$('#langList').css({'left':x,'top':y});$('#langList').stop(true,true).delay(200).fadeIn("slow");},function(){$('#langList').stop(true,true).delay(200).fadeOut("slow");});$('#langList').hover(function(){$('#langList').stop(true,true).delay(200).fadeIn("slow");},function(){$('#langList').stop(true,true).delay(200).fadeOut("slow");});$('#langSel').click(function(){return false;});$("#jqbookmark").jBrowserBookmark();if(swpmax!=0){setInterval(swapimg,5000);}});var cimg=1;function swapimg(){if(swpmax==0)return;var n=(cimg==swpmax)?1:cimg+1;$('#cs'+cimg).fadeOut(900);$('#cs'+n).fadeIn(900);cimg=n;}
function trim(stringToTrim){return stringToTrim.replace(/^\s+|\s+$/g,"");}
$(function(){});function loadRecent(tp){if(tp<3){var url='/ajax/gameRMS.php?id='+md+'&lang='+lang+'&tp='+tp;$.get(url,function(data){$('#agamebox').html(data);});$('#sgbox').stop(true,true).hide();$('#agamebox').stop(true,true).fadeIn('slow');}else{$('#agamebox').stop(true,true).hide();$('#sgbox').stop(true,true).fadeIn("slow");}}
var l=0;var t=0;function viewDetail(){if(timeOutId==-1){$("#gametooltip").stop(true,true).delay(200).fadeOut();return;}
$("#gametooltip").stop(true,true).fadeIn("slow");clearTimeout(timeOutId);timeOutId=0;}
function showDetail(it){var url='/ajax/game.php?id='+$(it).attr("name")+'&lang='+lang;$.get(url,function(data){data=trim(data);if((data!='ERROR')&&(data!='')){$("#gametooltip").html(data);var pos=$(it).position();st=pos.left+':'+pos.top+' <br> ';l=(pos.left<650)?(pos.left+$(it).width()+10)+'px':(pos.left-250)+'px';t=pos.top;var vh=$("#gametooltip").outerHeight();if((t+vh+30)>($(window).scrollTop()+$(window).height())){t=(t+$(it).height())-vh;}
if(t<$(window).scrollTop())t=$(window).scrollTop()+10;t+='px';$("#gametooltip").css({'left':l,'top':t});$(it).attr('title','');$(it).parent('a').attr('title','');if(timeOutId!=-1){$("#gametooltip").stop(true,true);timeOutId=window.setTimeout(viewDetail,300);}}});}
function loadGame(url,gw,gh){var flashvars={};var params={};if(havead==1){params.allowScriptAccess="always";params.allowNetworking="all"; if (threed == 1) { params.wmode="direct"; }}else{params.allowScriptAccess="samedomain";params.allowNetworking="internal"; if (threed == 1) { params.wmode="direct"; }}var attributes={};if(havead==1){attributes.allowScriptAccess="always";attributes.allowNetworking="all";}else{attributes.allowScriptAccess="samedomain";attributes.allowNetworking="internal";} if (threed == 1) { attributes.wmode="direct"; } attributes.name="a2fgameid";swfobject.embedSWF(url,"gameDiv",gw,gh,ver+'.0.0',"expressInstall.swf",flashvars,params,attributes);$('#gamediv').css('top','10px');$('#gamediv').css('left',l+'px');$('#gamediv, #gameWrap, #player_container').height(gh+5);}
function showGame(){document.getElementById('gameWrap').style.top='10px';var l=Math.ceil((960-$('#gameWrap').outerWidth())/2)+'px';document.getElementById('gameWrap').style.left=l;document.getElementById('player').style.visibility="hidden";document.getElementById('player').style.display="none";swfobject.removeSWF('player');} function showFlags() { $("#flags").height(70);  } function hideFlags() { $("#flags").height(20); }
(function($){$.fn.jBrowserBookmark=function(options,lang){var defaults=$.extend(opts={language:{'':['Press [key] + ',' to bookmark this page.']},defaultLanguage:'',functionButton:['CTRL','CMD']},options);var docUrl=window.location.href;var docTitle=document.title;var browserName;browserName=getBrowser();return this.each(function(){$(this).click(function(e){e.preventDefault();try{switch(browserName){case'konqueror':case'firefox':window.sidebar.addPanel(docTitle,docUrl,'');break;case'msie':window.external.AddFavorite(docUrl,docTitle);break;case'opera':if(versionOpera()<11){$(this).attr('rel','sidebar').attr('title',docTitle).attr('href',docUrl);break;}else{throw error;}default:throw error;}}catch(error){var hotkey=getHotkey(browserName);var alertText=getLanguageText();if(/mac/.test(navigator.platform.toLowerCase()=='mac')){prefix=alertText[0].replace('[key]',opts.functionButton[1]);}else{prefix=alertText[0].replace('[key]',opts.functionButton[0]);}alert(prefix+hotkey+alertText[1]);}});});function getBrowser(){if($.browser.msie){return'msie';}if($.browser.mozilla){return'firefox';}if($.browser.opera){return'opera';}if($.browser.safari&&/chrome/.test(navigator.userAgent.toLowerCase())){return'chrome';}if($.browser.safari){return'safari';}if(/konqueror/.test(navigator.userAgent.toLowerCase())){return'konqueror';}}function getHotkey(browserName){switch(browserName){case'konqueror':return'B';break;case'opera':return(versionOpera()<9)?'T':'D';break;default:return'D';break;}}function getLanguageText(){var languageChosen;if(opts.language[lang]!=undefined){languageChosen=lang;}else{if(opts.language[navigator.language.toLowerCase().substring(0,2)]!=undefined){languageChosen=navigator.language.toLowerCase().substring(0,2);}else{if(opts.language[opts.defaultLanguage]!=undefined)languageChosen=opts.defaultLanguage;else{for(var i in opts.language){languageChosen=i;break;}}}}return opts.language[languageChosen];}function versionOpera(){version=navigator.userAgent.substring(navigator.userAgent.toLowerCase().indexOf('version/')+8);return parseInt(version.substring(0,version.indexOf('.')));}};})(jQuery);
