$(document).ready(function(){
	$("a.linkExterno").attr('target','_blank');
	
     
   if($('#listaPortfolio').length > 0){
	   $('#listaPortfolio a').click(function(){
		   link = $(this).attr('href');
		   $.ajax({
			  type: 'POST',
			  url: 'pfImagens/'+link+'.php',     
			  dataType: 'html',
			  beforeSend: function(){                                                  
				$('#contentPortfolio').html("");
				$('#contentPortfolio').html("<div class='loader'>Carregando...<br/><img src='../imagens/loader.gif' alt='carregando'/></div>");
			  },
			  success: function(msg) {            
				$('#contentPortfolio').html("");
				$('#contentPortfolio').html(msg);           
			  },
			  error: function(msg){
				$('#contentPortfolio').html("");
				$('#contentPortfolio').html("Erro no carregamento...");                  
			  }
			});
			return false;
	   });
   }
   
   // Quando o formulário for enviado, essa função é chamada
    $('#submitFormComen').click(function(){ 
        $.ajax({
          type: 'POST',
          url: $('#commentform').attr('action'),     
          data: 'nome='+ $('#nome').val() +'&email='+ $('#email').val()+'&mensagem='+ $('#mensagem').val()+'&setor='+ $('#setor').val()+'&telefone='+ $('#telefone').val() ,
          dataType: 'html',
          beforeSend: function(){                                      
            $('#retorno').hide();
            $('#status').show();
          },
          success: function(msg) {            
            $('#status').hide();
            $('#retorno').show();              
            $('#retorno').html("");              
            $('#retorno').html(msg).show();            
          },
          error: function(msg){
            $('#status').hide("");
            $('#retorno').show(); 
            $('#retorno').html("");            
            $('#retorno').html("Ocorreu um erro durante o processamento. Tente novamente!").show();              
          }
        });
        $('#nome').val(' ');
        $('#email').val(' ');
        $('#mensagem').val(' ');
        $('#telefone').val(' ');
        return false;
    });
      
   
});



