jQuery(function() {
    jQuery('#email-link').click(function() {
        var email = prompt('Para qual email ?');

        if(email) {
            if(validaEmail(email)) {
                jQuery.ajax({
                    data: {
                        email: email,
                        post: this.rel
                    },
                    success: function(data, status) {
                        alert('Post enviado para ' + email);
                    },
                    error: function(req, status, err) {
                        alert(req.responseText);
                    },
                    url: this.href,
                    type: 'post'
                });
            } else {
                alert('O email informado não é válido');
            }
        }

        return false;
    });
    
    jQuery('#twitter-prox').click(function() {
    	
    	if($('#twitter-posts li:visible').size() > 2) {
    		$('#twitter-posts li:visible:lt(2)').hide();
    	}
    	
    	return false;
    });
    
    jQuery('#twitter-ant').click(function() {
    	$('#twitter-posts li:hidden:last').show();
    	$('#twitter-posts li:hidden:last').show();
    	
    	
    	
    	return false;
    });
});


jQuery(document).ready(function(){
	var pollHtml = jQuery('.post .wp-polls').html();
		pollHtml = '<div class="enquete"><span class="top"><!-- // --></span><div class="borda"><ul><li>'+pollHtml+'</li></ul></div><span class="bottom"><!-- // --></span></div>';
		jQuery('.post .wp-polls').html(pollHtml);
});


function validaEmail(email) {
    var emailPattern = /^[a-zA-Z0-9._\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4}$/;

    if (!emailPattern.test(email)) {
        return false;
    } else {
        return true;
    }
}
