$(function() {
    // Clean up search box
    $('#search').val('');

    $('#vb_form_name, #vb_form_pass').focus(function() {
        $(this).val('');
    });

    // Home page slider animation {{{
    $('#slider_thumbs li').mouseover(function() {
        var height = $(this).attr('id').replace('thumb_', '') * 350;
        var properties = {};
        properties['top'] = -height;
        $('.slider_item').stop().animate(properties, 300);
    }); // }}}
    // Navigation bar drop down menu {{{
    $('.navbar_item').mouseenter(function() {
        var child = $(this).find('ul');
        $(this).css({'background': '#404040'});
    //	$(this).children().css({'background': 'white', 'color': '#e11ab0'});
        child.css({'display': 'block', 'visibility': 'visible'});
    });
    $('.navbar_item').mouseleave(function() {
        var child = $(this).find('ul');
        $(this).css({'background': 'transparent'});
    //	$(this).children().css({'background': 'transparent', 'color': 'white'});
        child.css({'display': 'none', 'visibility': 'hidden'});
    }); // }}}
    // Sidebar box multi tab: most viewed {{{
    $('.viewed_timenavi_link').click(function() {
        var id = '#' + $(this).attr('id').replace('_link', '');

        $('.most_viewed_list').css('display', 'none');
        $(id).css('display', 'block');
        
        $('.viewed_timenavi_link').css('color', '#777777');
        $(this).css('color', '#e11ab0');
        
        return false;
    }); // }}}
    // Sidebar box multi tab: most commented {{{
    $('.commented_timenavi_link').click(function() {
        var id = '#' + $(this).attr('id').replace('_link', '');

        $('.most_commented_list').css('display', 'none');
        $(id).css('display', 'block');
        
        $('.commented_timenavi_link').css('color', '#777777');
        $(this).css('color', '#e11ab0');
        
        return false;
    }); // }}}
    // Sidebar box multi tab: latest news {{{
    $('.latest_timenavi_link').click(function() {
        var id = '#' + $(this).attr('id').replace('_link', '');

        $('.latest_list').css('display', 'none');
        $(id).css('display', 'block');
        
        $('.latest_timenavi_link').css('color', '#777777');
        $(this).css('color', '#e11ab0');
        
        return false;
    }); // }}}
    // Sidebar box multi tab: lyrics most viewed {{{
    $('.lyrics_timenavi_link').click(function() {
        var id = '#' + $(this).attr('id').replace('_link', '');

        $('.lyrics_most_viewed_list').css('display', 'none');
        $(id).css('display', 'block');
        
        $('.lyrics_timenavi_link').css('color', '#777777');
        $(this).css('color', '#e11ab0');
        
        return false;
    }); // }}}
    // Headlines AJAX pagination {{{
    var page = 1;
    var here = window.location;
    var host = here.hostname;
    var protocol = here.protocol;
    var ajax_link = protocol + '//' + host + '/ajax-headlines/?theme=rnb2011&page=';
    $('.headlines_prev').click(function() {
        if ( $(this).hasClass('headlines_bottom') )
            var scroll = true;
        
        if ( page == 1 )
            return false;
        page -= 1;
        $.ajax({
            async: false,
            url: ajax_link + page,
            success: function(data) {
                $('#headlines_container').html(data);
                if ( page == 1 )
                    $('.headlines_prev').css('display', 'none');
                if ( scroll )
                    $(document.window).scrollTop(510);
            }
        });
        return false;
    });
    $('.headlines_next').click(function() {
        if ( $(this).hasClass('headlines_bottom') )
            var scroll = true;
        
        page += 1;
        $.ajax({
            async: false,
            url: ajax_link + page,
            success: function(data) {
                $('#headlines_container').html(data);
                if ( page == 2 )
                    $('.headlines_prev').css('display', 'inline');
                if ( scroll )
                    $(document.window).scrollTop(510);
            }
        });
        return false;
    });
    // }}}
    $('#comments_guest').click(function() {
        $('.comment-form-fields, .comment-notes').css('display', 'block');
        $('#comment, #submit').removeAttr('disabled');

        return true;
    });
    $('.fb_button').live('click', function() {
        $('#comment, #submit').removeAttr('disabled');

        return false;
    });
    $('#post_content embed').attr('wmode', 'transparent');

});
// vim: set foldmethod=marker :

