/**
 * author: Ciro Feitosa - http://cirofeitosa.com
 * 2009/oct
 */

$(document).ready(function()
{
	/**
	 * animated scroll
	 */
	$('a[href*=#]').click(function()
	{
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname)
		{
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length)
			{
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 500);
				location.replace($(this).attr('href'));
				return false;
			}
		}
	});

	var url_hash = location.href.split('#');
	url_hash = url_hash[1];
	if (url_hash) {
		var $target = $('#' + url_hash);
		var targetOffset = $target.offset().top;
		$('html,body').animate({scrollTop: targetOffset}, 500);
		return false;
	}

});