$(document).ready(function() {
	criaLinkExterno();
});

/* Habilita os links externos para abrirem em uma nova janela */
function criaLinkExterno() {
	$("a[rel='external']").click(function() {
		$(this).attr("target", "_blank");
	});
}

/* Validacao do Formulario de Comentarios */
function validarComentario() {
	var isError = false;

	$(".aviso").hide("");

	if ( $("#author").val() == "" ) {
		$(".aviso").fadeIn("slow");
		isError = true;
	}

	if ( !isEmail($("#email").val()) ) {
		$(".aviso").fadeIn("slow");
		isError = true;
	}

	if ( $("#comment").val() == "" ) {
		$(".aviso").fadeIn("slow");
		isError = true;
	}

	return !isError;
}

function isEmail(email) {
	var expr = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	
	if(email.search(expr) == -1)
	{
		return false;
	}
	return true;
}


$( function() {
	$( '.category' ).click( function() {
		$( this ).toggleClass( 'active' )
		$( this ).siblings( '.dropdown' ).toggle();
		$( this ).find( '.indicator' ).toggleClass( 'indicator-active' );
		return false;
	} );
			
	$( '#dock > li' ).hover( function() {
		$( '.latest' ).fadeOut( 'fast' );
		$( this ).addClass( 'dock-active' );
		$( this ).children( 'span' ).fadeIn( 200 );
	}).bind( "mouseleave", function() {		
		$( this ).removeClass( 'dock-active' );	
		$( this ).children( 'span' ).fadeOut( 200 );
	} );
			
	$( '#dock' ).bind( "mouseleave", function() {
		$( '.latest' ).fadeIn( 1000 );
	} );
} );