$(document).ready(function(){

    var $ul = $('#nav ul > li');
    var el = $ul.eq($ul.length-1);
    $(el).addClass('no-bg');

    $('#tab1').addClass('active');

    $('#tab1').click(function(){
        $('#tab1-content').fadeIn('slow');
        $('#tab2-content').fadeOut('slow');
        $('#tab1').addClass('active');
        $('#tab2').removeClass('active');
        $('#tab1-content').removeClass('hidden');
        $('#tab2-content').addClass('hidden');
        return false;
    })
    $('#tab2').click(function(){
        $('#tab2-content').fadeIn('slow');
        $('#tab1-content').fadeOut('slow');
        $('#tab1').removeClass('active');
        $('#tab1-content').addClass('hidden');
        $('#tab2-content').removeClass('hidden');
        $('#tab2').addClass('active');
        return false;
    })


    $('#slideshow').cycle({
        fx:     'fade',
        speed:  1500,
        timeout: 0,
        pager:  '#nav',
        pagerAnchorBuilder: function(idx, slide) {
            // return selector string for existing anchor
            return '#nav li:eq(' + idx + ') a';
        }
    });

    $('.post-count').click(function(){
        var count_id = $(this).parent().attr('id');
        var count_p = $('#count-'+count_id);
        var post_id = $('#post_id_'+count_id).val();
        var url = $('#url-'+count_id).val();
        $.ajax({
            type: "POST",
            url: ""+url+"",
            data: "post_id="+post_id,
            success: function(data){
                $(count_p).text(data);
                //window.location = rurl;
            },
            error:function (xhr, ajaxOptions, thrownError){
                    alert(xhr.status);
                    alert(thrownError);
            }
        });
        return false;
    })
    $('#post-count').click(function(){        
        var post_id2 = $('#post_id').val();
        var count = $('#count');
        var url2 = $('#url').val();        
        $.ajax({
            type: "POST",
            url: ""+url2+"",
            data: "post_id="+post_id2,
            success: function(data) {
                $(count).text(data);
                //window.location = rurl2;
            },
            error:function (xhr, ajaxOptions, thrownError){
                    alert(xhr.status);
                    alert(thrownError);
            }
        });
        return false;
    })

})
