$(document).ready(function () {

    /*--- Variables ---*/
    var delay = 9000;
    var timer;
    var ifEnded = 0;
    var ifStarted = 0;

    /*--- Animation Functions ---*/
    jQuery.fn.one = function () {
        clearTimeout(timer);
        $(".banner-main-image-two img").hide();
        $(".banner-main-image-three img").hide();
        $(".banner-main-image-four img").hide();
        $(".banner-main-image-one img").fadeIn('slow');
        $(".arrow-text-two").hide();
        $(".arrow-text-three").hide();
        $(".arrow-text-four").hide();
        $(".arrow-text-one").show('scale', { percent: '100', direction: 'right' }, 500);
        $(".thumb").eq(0).addClass('selected');
        $(".thumb").eq(1).removeClass('selected');
        $(".thumb").eq(2).removeClass('selected');
        $(".thumb").eq(3).removeClass('selected');
        if (ifEnded < 1) {
            timer = setTimeout(function () { $('.thumb').eq(1).click(); }, delay);
        }

        ifStarted++;
    };

    jQuery.fn.two = function () {
        clearTimeout(timer);
        $(".banner-main-image-one img").hide();
        $(".banner-main-image-three img").hide();
        $(".banner-main-image-four img").hide();
        $(".banner-main-image-two img").fadeIn('slow');
        $(".arrow-text-one").hide();
        $(".arrow-text-three").hide();
        $(".arrow-text-four").hide();
        $(".arrow-text-two").show('scale', { percent: '100', direction: 'right' }, 500);
        $(".thumb").eq(0).removeClass('selected');
        $(".thumb").eq(1).addClass('selected');
        $(".thumb").eq(2).removeClass('selected');
        $(".thumb").eq(3).removeClass('selected');
        if (ifEnded < 1)
            timer = setTimeout(function () { $('.thumb').eq(2).click(); }, delay);
    };

    jQuery.fn.three = function () {
        clearTimeout(timer);
        $(".banner-main-image-one img").hide();
        $(".banner-main-image-two img").hide();
        $(".banner-main-image-four img").hide();
        $(".banner-main-image-three img").fadeIn('slow');
        $(".arrow-text-one").hide();
        $(".arrow-text-two").hide();
        $(".arrow-text-four").hide();
        $(".arrow-text-three").show('scale', { percent: '100', direction: 'right' }, 500);
        $(".thumb").eq(0).removeClass('selected');
        $(".thumb").eq(1).removeClass('selected');
        $(".thumb").eq(3).removeClass('selected');
        $(".thumb").eq(2).addClass('selected');
        if (ifEnded < 1)
            timer = setTimeout(function () { $('.thumb').eq(3).click(); }, delay);
    };

    jQuery.fn.four = function () {
        clearTimeout(timer);
        $(".banner-main-image-one img").hide();
        $(".banner-main-image-two img").hide();
        $(".banner-main-image-three img").hide();
        $(".banner-main-image-four img").fadeIn('slow');
        $(".arrow-text-one").hide();
        $(".arrow-text-two").hide();
        $(".arrow-text-three").hide();
        $(".arrow-text-four").show('scale', { percent: '100', direction: 'right' }, 500);
        $(".thumb").eq(0).removeClass('selected');
        $(".thumb").eq(1).removeClass('selected');
        $(".thumb").eq(3).addClass('selected');
        $(".thumb").eq(2).removeClass('selected');
        if (ifEnded < 1)
            timer = setTimeout(function () { $('.thumb').eq(0).click(); }, delay);
        ifEnded++;
    };

    /*--- Action Functions ---*/
    $('.thumb').eq(0).click(function () { $(this).one(); });
    $('.thumb').eq(1).click(function () { $(this).two(); });
    $('.thumb').eq(2).click(function () { $(this).three(); });
    $('.thumb').eq(3).click(function () { $(this).four(); });

    /*--- Init ---*/
    $('.thumb').eq(0).click();


})
