﻿/* jQuery SmoothScroll | Modified by Etienne Dupuis in January 2010 to support standard Anchor names instead of IDs */

$(document).ready(function () {

    $('a[href*="#"]').live('click', function ()
     {
        if($(this).attr("tabs") != "true")
        {
            // duration in ms
            var duration = 1000;

            // easing values: swing | linear
            var easing = 'swing';

            // get / set parameters
            var newHash = this.hash.slice(1);
            var target = $("a[name=" + this.hash.slice(1) + "]").offset().top;
            var oldLocation = window.location.href.replace(window.location.hash, '');
            var newLocation = this;

            // make sure it's the same location      
            if (oldLocation + "#" + newHash == newLocation.href) {
                // animate to target and set the hash to the window.location after the animation
                $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function () {

                    // add new hash to the browser location
                    window.location.href = newLocation.href;
                });

                // cancel default click action
                return false;
            }
        }
    });
});


