var currentPost = 0;

jQuery(document).ready(function(){
	jQuery("div#top ul#menu li").hover(function(){  
       if(!jQuery(this).hasClass("current") && !jQuery(this).hasClass("desactive")){
        	jQuery(this).addClass("over");   
		}
    }, function(){    
     if(!jQuery(this).hasClass("current") && !jQuery(this).hasClass("desactive")){
       		jQuery(this).removeClass("over");  
	}
    });
	
	jQuery("#socialmedia li img").hover(function(){   
        var img_name_trunk = "";
	    img_name_trunk = jQuery(this).attr("src");
		img_name_trunk = img_name_trunk.replace("_bw.gif",".gif");
		jQuery(this).attr("src",img_name_trunk);
    }, function(){    
 		var img_name_trunk = "";
	    img_name_trunk = jQuery(this).attr("src");
		img_name_trunk = img_name_trunk.replace(".gif","_bw.gif");
		jQuery(this).attr("src",img_name_trunk);
    });

	$("#top_post_previous").click(function() {scrollPost("previous");return false;}).hide();
	$("#top_post_next").click(function() {scrollPost("next");return false;})
	if($(".box_top_post_container .box_top_post").length < 5) $("#top_post_next").hide()
});



function scrollPost(delta) {
	$("#top_post_previous").show();
	$("#top_post_next").show();
	maxPost = $(".box_top_post_container .box_top_post").length-4
	if(maxPost < 0) maxPost = 0
	currentPost += (delta == "next") ? 1 : -1 ;
	if(currentPost <= 0) {
		currentPost = 0;
		$("#top_post_previous").hide();
	}
	if(currentPost >= maxPost) {
		currentPost = maxPost;
		$("#top_post_next").hide();
	}

	$('.box_top_post_container').animate({"left":"-"+(currentPost*234)+"px"}, 500); 
	return false 
}
