$(function(){ // game control buttons $("#infinite").scrollable({size:1, clickable: false, circular: true}); initiateLoader(); addTooltip(); // game tabs $(".add a").live('click', function() { alert('fav'); fav(); }); $("#moregames a").live('click', function() { switchtab('moregames', 'tab_moregames'); }); $("#share a").live('click', function() { }); $('.scroll-gameinfo').click(function(){ switchtab('gameinfo', 'tab_gameinfo'); goToByScroll('gameinfo'); return false; }); $('.scroll-moregames').click(function(){ switchtab('moregames', 'tab_moregames'); goToByScroll('moregames'); return false; }); $('.scroll-share').click(function(){ switchtab('share', 'tab_share'); goToByScroll('share'); return false; }); $('#favs').click(function(){ fav(); return false; }); }); function ieScrollingFix(){ if(jQuery.browser.msie){ setTimeout(function(){ $("#flashobj").css({overflow:'auto'}); }, 2000); } } // callback function invoked before the preloader var gameType = 'swf'; function PreloaderCallbackBefore() { $("#spaceDiv").hide(); }; // callback function invoked after the SWF is (pre)loaded function PreloaderCallbackAfter() { resetBodyWidth(); $('#zoomer').css('display','inline-block').hide().fadeIn(); $("#flashobj").css({'width' : originalwidth, 'height' : originalheight}); }; var js_pre_whileloading = ''; var js_pre_click2close = ''; function fav(){ if (document.cookie.match(/mygames=/)) { splits = document.cookie.split(';'); for(i = 0; i < splits.length; i++){ if(splits[i].match(/mygames=/)){ favstring = splits[i].replace('mygames=', ''); } } if (favstring.indexOf(gameid)!=-1) { var favstring = favstring.replace(gameid + '.', ''); if(favstring == " "){ document.cookie = "mygames="+favstring+"; expires=01/01/2007 00:00:00; path=/;"; } else{ document.cookie = "mygames="+favstring+"; expires=01/01/2015 00:00:00; path=/;"; } var state = 'unadded'; } else { var favstring = favstring+gameid+'.'; document.cookie = "mygames="+favstring+"; expires=01/01/2015 00:00:00; path=/;"; var state = 'added'; } } else{ var favstring = gameid +'.'; document.cookie = "mygames="+favstring+"; expires=01/01/2015 00:00:00; path=/;"; var state = 'added'; } if(state === 'added'){ document.getElementById('favs').innerHTML = ''+gameheadervar8+' '+gameheadervar8; alert(gameheadervar9); switchtab('share', 'tab_share'); goToByScroll('share'); } else{ document.getElementById('favs').innerHTML = ''+gameheadervar10+' '+gameheadervar10; alert(gameheadervar11); } } var voted = 'no'; function ajaxvote(grade){ if (voted != 'yes'){ var ajaxRequest; try{ ajaxRequest = new XMLHttpRequest(); } catch (e){ try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("error"); return false; } } } ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ document.getElementById("votecomment").innerHTML = gameheadervar12; voted = 'yes'; } } permwidth = grade * 25; document.getElementById("permvote").style.cssText = 'background: url(/i/alt_star.gif) left bottom; position: absolute; height: 25px; width: '+permwidth+'px; display: block; text-indent: -9000px; z-index: 2;'; document.getElementById("ten").setAttribute("class", ""); document.getElementById("ten").setAttribute("className", ""); document.getElementById("nine").setAttribute("class", ""); document.getElementById("nine").setAttribute("className", ""); document.getElementById("eight").setAttribute("class", ""); document.getElementById("eight").setAttribute("className", ""); document.getElementById("seven").setAttribute("class", ""); document.getElementById("seven").setAttribute("className", ""); document.getElementById("six").setAttribute("class", ""); document.getElementById("six").setAttribute("className", ""); document.getElementById("five").setAttribute("class", ""); document.getElementById("five").setAttribute("className", ""); document.getElementById("four").setAttribute("class", ""); document.getElementById("four").setAttribute("className", ""); document.getElementById("three").setAttribute("class", ""); document.getElementById("three").setAttribute("className", ""); document.getElementById("two").setAttribute("class", ""); document.getElementById("two").setAttribute("className", ""); document.getElementById("one").setAttribute("class", ""); document.getElementById("one").setAttribute("className", ""); var loc = '/ajax/vote/'+grade+'/'+gameid+'/'+gameremoteaddr; ajaxRequest.open("GET", loc, true); ajaxRequest.send(null); } } var originalwidth = gamewidth; var originalheight = gameheight; function increasesize(){ var breedte = parseInt($("#flashobj").width()) * 1.1; var hoogte = parseInt($("#flashobj").height()) * 1.1; var langLeft = parseInt($("#cd").css('left')); if(breedte > 969){ var bodywidth = breedte + 60; document.body.style.cssText = 'width: '+bodywidth+'px;'; if(jQuery.browser.msie && jQuery.browser.version == '6.0') {}else{ $("#cd").css('left',bodywidth - 118); } } $("#flashobj")[0].style.cssText = 'width: '+breedte+'px; height: '+hoogte+'px;'; } function decreasesize(){ var breedte = parseInt($("#flashobj").width()) / 1.1; var hoogte = parseInt($("#flashobj").height()) / 1.1; if(breedte > 969){ var bodywidth = breedte + 60; document.body.style.cssText = 'width: '+bodywidth+'px;'; if(jQuery.browser.msie && jQuery.browser.version == '6.0') {}else{ $("#cd").css('left',bodywidth - 118); } } if(breedte < 969){ var bodywidth = 969; document.body.style.cssText = 'width: '+bodywidth+'px;'; if(jQuery.browser.msie && jQuery.browser.version == '6.0') {}else{ $("#cd").css('left',bodywidth - 118); } } $("#flashobj")[0].style.cssText = 'width: '+breedte+'px; height: '+hoogte+'px;'; } function reset(){ $('.ui-slider-handle.').click(); } function switchtab(tab, tabcontent){ if(!window.globactive){ window.globactive = document.getElementById("gameinfo"); } window.globactive.setAttribute("class", ""); window.globactive.setAttribute("className", ""); newtab = document.getElementById(tab); newtab.setAttribute("class", "active"); newtab.setAttribute("className", "active"); window.globactive = newtab; // document.getElementById("tab_gameinfo").style.cssText = 'display:none'; $("#tab_gameinfo").hide(); document.getElementById("starlist").setAttribute("class", "star-rating-hidden"); document.getElementById("starlist").setAttribute("className", "star-rating-hidden"); //document.getElementById("tab_moregames").style.cssText = 'display:none'; $("#tab_moregames").hide(); $("#tab_share").hide(); // document.getElementById(tabcontent).style.cssText = 'visibility:visible'; $("#"+tabcontent).show(); if(tab === 'gameinfo'){ document.getElementById("starlist").setAttribute("class", "star-rating"); document.getElementById("starlist").setAttribute("className", "star-rating"); } } var over = false; function rate(grade){ grade = parseInt(grade); over = true; switch(grade){ case 1: var verbalrating = gameverbals0; break; case 2: var verbalrating = gameverbals1; break; case 3: var verbalrating = gameverbals2; break; case 4: var verbalrating = gameverbals3; break; case 5: var verbalrating = gameverbals4; break; case 6: var verbalrating = gameverbals5; break; case 7: var verbalrating = gameverbals6; break; case 8: var verbalrating = gameverbals7; break; case 9: var verbalrating = gameverbals8; break; case 10: var verbalrating = gameverbals9; break; } if(voted != 'yes'){ $("#votecomment").text(verbalrating); } } function resetvotecomment(){ if(voted != 'yes' && !over){ game_title = gametitle; $("#votecomment").text(gameheadervar13); } } // --------------------------- function initGame() { var FBody = $('#flashobj'); var Flash = $('#zoomer'); var FSlider = Flash.find('.slider-bar'); var FWidth = originalwidth; var FHeight = originalheight; var FNewWidth = 0; // Setting predefined width and height FBody.width(FWidth).height(FHeight); // Difference beatveewn height and width nSize = parseFloat(FHeight/FWidth); FSlider.slider({ animate: true, min: -320, max: 480, start: function(event, ui) { $("#flashobj").css({'border':'1px solid #79c9e9'}).find('#flashobj_mc').css({'width':'100px', 'height':'100px', 'visibility':'hidden'}); }, stop: function(event, ui) { $("#flashobj").css({'border':'1px none'}).find('#flashobj_mc').css({'width':'100%', 'height':'100%', 'visibility':'visible'}); var nwidth = FWidth + ui.value; if(jQuery.browser.msie != true ) { if( nwidth > 969 ) $("#cd").css('left', nwidth -58); else $("#cd").css('left', 662); } }, slide: function(event, ui) { var nwidth = FWidth + ui.value; var nheight = nwidth*nSize; var cd_left = 662; if(jQuery.browser.msie != true ) { if( nwidth > 969 ) $("#cd").css('left', nwidth -58); else $("#cd").css('left', 662); } if (nwidth > 969) $('body').css('width',nwidth + 60); else $('body').css('width', 969); $("#flashobj").css({'width' : nwidth, 'height' : nheight}); }, change: function(event, ui) { var nwidth = FWidth + ui.value; var nheight = nwidth*nSize; var cd_left = 662; if(jQuery.browser.msie != true ) { if( nwidth > 969 ) $("#cd").css('left', nwidth -58); else $("#cd").css('left', 662); } if (nwidth > 969) $('body').css('width',nwidth + 60); else $('body').css('width', 969); $("#flashobj").css({'width' : nwidth, 'height' : nheight}); // ieScrollingFix(); } }); $('#scroller .but-plus').click(function(){ FSlider.slider('value', FSlider.slider('value') + 80); }); $('#scroller .but-minus').click(function(){ FSlider.slider('value', FSlider.slider('value') - 80); }); $('#scroller .but-reset').click(function(){ FSlider.slider('value', 0); resetBodyWidth(); }); } function resetBodyWidth() { originalwidth > 969 ? $('body').css('width', originalwidth + 60) : $('body').css('width', 969); } function goToByScroll(id){ $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow'); } function addTooltip () { $('.gs-tooltip').css({ 'visibility': 'hidden' }); $('.gs-tooltip h4').css('width', 'auto'); var tip_offset = 0; var tip_offset = 0; var fixIE6 = 0; if(jQuery.browser.msie && parseInt(jQuery.browser.version) == 6) fixIE6 = 12; $('.scrollable .items a').mouseenter(function(){ $('.gs-tooltip h4').text($(this).attr('title')); $('.gs-tooltip').css('width', $('.gs-tooltip h4').width() + 30); var tip_left = parseInt($(this).offset().left) - (parseInt($('html').width()) - (parseInt($('body').width()) + parseInt($('body').css('padding-right'))))/2 + fixIE6; var tip_top = $(this).offset().top + 42; var tip_mar = '-' + parseInt($('.gs-tooltip').width())/2 + 'px'; $('.gs-tooltip').css({ 'top': tip_top, 'left': tip_left + 54 + 'px', 'margin-left': tip_mar, 'visibility': 'visible' }); }); $('.scrollable .items a').mouseleave(function(){ $('.gs-tooltip').css({'width': 'auto', 'left': '0px', 'bottom': '0px' }); $('.gs-tooltip h4').css({'width': 'auto'}); $('.gs-tooltip').css({ 'visibility': 'hidden' }); }); } function showGame(gameurl, format){ if(format === 'swf'){ document.write(''); } if(format === 'dcr'){ document.write(''); } } function PreloaderCallbackAfter(ad, id){ if(ad == 'NOAD'){ alert("Videostrip player placed in element '"+id+"'. No ad served according to Videostrip, callback done immediately, so game showed immediately."); } displayGame(); } function initVideostrip(){ $('.zbox').width('auto'); videostrip.PlayerPlacer.changeVideo('video-ad', 11840366, 23941145, 640, 360, true); } function initiateLoader() { if(typeof hideProgress == "undefined" || hideProgress == false){ $('#zprogress-container').toggle(); $('#zmessage').toggle(); $('#zbutton').toggle(); } if(typeof noBox == "undefined" || noBox == false){ $('.zbox').css('background-color', '#ebf4f7'); $('.zbox').css('border', '1px #000 solid'); } $('#skip-link').click(function(){ displayGame(); }); barWidth = $('#zprogress-container').width(); initiateTimer(); } function embedSwf(){ var attributes = { id: "flashobj_mc", "name": "flashobj_mc" }; swfobject.embedSWF(swfUrl, "swf", "100%", "100%", "8", false, false, false, attributes); gameEmbedded = true; } function displayGame(){ clearTimeout(t); if(!gameEmbedded){ embedSwf(); } $('.zbox').remove(); $('#flashobj').toggle(); initGame(); resetBodyWidth(); $('#zoomer').css('display','inline-block').hide().fadeIn(); $("#flashobj").css({'width' : originalwidth, 'height' : originalheight}); } function initiateTimer() { $('#zprogress-bar').width(loadingProgress / loadingTime * barWidth); //if(loadingProgress % 1000 == 0) { //$('#countdown').html((loadingTime - loadingProgress) / 1000); //} alert('hello'); $('#countdown').html(Math.round(loadingProgress/loadingTime*100)+'%'); loadingProgress = loadingProgress + 200; t=setTimeout("initiateTimer()", 200); if(loadingProgress == skippableOn){ $('#skip-link').toggle(); } if(loadingProgress == embedGame + 1000){ embedSwf(); } if(loadingProgress > loadingTime){ displayGame(); } }