/*
 * jQuery.scrollFor
 * Copyright (c) 2008 Naoki Ueno
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Date: 6/10/2008
 *
 * @id jQuery.scrollFor
 *
 * @example jQuery.scrollFor('#pagetop');
 *
 * @example jQuery.scrollFor('#pagetop', { duration : 1000, offset : 50 });
 *
 * @example jQuery.scrollFor('#pagetop', {}, callbackFunc);
 *
 * @id jQuery.fn.scrollFor
 *
 * @return {jQuery} Returns the same jQuery object, for chaining.
 *
 * @example jQuery('.pageTopAnchor').scrollFor('#pagetop');
 *
 * @example jQuery('.pageTopAnchor').scrollFor('#pagetop', { event : 'mouseover', duration : 1000, offset : 50 });
 *
 * @example jQuery('.pageTopAnchor').scrollFor('#pagetop', {}, callbackFunc);
 *
 */

(function($){
$.extend({
	scrollFor : function(elem, settings, callback) {
		settings = $.extend({
			duration : 500,
			offset : 0
		}, settings);
		$('html, body').animate({ scrollTop : $(elem).offset().top - settings.offset }, settings.duration, 'swing', callback);
	}
});
$.fn.extend({
	scrollFor : function(elem, settings, callback) {
		return this.each(function() {
			settings = $.extend({
				event : 'click'
			}, settings);
			$(this).bind(settings.event, function(e){
				jQuery.scrollFor(elem, settings, callback);
				e.preventDefault();
			});
		});
	}
});
})(jQuery);



/*------------------------------------------------------------*/
jQuery(function(){
	jQuery('.pagetopAnchor').scrollFor('#page-top');
});