$(document).ready(function() {
    $(".slide_count").show();
    $(".slide_count a:first").addClass("active");
    var image_width = $(".width").width();
    var imageSum = $(".slides img").size();
    var slideWidth = image_width * imageSum;
    $(".slides").css({
        'width' : slideWidth
    });
    rotate = function(){
        var get_count = $active.attr("rel") - 1;
        var slide_position = get_count * image_width;
        $(".slide_count a").removeClass('active');
        $active.addClass('active');
        $(".slides").animate({
            left: - slide_position
        }, 500 );
    };
    rotateSwitch = function(){
        play = setInterval(function(){
            $active = $('.slide_count a.active').next();
            if ( $active.length === 0) {
                $active = $('.slide_count a:first');
            }
            rotate();
        }, 7000);
    };
    rotateSwitch();
    $(".slides a").hover(function() {
        clearInterval(play);
    }, function() {
        rotateSwitch();
    });
    $(".slide_count a").click(function() {
        $active = $(this);
        clearInterval(play);
        rotate();
        rotateSwitch();
        return false;
    });
	
});
