//
//	jquery.bren.scroller
//
//	Usage:
//		$(function() {
//			$('a[href^=#]').bren_scroller({
//				speed			: 500,
//				easing			: null,
//				ofsx			: 0,
//				ofsy			: 0,
//			});
//			$.fn.bren_hashscroller({
//				speed			: 500,
//				easing			: null,
//				ofsx			: 0,
//				ofsy			: 0,
//			});
//		});
//

$.fn.bren_geturihash = function()
{
    return window.location.hash.substring(1, window.location.hash.length);
}

$.fn.bren_scroller = function(myconfig)
{
	$(this).each(function()
		{
			var config = jQuery.extend(
				{
					speed			: 500,
					easing			: null,
					ofsx			: 0,
					ofsy			: 0,
				},
				myconfig
			);

			$(this).click(function() {
				$('html,body').animate(
					{
						scrollLeft		: $($(this).attr("href")).offset().left + config.ofsx + 'px',
						scrollTop		: $($(this).attr("href")).offset().top + config.ofsy + 'px'
					},
					config.speed,
					config.easing
				);
				return true;
			});

			return this;
		}
	);
}

$.fn.bren_hashscroller = function(myconfig)
{
	var config = jQuery.extend(
		{
			speed			: 500,
			easing			: null,
			ofsx			: 0,
			ofsy			: 0,
		},
		myconfig
	);

	var hash = $.fn.bren_geturihash();
	if (hash.length > 0) {
		$('html,body').animate(
			{
				scrollLeft		: $('#' + hash).offset().left + config.ofsx + 'px',
				scrollTop		: $('#' + hash).offset().top + config.ofsy + 'px'
			},
			config.speed,
			config.easing
		);
	}

	return this;
}


