//==================== function onResize(){ $("#home").height(windowHeight); $("#contacts").height(Math.max(650, windowHeight - 78- $("#split-contacts").height())); $("#scroller").height($("#fixed-content-inner").height() - 78); } function Move(animate, from){ var wPos = $window.scrollTop(); //position of the scrollbar targetPosition = -wPos; if(animate){ if(scrollAnimId == 0){ scrollAnimId = setInterval("updateScroll()", 33); } }else{ divTop = targetPosition; $fixed_content_inner.css("margin-top", divTop); updateParallaxPos(); } } var scrollAnimId = 0; var targetPosition = 0; var divTop = 0; var $fixed_content_inner; var $contentBlocks; function updateScroll(){ var delta = (targetPosition-divTop)/5; divTop = divTop + delta; if(Math.abs(delta)<0.05){ clearInterval(scrollAnimId); scrollAnimId = 0; divTop = targetPosition; } $fixed_content_inner.css("margin-top", divTop); updateParallaxPos(); } var setHashDelayId; function updateParallaxPos(){ $contentBlocks.each(function(index){ var thisH = $(this).height(); var thisAbsPos = $(this).position().top; var thisRelPos = $(this).offset().top; var thisRatio = -(thisAbsPos-windowHeight)/(thisH+windowHeight); if(thisRatio>=0 && thisRatio<=1){ $(this).css("background-position", "50% " + (90-thisRatio*400) + "px"); $(".black-shield", $(this)).css("opacity", Math.min(0.6, Math.max(0,thisRatio*4-1.8))); if(thisAbsPos<-660 && thisAbsPos>-1350){ $(".copyright", $(this)) .css("margin-top", 800 + (-660 - thisAbsPos)) .css("margin-bottom", 600 - (-660 - thisAbsPos)); }else if(thisAbsPos<=-1350){ $(".copyright", $(this)) .css("margin-top", 800 + (-660 +1350)) .css("margin-bottom", 600 - (-660 +1350)); }else if(thisAbsPos>=-660){ } //$(".copyright", $(this)).css("top", copRatio * 1050); //$(".copyright", $(this)).css("margin-top", (thisH*0.9)*thisRatio); } if((-divTop+windowHeight - 128)>thisRelPos && (-divTop+windowHeight-128)li>a").removeClass("active"); if(selectedMenuIndex>0){ $("#menu>li>a").eq(selectedMenuIndex-1).addClass("active"); } //hash change clearTimeout(setHashDelayId); //setHashDelayId = setTimeout(setHash, 1000, getId($(".parallax-anchor", $(this)).attr("id"))) var hid = getId($(".parallax-anchor", $(this)).attr("id")); setHashDelayId = setTimeout(function(){ setHash(hid); }, 1000); } }; }); if(officeObj) officeObj.onScroll(); } var selectedMenuIndex = 0; $(document).ready(function() { $fixed_content_inner = $("#fixed-content-inner"); $contentBlocks = $(".content-block") $("ul#menu > li > a").click(function(e){ if($(this).data("type") == "external_link"){ return; } e.preventDefault(); var path = $(this).attr("href").substr(1); var parallaxAnchor = $("#anchor-"+path); var scrollTop = parallaxAnchor.offset().top - 240; $('html,body').animate( { scrollTop: scrollTop }, {queue: false, easing: 'easeInOutExpo', duration: 2000} ); if($(this).parent().index() == 4){ if(!$("#projects-filter ul li").first().hasClass("active")){ $("#projects-filter ul li a").first().click(); } } }); $(document).keydown(function(e){ if(e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return; switch(e.keyCode){ case 38://up if($("ul#menu > li > a.active").length>0){ var index = $("ul#menu > li > a.active").parent().index(); if(index == 0){ $('html,body').animate( { scrollTop: 0 }, {queue: false, easing: 'easeInOutExpo', duration: 2000} ); }else{ $("ul#menu > li > a").eq(index-1).click(); } } return false; break; case 40://down if($("ul#menu > li > a.active").length>0){ var index = $("ul#menu > li > a.active").parent().index(); $("ul#menu > li > a").eq(index+1).click(); }else{ $("ul#menu > li > a").first().click(); } return false; break; case 8://backspace break; default: console.log(e.keyCode); break; } }); windowHeight = $window.height(); windowWidth = $window.width(); var hash = getHash(); $window.resize(function(){ windowHeight = $window.height(); windowWidth = $window.width(); onResize(); Move(false, "resize"); }); $(window).scroll(function(event){ //when the user is scrolling... Move(!jQuery.browser.opera, "scroll"); }); $window.bind('mousewheel', function(){ $('html,body').stop(); }); onResize(); Move(false, "firsttime"); console.log(hash); if(hash == "newslettersarchive" || hash=="sprendimu-era"){ $("#menu li a").eq(0).click(); aboutMenu.clickLink("newslettersarchive"); }else if(hash == "fima-service-center"){ if($('#menu-kontaktai').length>0) { console.log('trigger'); $('#menu-kontaktai').click(); } else{ $('#menu li a').last().click(); } $('#off-locations li a').last().click(); }else if(hash){ $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); var parallaxAnchor = $("#anchor-"+hash); if($.browser.chrome){ return; } if(parallaxAnchor.length){ $('html,body').scrollTop(parallaxAnchor.offset().top-240); Move(false, "hash"); } }else{ setHash("top"); } $(window).bind( 'hashchange', function( event ) { var hash = getHash(); console.log('hashchange', hash); if(hash && hash != "top"){ var parallaxAnchor = $("#anchor-"+hash); if(parallaxAnchor.length){ $('html,body').scrollTop(parallaxAnchor.offset().top-240); Move(false, "hashchange"); } }else{ $('html,body').scrollTop(0); Move(false, "hashchange"); } }); });