﻿var x = 0;
var max = 0;
var holderWidth = 0;
var timeoutId = 0;
$(document).ready(function() {
    max = $('#imgslide').children().length;
    holderWidth = $('#imgslide').width();
    $('#imgslide').width(max * holderWidth);
    $('#imgslide').css('left', '0px');
    updateLinks(0);
    $('a#next').click(function() {
        var pos = parseInt($(this).attr('class'));
        if (pos < max) {
            $('#imgslide').animate({
                left: -((pos + 1) * holderWidth) + "px"
            }, 800);
            updateLinks(pos + 1);
        }
        this.blur();
        return false;
    });
    $('a#prev').click(function() {
        var pos = parseInt($(this).attr('class'));
        if (pos < max) {
            $('#imgslide').animate({
                left: -((pos - 1) * holderWidth) + "px"
            }, 800);
            updateLinks(pos - 1);
        }
        this.blur();
        return false;
    });
});

function updateLinks(pos) {
    $('a#next').attr('class', pos);
    $('a#prev').attr('class', pos);
    if (pos == 0)
        $('a#prev').hide();
    else
        $('a#prev').show();

    if (pos == max - 1)
        $('a#next').hide();
    else
        $('a#next').show();
}

/*var x = 0;
var max = 0;
var holderWidth = 0;
var timeoutId = 0;
$(document).ready(function() {
    holderWidth = $('#FB_UserHolder').width();
    var cnt = 0;
    $('#FB_ContentHolder').html(content);
    $('#FB_ContentHolder .Users').each(function(i) {
        cnt++;
    });
    max = cnt;
    $('#FB_ContentHolder').width(cnt * holderWidth);
    updateLinks(0);
    $('a#next').click(function() {
        var pos = parseInt($(this).attr('class'));
        if (pos < max) {
            $('#FB_ContentHolder').animate({
                left: -((pos + 1) * holderWidth) + "px"
            }, 800);
            updateLinks(pos + 1);
        }
        this.blur();
        return false;
    });
    $('a#prev').click(function() {
        var pos = parseInt($(this).attr('class'));
        if (pos < max) {
            $('#FB_ContentHolder').animate({
                left: -((pos - 1) * holderWidth) + "px"
            }, 800);
            updateLinks(pos - 1);
        }
        this.blur();
        return false;
    });
});

function updateLinks(pos) {
    $('a#next').attr('class', pos);
    $('a#prev').attr('class', pos);
    if (pos == 0)
        $('a#prev').hide();
    else
        $('a#prev').show();

    if (pos == max - 1)
        $('a#next').hide();
    else
        $('a#next').show();
}
*/
