/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// easing type
jQuery.easing.easeInOutQuad=function (x, t, b, c, d) {if ((t/=d/2) < 1) return c/2*t*t + b;return -c/2 * ((--t)*(t-2) - 1) + b;};

//jQuery.easing.easeInOutQuart=function(x,t,b,c,d){if((t/=d/2)<1) return c/2*t*t*t*t+b;return -c/2 *((t-=2)*t*t*t - 2)+b;};

//jQuery.easign.easeInOutQuint=function (x, t, b, c, d) {if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;return c/2*((t-=2)*t*t*t*t + 2) + b;};
/*
* Animated Scrolling for Same-Page Links
* @see http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links
* @see http://github.com/kswedberg/jquery-smooth-scroll
*/

;(function($){$.fn.smoothScroll=function(options){var opts=$.extend({},$.fn.smoothScroll.defaults,options),locationPath=filterPath(location.pathname),scrollElem=scrollableElement('html','body');this.each(function(){var link=this,$link=$(this),hostMatch=((location.hostname===link.hostname)||!link.hostname),pathMatch=(filterPath(link.pathname)||locationPath)===locationPath,thisHash=link.hash && link.hash.replace('#',''),scrollTargetExists=thisHash && !!$('#'+thisHash).length;if(hostMatch && pathMatch && scrollTargetExists){var include=true,exclude=opts.exclude,elCounter=0,el=exclude.length,excludeWithin=opts.excludeWithin,ewlCounter=0,ewl=excludeWithin.length;while(include && elCounter<el){if($link.is(exclude[elCounter++])){include=false;}}while(include && ewlCounter<ewl){if($link.parents(excludeWithin[ewlCounter++]+':first').length){include=false;}}if(include){$link.data('scrollTarget','#'+thisHash);}}});this.die('click.smoothscroll').live('click.smoothscroll',function(event){var scrollTargetId=$(this).data('scrollTarget');if(scrollTargetId){event.preventDefault();var scrollTargetOffset=$(scrollTargetId).offset().top;$(scrollElem).animate({scrollTop:scrollTargetOffset+opts.offset},1000,'easeInOutQuad',function(){});}});return this;function scrollableElement(els){for(var i=0,argLength=arguments.length;i<argLength;i++){var el=arguments[i],$scrollElement=$(el);if($scrollElement.scrollTop()>0){return el;}else{$scrollElement.scrollTop(1);var isScrollable=$scrollElement.scrollTop()>0;$scrollElement.scrollTop(0);if(isScrollable){return el;}}}return [];}function filterPath(string){return string.replace(/^\//,'').replace(/(index|default).[a-zA-Z]{3,4}$/,'').replace(/\/$/,'');}function debug($obj){if(window.console && window.console.log){window.console.log($obj);}}};$.fn.smoothScroll.defaults={exclude:[],excludeWithin:[],offset:0};})(jQuery);

// init settting

$(document).ready(function() {
	$('a[href*=#]').smoothScroll({offset: -20});
});
