$(function() {

	// Js Hide e Show (CSS)
	
	$('.js-hide').removeClass('js-hide').hide();
	$('.js-show').show();
	
	
	// Form Utils
	form_utils();
	

	var locationPath = filterPath(location.pathname);

	$('a[href*=#]').each(function() {
		if (!$(this).parent().parent().parent().is('#destaques-nav')) {
		
			var thisPath = filterPath(this.pathname) || locationPath;
			
			if ( locationPath == thisPath && (location.hostname == this.hostname || !this.hostname) && this.hash.replace(/#/,'') ) {
				var $target = $(this.hash), target = this.hash;
				
				if (target) {
					try {
						var targetOffset = $target.offset().top;
					
						$(this).click(function(e) {
							e.preventDefault();
							e.stopPropagation();
							
							$('html').animate({scrollTop: targetOffset}, 750, function() {
								//location.hash = target;
							});
							
							return false;
						});
					} catch(e) {}
				}
			}
		}
	});

});


// Filter Path
function filterPath(string) {
	return string.replace(/^\//,'').replace(/(index|default).[a-zA-Z]{3,4}$/,'').replace(/\/$/,'');
}


// Form Utils
function form_utils() {
	// Set the status bar help title
	$('input, select, textarea').each(function() {
		var $this = $(this);

		$this.bind('focus', function() {
			window.status = $this.attr('title');
		});

		$this.bind('blur', function() {
			window.status = '';
		});
	});
}