$(document).ready(function(){ //social link hover (rolls up on mouseover and mouseout. grabs the items height and uses that to determine movement. $(".scHdr").hover(function(){ var h = $(this).height(); $(this).stop().animate({backgroundPositionY: "-" + h + "px"}, 300); }, function(){ var h = $(this).height(); $(this).stop().animate({backgroundPositionY: "-" + (h*2) + "px"}, 300, function(){ $(this).css({backgroundPositionY: "0px"}); }); }); /********* Smooth Scroll for IE/Chrome *********/ var s = true; //this is for people that user arrow keys when in a drop down list $("body select").focus(function(){ s = false; }); $("body select").blur(function(){ s = true; }); $(".preventPageScroll").hover(function () { s = false; //window.removeEventListener('DOMMouseScroll', wheel, false) }, function () { s = true; //window.addEventListener('DOMMouseScroll', wheel, false) }); if (window.addEventListener) window.addEventListener('DOMMouseScroll', wheel, false); window.onmousewheel = document.onmousewheel = wheel; var time = 1000; var distance = 300; function wheel(event) { if (s) { if (event.wheelDelta) delta = event.wheelDelta / 120; else if (event.detail) delta = -event.detail / 3; handle(); if (event.preventDefault) event.preventDefault(); event.returnValue = false; }; } function handle() { $('html, body').stop().animate({ scrollTop: $(window).scrollTop() - (distance * delta) }, time); } $(document).keydown(function (e) { if (s) { switch (e.which) { //up case 38: $('html, body').stop().animate({ scrollTop: $(window).scrollTop() - distance }, time); break; //down case 40: $('html, body').stop().animate({ scrollTop: $(window).scrollTop() + distance }, time); break; } }; }); /********* *********/ /********* *********/ ////////////////////////////////////////////////fade btns $('.fadeThis').append('').each(function () { var $span = $('> span.hover', this).css('opacity', 0); $(this).hover(function () { if ($(this).hasClass('inactive')){ //do nothing } else{ $span.stop().fadeTo(300, 1); } }, function () { if ($(this).hasClass('active')){ //do nothing } else{ $span.stop().fadeTo(300, 0); } }); }); ////////////////////////////////////////////////////////menu////////////////////////// $("ul#navUL li").hover(function(){ $(this).find(".mBtn").css({backgroundPosition: "0px bottom"}).stop().animate({color: "#ba0605"}); $(this).find(".subMenu").stop(true, true).slideDown(200); }, function(){ $(this).find(".mBtn").css({backgroundPosition: "0px top"}).stop().animate({color: "#5a5a5b"}); $(this).find(".subMenu").stop(true, true).slideUp(200); }); $(".subMenu .menuContent a").hover(function(){ $(this).stop().animate({paddingLeft: "5px", color: "#ba0605"}); }, function(){ $(this).stop().animate({paddingLeft: "0px", color: "#5a5a5b"}); }); /////////////////anchor slide $(".scroll").click(function(event){ //prevent the default action for the click event event.preventDefault(); //get the full url - like mysitecom/index.htm#home var full_url = this.href; //split the url by # and get the anchor target name - home in mysitecom/index.htm#home var parts = full_url.split("#"); var trgt = parts[1]; //get the top offset of the target anchor var target_offset = $("#"+trgt).offset(); var target_top = target_offset.top; //goto that anchor by setting the body scroll top to anchor top $('html, body').animate({scrollTop:target_top}, 500); }); });