 $(document).ready(function() {
    
        $(".filter_tweet").click(function () {
           var x = "includes/tweetactions.php?op=block& tweetid=" + $(this).attr("id") ;
           $.post(x);
            // $(this).attr("id") 
              //  alert ($(this).attr("id"));
              alert ("Ok. Deze tweet wordt gefilterd, druk op F5 / pagina opnieuw laden om het resultaat te zien.");  
            });
 
        $("#tweetbutton").click(function () {
        
        //move tweetpanel:    
        if($("#tweetpanel").css("display")=='none') {
      
             $("#tweetpanel").css({"left": "-350px", "display": "block"});
             $(this).animate({left: 355}, 500); //350 = breedte van tweetpanel + 5
             $("#tweetpanel").animate({"left": "0"}, 500); //350 = breedte van tweetpanel + 5
             
        } else {
            
             $(this).animate({left: 0}, 500); //350 = breedte van tweetpanel + 5
             $("#tweetpanel").animate({"left": "-350px"}, 500, function() { $(this).css({"display": "none"}); });
        }
    });
  
	function twitterNextPrev()
	{
	
		var siteName = $("site").attr("name");
	
		$(".tweet_close").click(function () {

				if($("#tweetpanel").css("display") == 'block') {
				
					$("#tweetbutton").animate({left: 0}, 500); //350 = breedte van tweetpanel + 5
					$("#tweetpanel").animate({"left": "-350px"}, 500, function() { $(this).css({"display": "none"}); });
				}
		 });
	
		$("#tweetpanel .next").unbind('click').click(function() {
			
			$nextPage = $(this).attr('rel');
			
			$("#tweetpanel").append("<img src='images/loading.gif' />");

			$.ajax({
			  url: "templates/proostmagazine/twitter_default.php?ajax=1&p=" + $nextPage,
			  success: function(x){
				
				$("#tweetpanel").html(x);
				$('html, body').animate({scrollTop:0}, 'slow');
			  }
			});
		});
		
		$("#tweetpanel .prev").unbind('click').click(function() {
			
			$nextPage = $(this).attr('rel');
			
			$("#tweetpanel").append("<img src='images/loading.gif' />");
			
			$.ajax({
			  url: "templates/proostmagazine/twitter_default.php?ajax=1&p=" + $nextPage,
			  success: function(x){
				
				$("#tweetpanel").html(x);
				$('html, body').animate({scrollTop:0}, 'slow');
			  }
			});
		});
	}
	twitterNextPrev();
	
	//Ajax handler; trigger deze methode na alle succesvolle requests
	$('body').ajaxSuccess(function(event, XMLHttpRequest, ajaxOptions) { 
		twitterNextPrev();
	});

});
