function animateShip(a){var b=ships[a];if(shipPos[a]<-shipSize[a]){if(Math.random()>(lowFrameRate?.002:.001))return;shipPos[a]=window.innerWidth||document.body.clientWidth;b.top=(gi("clipper").offsetHeight-gi("footer").offsetHeight)*Math.random()+"px";if(shipTrail[a]){b.height=px(128);shipTrailFrame[a]=0;b.opacity=1;b.filter="alpha(opacity=100)"}}else{shipPos[a]-=shipSpeed[a];if(isIE)shipPos[a]-=shipSpeed[a]}b.left=shipPos[a]+"px";if(shipTrail[a]&&shipPos[a]<-(window.innerWidth||document.body.clientWidth)){shipTrailFrame[a]++;b.top=parseInt(b.top)+6+"px";if(isIE){shipTrailFrame[a]++;b.top=parseInt(b.top)+6+"px"}var c=128-12*shipTrailFrame[a];if(c<0)b.height="0px";else b.height=px(c);var d=1-shipTrailFrame[a]/20;b.opacity=d;b.filter="alpha(opacity="+d*100+")"}}function fadeToBlackTransition(){if(!_tNode){_tNode=document.createElement("DIV");_tNode.id="fadeToBlackTransition";_tNode.style.opacity=0;_tNode.style.filter="alpha(opacity=0)";gi("clipper").appendChild(_tNode)}_tNode.style.opacity=_tFrame/8;_tNode.style.filter="alpha(opacity="+_tFrame/.08+")";if(_tFrame>=8){window.clearInterval(_tTimer);_tFrame=-2;_tCallback=null;window.location.href=_pageTarget}}function diamondsTransition(){if(!_tNode){_tNode=document.createElement("DIV");_tNode.id="diamondsTransition";var a=document.createElement("DIV");a.id="diamondsTransitionBlack";_tNode.appendChild(a);gi("clipper").appendChild(_tNode)}_tNode.style.left=100*(16-_tFrame)/16+"%";if(_tFrame>=32){window.clearInterval(_tTimer);_tFrame=-2;_tCallback=null;window.location.href=_pageTarget}}function shipTransition(){if(!_tNode){_tNode=document.createElement("DIV");_tNode.id="shipTransition";var a=document.createElement("DIV");a.id="shipTransitionContent";a.innerHTML="<div id='shipTransitionTrail'><div class='ship4trail'><div class='ship4trail1'><div class='ship4trail2'></div></div></div>"+"<div class='ship4'><img src='"+imgPath+"/ship-4c.png' id='shipTransitionShip' /></div></div>";_tNode.appendChild(a);gi("clipper").appendChild(_tNode)}if(_tFrame>42){window.clearInterval(_tTimer);_tFrame=-2;_tCallback=null;window.location.href=_pageTarget}else if(_tFrame>31){_tNode.style.top=50-(_tFrame-31)*10+"%";_tNode.style.bottom=_tNode.style.top;_tNode.style.left="-800px"}else{_tNode.style.left=100*(30-_tFrame)/30+"%"}}function pageTransition(){if(!_tCallback){if(_tNode&&!document.addEventListener){clearPageTransition()}return}if(!_tEventRegistered&&window.addEventListener){_tEventRegistered=true;window.addEventListener("pageshow",clearPageTransition)}_tFrame++;if(lowFrameRate)_tFrame++;_tCallback()}function clearPageTransition(){if(_tNode){_tNode.parentNode.removeChild(_tNode);_tNode=null;_tFrame=0}}function transitionTo(a,b,c){if(_tFrame!=0)return;if(audioshim!=null){audioshim.playSelect()}else{var d=gi("selectSound");try{d.pause();d.currentTime=0}catch(e){}try{d.play()}catch(e){}}if(b>=GAMES_ANIM_BASE&&b<=GAMES_ANIM_MAX){var f=gi("gamesHex"+(b-GAMES_ANIM_BASE)).parentNode;if(window.location.href.indexOf(f.href)!=-1){return eatEvent(a)}_pageTarget=f.href+"#from=games";_tCallback=fadeToBlackTransition}else{_pageTarget=gi(animID[b]+"Menu").getAttribute("href");if(!_pageTarget){_pageTarget=gi(animID[b]+"Menu").getAttribute("href2")}if(b!=BLOG_ANIM){_pageTarget+="#from="+getCurrentPage()}_tCallback=shipTransition;if(b==CAVETREK_ANIM||window.location.href.indexOf("cave")!=-1||window.location.href.indexOf("games")!=-1)_tCallback=diamondsTransition}return eatEvent(a)}function backgroundMusic(){var a=gi("backgroundMusic"),b=gi("backgroundMusic2");try{if(!b){b=a.cloneNode(true);b.id="backgroundMusic2";document.body.appendChild(b);a.addEventListener("ended",backgroundMusic);b.addEventListener("ended",backgroundMusic);if(loadSetting("muteMusic")){styleOf("muteMusic").backgroundImage="url("+imgPath+"/mute-music-light.png)"}else if(a.readyState==4){a.play()}else{a.autoplay=true;a.play()}return}if(a.currentTime==0){b.currentTime=0;b.pause();a.play()}else if(b.currentTime==0){a.currentTime=0;a.pause();b.play()}}catch(c){}}function hideLoadingScreen(){gi("loadContent").style.display="block";if(!_hideLoadingTimer){_hideLoadingTimer=window.setInterval(hideLoadingScreen,33)}if(!_loadingReady){if(findUnloadedImages().length==0)_loadingReady=true}if(_loadingReady){var a=gi("loadingChase1");if(a&&_loadingFadeFrame>9){var b=gi("loadingChase2"),c=gi("loadingChase3"),d=gi("loadingChase");a.style.display="none";b.style.display="none";if(_loadStartTime<(new Date).getTime()-250){c.style.display="inline-block"}d.style.background="transparent";d.style.backgroundImage="none"}var e=gi("loading"),f=1;if(e.className=="fromBlack")f=2;for(var g=0;g<f;g++){_loadingFadeFrame--;if(lowFrameRate)_loadingFadeFrame--;if(isMobile)_loadingFadeFrame-=2}if(_loadingFadeFrame<=0){e.style.display="none";window.clearInterval(_hideLoadingTimer)}else{e.style.opacity=_loadingFadeFrame/10;e.style.filter="alpha(opacity="+_loadingFadeFrame*10+")"}}}function findUnloadedImages(a){if(!a){a=document.getElementsByTagName("IMG")}var b=[];for(var c=a.length-1;c>=0;--c){if(!a[c].complete)b.push(a[c])}return b}function loadSetting(a){var b=gi("ieUserData");if(b){b.load("nicalisSettings");return b.getAttribute(a)}else{return window.localStorage.getItem(a)}}function storeSetting(a,b){var c=gi("ieUserData");if(c){c.setAttribute(a,b);c.save("nicalisSettings")}else{window.localStorage.setItem(a,b)}}function toggleMusic(){var a=gi("backgroundMusic"),b=gi("backgroundMusic2");try{var c=loadSetting("muteMusic");if(c){styleOf("muteMusic").backgroundImage="url("+imgPath+"/mute-music.png)";if(audioshim!=null){audioshim.playBgm()}else if(b.currentTime==0){a.play()}else{b.play()}storeSetting("muteMusic","")}else{styleOf("muteMusic").backgroundImage="url("+imgPath+"/mute-music-light.png)";try{if(audioshim!=null){audioshim.pauseBgm()}else{gi("backgroundMusic").pause();gi("backgroundMusic2").pause()}}catch(d){}storeSetting("muteMusic","1")}}catch(d){}}function audioshimReady(){audioshim=gi("backgroundMusicFlashObject");if(!audioshim.playBgm)audioshim=gi("backgroundMusicFlashEmbed");if(audioshim.playBgm){var a=loadSetting("muteMusic");if(a){styleOf("muteMusic").backgroundImage="url("+imgPath+"/mute-music-light.png)"}else{audioshim.setAutoPlay(true)}}else{audioshim=null}}function updateParallax(){if(noParallax)return;if(_parallaxNodes.length==0){try{_parallaxNodes=document.getElementsByClassName("parallax")}catch(a){_parallaxNodes=[];var b=document.getElementsByTagName("DIV");for(var c=b.length-1;c>=0;--c){if(b[c].className.indexOf("parallax")!=-1)_parallaxNodes.push(b[c])}}}var d=/mag(-?[0-9.]+)/;for(var c=0;c<_parallaxNodes.length;c++){var e=_parallaxNodes[c].className.match(d)[1]/lowRes,f=styleOf(_parallaxNodes[c]);f.left=Math.floor(e*parallaxX)+"px";f.top=Math.floor(e*parallaxY)+"px";f.right=Math.ceil(-e*parallaxX)+"px";f.bottom=Math.ceil(-e*parallaxY)+"px"}}function parallax(a,b){if(!a){parallaxX=(1-window.event.clientX/document.body.clientWidth)*10;parallaxY=(1-window.event.clientY/gi("clipper").offsetHeight)*7}else if(a.touches&&a.touches.length==1){var c=a.touches[0].pageX,d=a.touches[0].pageY;parallaxX=(1-c/window.innerWidth)*10;parallaxY=(1-d/window.innerHeight)*7,e=document.getElementsByClassName("hasMouseOver"),f=null;for(var g=0;g<e.length;g++){var h=e[g].getBoundingClientRect();if(h.left<c&&h.right>c&&h.top<d&&h.bottom>d){f=e[g];break}}if(_mobileLastTouch&&_mobileLastTouch!=f){try{_mobileLastTouch.onmouseout(a.touches[0])}catch(i){}}if(!b||Math.abs(c-_mobileStartX)>10||Math.abs(d-_mobileStartY)>10)_mobileClick=null;if(f){try{f.onmouseover(a.touches[0])}catch(i){}if(b){_mobileClick=f;_mobileStartX=c;_mobileStartY=d}}_mobileLastTouch=f}else{parallaxX=(1-a.clientX/window.innerWidth)*10;parallaxY=(1-a.clientY/window.innerHeight)*7}}function onTouchEnd(a){if(!_mobileLastTouch||!_mobileClick)return;try{_mobileLastTouch.onclick(a.changedTouches[0])}catch(b){}}function onTouchStart(a){parallax(a,true)}function closureWrap(a,b,c,d){var e=a,f=b,g=c,h=d;return function(a){if(!a)a=window.event;e(a,f,g,h)}}function computedStyleOf(a){try{if(typeof a=="string"){if(window.getComputedStyle)return window.getComputedStyle(gi(a));return gi(a).currentStyle}else{if(window.getComputedStyle)return window.getComputedStyle(a);return a.currentStyle}}catch(b){return{}}}function styleOf(a){try{if(typeof a=="string")return gi(a).style;else return a.style}catch(b){return{}}}function getCurrentPage(){try{var a=/\/([A-Za-z]*)\.php/;return window.location.href.match(a)[1]}catch(b){return"index"}}function eatEvent(a){a.cancelBubble=true;a.returnValue=false;if(a.stopPropagation)a.stopPropagation();if(a.preventDefault)a.preventDefault();return false}function stopSelection(a){if(!a)a=window.event;var b=a.srcElement||a.targetElement;while(b){if(b.className&&b.className.indexOf("allowSelection")>=0)return true;b=b.parentNode}return eatEvent(a)}function commonInit(){if(isIE){var a=document.getElementsByTagName("A");for(var b=0;b<a.length;b++){if(a[b].onclick){a[b].setAttribute("href2",a[b].getAttribute("href"));a[b].removeAttribute("href")}}}try{document.body.addEventListener("mousemove",parallax,true);document.body.addEventListener("touchmove",parallax,true);document.body.addEventListener("touchstart",onTouchStart,true);document.body.addEventListener("touchend",onTouchEnd,true)}catch(c){document.onmousemove=parallax}try{document.body.addEventListener("selectstart",stopSelection,false);document.body.addEventListener("mousedown",stopSelection,false);document.body.addEventListener("touchstart",stopSelection,false)}catch(c){document.body.attachEvent("selectstart",stopSelection);document.body.attachEvent("mousedown",stopSelection)}}var CONTACT_ANIM=0,GAMES_ANIM=1,ABOUT_ANIM=2,BLOG_ANIM=3,CAVETREK_ANIM=4,NUM_ANIMS=5,INDEX_ANIM=5,GAMES_ANIM_BASE=6,GAMES_ANIM_MAX=GAMES_ANIM_BASE+5,animID=["contact","games","about","blog","caveTrek","index"],parallaxX=0,parallaxY=0,_parallaxNodes=[],_tFrame=0,_tTimer=0,_pageTarget="",_tNode=null,_tCallback=null,_tEventRegistered=false,contactAnimYPos=[[0,0,0,0,0,0,0,0,0,0,0,2,4,6,8,10,14,18,22,26,30,50,70,90,110,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130],[0,0,0,0,0,0,2,4,6,8,10,14,18,20,24,28,48,68,88,108,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128],[0,0,0,0,0,0,0,0,0,0,0,2,4,6,8,10,14,18,22,26,30,50,70,90,110,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130],[128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,118,98,78,58,40,36,32,28,24,22,20,18,16,14,12,12,12,12,12,12,12,12,12,12],[128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,126,116,106,96,86,76,72,68,66,64,62,60,59,58,57,56,56]],ua=window.navigator.userAgent,gi=function(x){return document.getElementById(x)},isIE=ua.indexOf("MSIE")>-1,isMobile=ua.toLowerCase().indexOf("mobile")>-1||ua.indexOf("Nintendo")>-1,lowFrameRate=isIE||isMobile,audioshim=null,_mobileLastTouch=null,_mobileStartX=null,_mobileStartY=null,_mobileClick=null,noParallax=ua.indexOf('Nintendo')>-1,px=function(n){return n/lowRes+"px"}
if(!(/CPU .*OS ([56789]|\d{2,})_/i.test(window.navigator.userAgent))){var scrollNodes=document.getElementsByClassName('scrollable'),sbars=[],isScrolling=false,scrollPos=0;function sbStart(sb,e){isScrolling=sb;scrollPos=e.touches[0].screenY;document.body.addEventListener('touchmove',sbScroll);return eatEvent(e);}function sbScroll(e){var offset=scrollPos-e.touches[0].screenY;scrollPos=e.changedTouches[0].screenY;isScrolling.scrollTop+=offset;return eatEvent(e);}function sbRelease(e){if(isScrolling){document.body.removeEventListener('touchmove',sbScroll);isScrolling=false;return eatEvent(e);}}for(i in scrollNodes){var n=scrollNodes[i];var s=getComputedStyle(n);if(!s||(s.overflowY!='auto'&&s.overflowY!='scroll'))continue;n.ontouchstart=function(s){return function(e){return sbStart(s,e||window.event);}}(n);sbars.push(n);}document.body.addEventListener('touchend',sbRelease,true)}

