var test_element=document.createElement('span');var properties=['perspectiveProperty','WebkitPerspective','MozPerspective','OPerspective','msPerspective'];for(var i=0;i<properties.length;i+=1){if(test_element.style[properties[i]]!==undefined){var st=document.createElement('style'),div=document.createElement('div'),prefixes=' -o- -moz- -ms- -webkit- -khtml- '.split(' ');st.textContent='@media ('+prefixes.join('transform-3d),(')+'modernizr){#modernizr{height:3px}}';document.getElementsByTagName('head')[0].appendChild(st);div.id='modernizr';document.documentElement.appendChild(div);ret=div.offsetHeight===3;st.parentNode.removeChild(st);div.parentNode.removeChild(div);if(ret){$('html').addClass('csstransforms3d');}else{$('html').addClass('no-csstransforms3d');}}}
var VariousStuff={init:function(){VariousStuff.setHeights();VariousStuff.navigate();VariousStuff.lifebuoy();VariousStuff.scalePointer();},setHeights:function(){var bottomHeight=$(window).height();$('#bottom-scene').css('min-height',bottomHeight-50+'px');var scaleHeight=$(document).height()-725;$('#scale').css('height',scaleHeight+'px');},navigate:function(){$('a[href*="#"]').click(function(event){event.preventDefault();var el=$(this).attr('href').substring(1);$('html,body').animate({scrollTop:$('#'+el).offset().top},{duration:'slow',easing:'swing'});});},lifebuoy:function(){var lb=$('#lifebuoy'),maxTop=$('#web-explorers>h1').offset().top;VariousStuff.stayInPlace(lb,maxTop);$(lb).css('top',maxTop).click(function(event){event.preventDefault();$('html,body').animate({scrollTop:0},{duration:'slow',easing:'swing'});});$(window).bind('scroll',function(){VariousStuff.stayInPlace(lb,maxTop);});},scalePointer:function(){var sp=document.createElement('div'),maxTop=$('#scale').offset().top+45;$(sp).attr('id','scale-pointer').append('<span>-100m</span><p>That\'s how deep in the sea you are right now! Cool, eh?</p>').insertBefore('#scale');VariousStuff.stayInPlace($(sp),maxTop,'bottom');VariousStuff.setCurrentDepth($(sp));$(window).bind('scroll',function(){VariousStuff.stayInPlace($(sp),maxTop,'bottom');VariousStuff.setCurrentDepth($(sp));});$(sp).hover(function(){$('#scale-pointer, #scale').stop().animate({opacity:'1'},500);$(this).find('p').show().stop().animate({opacity:'1'},500);},function(){$('#scale-pointer, #scale').stop().animate({opacity:'.1'},500);$(this).find('p').stop().animate({opacity:'0'},500,function(){$(this).hide();});});},stayInPlace:function(el,maxTop,pos){var posTop=(pos==='bottom')?$(window).height()-70:50;var currentScroll=$(window).scrollTop()+posTop;(maxTop<currentScroll)?el.css({'position':'fixed','top':posTop}):el.css({'position':'absolute','top':maxTop});},setCurrentDepth:function(el){var cDepth=el.offset(),unit='m'
counter=$(el).find('>span');cDepth=Math.floor((cDepth.top-670)/100)*100;if(cDepth>=1000){unit='K';cDepth=cDepth/1000;}
counter.text('-'+cDepth+unit);}};$(document).ready(VariousStuff.init);
