(function($){$.fn.reportprogress=function(val,maxVal,text,bw){var max=100;var barWidth=bw||300;if(maxVal)
max=maxVal;return this.each(function(){var div=$(this);var innerdiv=div.find(".progress");

if(innerdiv.length!=1){innerdiv=$("<div class='progress'></div>");
//div.append("<div class='text'>&nbsp;</div>");
//$("<span class='text'>&nbsp;</span>").css("width",div.css('width')).appendTo(innerdiv);
div.append(innerdiv);
}
var width=Math.round(val/max*100);innerdiv.css("width",width+"%");if(text){div.find(".text").html(text);}});};})(jQuery);

(function($){$.flashPlayerVersion=function(){var flashVersion,activeX=null,fp6Crash=false,shockwaveFlash='ShockwaveFlash.ShockwaveFlash';if(!(flashVersion=navigator.plugins['Shockwave Flash'])){try{activeX=new ActiveXObject(shockwaveFlash+'.7');}
catch(errorA){try{activeX=new ActiveXObject(shockwaveFlash+'.6');flashVersion=[6,0,21];activeX.AllowScriptAccess='always';}
catch(errorB){if(flashVersion&&flashVersion[0]===6){fp6Crash=true;}}
if(!fp6Crash){try{activeX=new ActiveXObject(shockwaveFlash);}
catch(errorC){flashVersion='X 0,0,0';}}}
if(!fp6Crash&&activeX){try{flashVersion=activeX.GetVariable('$version');}
catch(errorD){}}}
else{flashVersion=flashVersion.description;}
flashVersion=flashVersion.match(/^[A-Za-z\s]*?(\d+)(\.|,)(\d+)(\s+r|\s+d|,)(\d+)/);return[flashVersion[1]*1,flashVersion[3]*1,flashVersion[5]*1];}();$.flashExpressInstaller='expressInstall.swf';$.hasFlashPlayer=($.flashPlayerVersion[0]!==0);$.hasFlashPlayerVersion=function(options){var flashVersion=$.flashPlayerVersion;options=(/string|integer/.test(typeof options))?options.toString().split('.'):options;return(options)?(flashVersion[0]>=(options.major||options[0]||flashVersion[0])&&flashVersion[1]>=(options.minor||options[1]||flashVersion[1])&&flashVersion[2]>=(options.release||options[2]||flashVersion[2])):(flashVersion[0]!==0);};$.flash=function(options){var noflashplayer=false;if(!$.hasFlashPlayer){noflashplayer=true;}
var movieFilename=options.url||'',contentType=options.type||'swf',paramAttributes=options.params||{},buildDOM=document.createElement('body'),aArr,bArr,cArr,dArr,a,b,c,d;var movieFilenameParams=options.urlParams||false;delete options.urlParams;if(typeof(movieFilenameParams)=='object'){str=[];for(up in movieFilenameParams){str.push(up+'='+movieFilenameParams[up]);};movieFilenameParams=str.join('&');};options.height=options.height||180;options.width=options.width||320;if(noflashplayer||(options.hasVersion&&!$.hasFlashPlayerVersion(options.hasVersion))){$.extend(options,{id:'SWFObjectExprInst',height:Math.max(options.height,137),width:Math.max(options.width,214)});movieFilename=options.expressInstaller||$.flashExpressInstaller;paramAttributes={flashvars:{MMredirectURL:window.location.href,MMplayerType:($.browser.msie&&$.browser.win)?'ActiveX':'PlugIn',MMdoctitle:document.title.slice(0,47)+' - Flash Player Installation'}};}
if(options.flashvars&&typeof paramAttributes==='object'){$.extend(paramAttributes,{flashvars:options.flashvars});}
for(a in(b=['url','type','expressInstall','hasVersion','params','flashvars'])){delete options[b[a]];}
aArr=[];for(a in options){if(typeof options[a]==='object'){bArr=[];for(b in options[a]){bArr.push(b.replace(/([A-Z])/,'-$1').toLowerCase()+':'+options[a][b]+';');}
options[a]=bArr.join('');}
aArr.push(a+'="'+options[a]+'"');}
options=aArr.join(' ');if(typeof paramAttributes==='object'){aArr=[];for(a in paramAttributes){if(typeof paramAttributes[a]==='object'){bArr=[];for(b in paramAttributes[a]){if(typeof paramAttributes[a][b]==='object'){cArr=[];for(c in paramAttributes[a][b]){if(typeof paramAttributes[a][b][c]==='object'){dArr=[];for(d in paramAttributes[a][b][c]){dArr.push(d.replace(/([A-Z])/,'-$1').toLowerCase()+':'+paramAttributes[a][b][c][d]+';');}
paramAttributes[a][b][c]=dArr.join('');}
cArr.push(c+'{'+paramAttributes[a][b][c]+'}');}
paramAttributes[a][b]=cArr.join('');}
bArr.push(window.escape(b)+'='+window.escape(paramAttributes[a][b]));}
paramAttributes[a]=bArr.join('&amp;');}
aArr.push('<PARAM NAME="'+a+'" VALUE="'+paramAttributes[a]+'">');}
paramAttributes=aArr.join('');}
if(contentType=='swf'){if(!(/style=/.test(options))){options+=' style="vertical-align:text-top;"';}
if(!(/style=(.*?)vertical-align/.test(options))){options=options.replace(/style="/,'style="vertical-align:text-top;');}}
if($.browser.msie){if(contentType=='swf'){options+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';paramAttributes='<PARAM NAME="movie" VALUE="'+movieFilename+'">'+paramAttributes;}else{if(movieFilenameParams){if(movieFilename.indexOf('?')==-1)movieFilename+='?'+movieFilenameParams;else movieFilename+='&'+movieFilenameParams;};options+=' classid="clsid:233C1507-6A77-46A4-9443-F871F945D258" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=11,0,0,0"';paramAttributes='<param name=PlayerVersion value=11><PARAM NAME="src" VALUE="'+movieFilename+'">'+paramAttributes;}}
else{if(contentType=='swf'){options+=' type="application/x-shockwave-flash" data="'+movieFilename+'"';}else{if(movieFilenameParams){if(movieFilename.indexOf('?')==-1)movieFilename+='?'+movieFilenameParams;else movieFilename+='&'+movieFilenameParams;};options+=' codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=11,0,0,0" type="application/x-director" data="'+movieFilename+'"';paramAttributes='<param name=PlayerVersion value=11><PARAM NAME="src" VALUE="'+movieFilename+'">'+paramAttributes;}}
return noflashplayer==true?false:'<OBJECT '+options+'>'+paramAttributes+'</OBJECT>';};$.fn.flash=function(options){if(!$.hasFlashPlayer){return this;}
var a=0,each;while((each=this.eq(a++))[0]){each.html($.flash($.extend({},options)));if(each[0].firstChild.getAttribute('id')==='SWFObjectExprInst'){a=this.length;}}
return this;};}(jQuery));

(function($){var settings={adWidth:300,adHeight:250,resizeBar:0,showAd:true,forcePreroll:false,usePercentsInPreroll:true,loadingBar:true,fileType:'swf',contentId:'#flashobj',preloadId:'#flashobj_mc',beforeCallback:null,afterCallback:null,skipCallback:null,gameInsertCallback:null,textOnProgressVisible:false,loadingText:"Loading game...",afterLoadingText:"Game loaded. Click here to start the game\u2026",progressbarText:'The game will start in %d seconds',closeText:'Close the advertisement and go on to the game.',advertisementText:'Advertisement',tickInterval:200,progressTime:15000,showSkipTime:0,barWidth:300,adType:'iframe',adCode:''};var percent=0;var timeElapsed=0;var linkShowTimeElapsed=0;var that=this;var flashLoadTries=0;var skipTextInserted=false;var skipLinkInserted=false;var neoedgeAd=false;var intervalHandle,target,check98PercentHandle,preTimer,preloaderWidth,preloaderHeight,preroll,neoedgeHandler;var cleanupAndShowGame=function(){$('#new-game-wrapper').css('height','');if(intervalHandle!=null){clearInterval(intervalHandle);intervalHandle=null;}
if(neoedgeHandler!=null){clearTimeout(neoedgeHandler);neoedgeHandler=null;}
if(check98PercentHandle!=null){clearTimeout(check98PercentHandle);check98PercentHandle=null;}
$(target).hide();if(settings.afterCallback!=null){settings.afterCallback.call(that,settings);}
if(settings.fileType!='swf'||settings.forcePreroll){settings.gameInsertCallback.call(that);}else{$(settings.contentId).css({width:preloaderWidth,height:preloaderHeight});}};var skipad=function(){if(settings.skipCallback!=null){settings.skipCallback.call(that,settings);};cleanupAndShowGame();};var skipTextAddOrDecrement=function(afterLoading){skipTextInserted=afterLoading?false:skipTextInserted;if(linkShowTimeElapsed<=0&&!skipTextInserted){if(preroll){if(!skipLinkInserted){$('#ap_skiptext').empty().append($('<a href="javascript:void(0);">'+settings.closeText+'</a>').click(skipad));skipLinkInserted=true;}}else if(afterLoading){if(!skipLinkInserted){$('#ap_skiptext').empty().append($('<a href="javascript:void(0);">'+settings.afterLoadingText+'</a>').click(skipad));skipLinkInserted=true;}}
skipTextInserted=true;return;}

linkShowTimeElapsed-=settings.tickInterval;};var insertAd=function(){$(target).css({width:(settings.adWidth+'px')});

if(settings.adType=='iframe'){$(target).append('<div id="ap_adframe"></div>');$('#ap_adframe').css({width:(settings.adWidth+'px'),height:(settings.adHeight+'px')});$('#ap_adframe').append(settings.adCode);}else{$('#ap_adframe').css({width:(settings.adWidth+'px'),height:(settings.adHeight+'px')});}
if(settings.loadingBar&&!neoedgeAd){$(target).append('<div id="ap_progressbar"></div>');$('#ap_progressbar').hide();$('#ap_progressbar').css('width',settings.barWidth+settings.resizeBar+'px');if(preroll&&!settings.usePercentsInPreroll){if(settings.textOnProgressVisible){$("#ap_progressbar").reportprogress(0,100,SPI.sprintf(settings.progressbarText,Math.ceil(settings.progressTime/1000)),settings.barWidth);}else{$("#ap_progressbar").reportprogress(0,100,false,settings.barWidth);}}else{if(settings.textOnProgressVisible){$("#ap_progressbar").reportprogress(0,100,'0%',settings.barWidth);}else{$("#ap_progressbar").reportprogress(0,100,false,settings.barWidth);}}}
if(!neoedgeAd){$(target).append('<div id="ap_skiptext"></div>');$('#ap_skiptext').empty().append(settings.loadingText);}
$('#ap_adframe, #ap_progressbar').show();skipTextAddOrDecrement();};var progressUpdatePreroll=function(){timeElapsed+=settings.tickInterval;percent=Math.round(100*timeElapsed/settings.progressTime);if(settings.usePercentsInPreroll){if(settings.textOnProgressVisible){$("#ap_progressbar").reportprogress(percent,100,percent+'%');}else{$("#ap_progressbar").reportprogress(percent,100,false);}}else{if(settings.textOnProgressVisible){$("#ap_progressbar").reportprogress(percent,100,SPI.sprintf(settings.progressbarText,Math.ceil((settings.progressTime-timeElapsed)/1000)));}else{$("#ap_progressbar").reportprogress(percent,100,false);}}
skipTextAddOrDecrement();if(percent>=100){if(!neoedgeAd){cleanupAndShowGame();}}};var check98Percent=function(oldvalue){var loaded=$(settings.preloadId)[0].PercentLoaded();if(oldvalue==loaded){if(!neoedgeAd){cleanupAndShowGame();}
if(check98PercentHandle!=null){clearTimeout(sometime);check98PercentHandle=null;}}};var progressUpdatePreloader=function(){var fromTimer=parseInt((settings.progressTime-preTimer)*100/settings.progressTime);var loaded=$(settings.preloadId)[0].PercentLoaded();if(loaded<0){loaded=100;}
percent=fromTimer<loaded?fromTimer:loaded;if(settings.textOnProgressVisible){$("#ap_progressbar").reportprogress(percent,100,percent+'%');}else{$("#ap_progressbar").reportprogress(percent,100,false);}
preTimer-=settings.tickInterval;if(fromTimer>=100){check98PercentHandle=setTimeout(function(){check98Percent(loaded);},2500);}
if(percent<100){if(loaded>=100){skipTextAddOrDecrement(true);}else{skipTextAddOrDecrement();}}else if(!neoedgeAd){cleanupAndShowGame();}};var startPreloader;startPreloader=function(){flashLoadTries++;try{var loaded_temp=$(settings.preloadId)[0].PercentLoaded();intervalHandle=setInterval(progressUpdatePreloader,settings.tickInterval);insertAd();}catch(e){if(flashLoadTries<=3){setTimeout(startPreloader,1000);}else{if(!neoedgeAd){cleanupAndShowGame();}}}};var showAd=function(){if(settings.beforeCallback!=null){settings.beforeCallback.call(that,settings);}
linkShowTimeElapsed=settings.showSkipTime;if(settings.fileType!='swf'||settings.forcePreroll){preroll=true;intervalHandle=setInterval(progressUpdatePreroll,settings.tickInterval);insertAd();}else{settings.gameInsertCallback.call(that);preloaderHeight=$(settings.contentId).css('height');preloaderWidth=$(settings.contentId).css('width');$(settings.contentId).css({width:'0px',height:'0px'});preroll=false;startPreloader();preTimer=settings.progressTime;}};

$.spiPreloaderNeoEdge=function(timeout){return function(_cmd){if(_cmd=="AD_STARTED"){if(parent)neoedgeAd=true;neoedgeHandler=setTimeout(cleanupAndShowGame,timeout||30000);}
if(_cmd=="AD_COMPLETED"){cleanupAndShowGame();}};};

$.fn.spiPreloader=function(options){target=$(this);$.extend(settings,options);if(settings.showAd==true){showAd();}else{if(settings.beforeCallback!=null){settings.beforeCallback.call(that,settings);}
settings.gameInsertCallback.call(that,settings);if(settings.afterCallback!=null){settings.afterCallback.call(that,settings);}}};})(jQuery);


