//alibahsisoglu.com.tr
$(document).ready(function() {

    $(".alt").show();
    $(".alt .pagi a:first").addClass("aktif");
    $id = $(".slides a[rel = 1 ]").attr("title");
    $('.alt .desc').html($id);
    var imageWidth = $(".window").width();
    var imageSum = $(".slides img").size();
    var imageReelWidth = imageWidth * imageSum;
   
    $(".slides").css({'width' : imageReelWidth});
    
    rotate = function(){
        var triggerID = $active.attr("rel") - 1;
        var image_reelPosition = triggerID * imageWidth;
        var $relid = $active.attr("rel");
        var desc = $(".slides a[rel = " + $relid +" ]").attr("title");
        $('.alt .desc').html(desc);
        $(".alt .pagi a").removeClass('aktif');
        $active.addClass('aktif');
        $(".slides").animate({
            left: -image_reelPosition
        }, 500 );
    };
    
    rotateSwitch = function(){
        play = setInterval(function(){ 
            $active = $('.alt .pagi a.aktif').next();
            if ( $active.length === 0) {
                $active = $('.alt .pagi a:first');
            }
            rotate();
        }, 7000);
    }; 
    rotateSwitch();
    
    $(".slides a").hover(function() {
        clearInterval(play);
    }, function() {
        rotateSwitch();
    });	
    
    $(".alt .pagi a").click(function() {
        $active = $(this);
        clearInterval(play);
        rotate();
        rotateSwitch();
        return false;
    });
});
