$(function() {
    var $tip = $("<div></div>").addClass("page-tip").hide();
    $("body").append($tip);
    apply_page_pager_tooltips();
    apply_page_pagers();
    
    
    function apply_page_pager_tooltips() {    
        $(".page-pager a[class!=selected]").hover(
            function() {            
                var $me = $(this);            
                $tip.html(this.title);
                this.title = '';
                $tip.fadeInWithStop(100);            
                var pos = $(this).offset();
                if($me.closest(".project-page-header").hasClass("page-pager-bottom")) {
                    $tip.css("top", pos.top - $me.height()+3);
                } else {
                    $tip.css("top", pos.top + $me.height());
                }
                $tip.css("left", pos.left - ($tip.outerWidth()/2-($me.outerWidth()/2)));
            },
            function() {            
                this.title = $tip.html();
                $tip.fadeOutWithStop(100);            
            }
        );
    }
    
    function apply_page_pagers() {
        
    }
    
    function kill_tt_filter() {
        if(this.style.removeAttribute) {
            this.style.removeAttribute('filter');
        }
    }
    
    $("#client-news-list").apply_ajax_pagers(
        function(url) {            
            var page_rx = /newspage=(\d*)/;
            var slug_rx = /projects\/(.*)\//;
            var page_num = url.match(page_rx)[1];
            var project_slug = url.match(slug_rx)[1];
            var x_url = "/portfolio/news/" + project_slug + "/" + page_num;
            return x_url;
        }, "#client-news-list ul li", kill_tt_filter);
   
});
