﻿var handshakeInterval;
var handshakeDir = false;

var moneyInterval;
var moneyDir = true;

var auraInterval;
var auraDir = true;

function shakehands() {
    if (handshakeDir) {
        $('#handshake').animate({ bottom: 0 }, 3500, 'easeOutCubic');
    } else {
        $('#handshake').animate({ bottom: -25 }, 3500, 'easeOutCubic');
    }

    handshakeDir = !handshakeDir;
}

function moneyOpacity() {
    if (moneyDir) {
        $('#money').fadeTo(3000, .60);
    } else {
        $('#money').fadeTo(3000, 1.00);
    }

    moneyDir = !moneyDir;
}

function auraOpacity() {
    if (auraDir) {
        $('#aura').fadeTo(1900, .30);
    } else {
        $('#aura').fadeTo(1900, 1.00);
    }

    auraDir = !auraDir;
}

$(document).ready(function () {
    $('#column1').animate({ top: 0 }, 1500, function () {
        $('#handshake').show().animate({ bottom: 0 }, 2500, 'easeOutBounce', function () { shakehands(); handshakeInterval = setInterval(shakehands, 3600); });
        $('#businessman').show().delay(1200).animate({ bottom: 0 }, 300);
        $('#money').show().delay(800).animate({ top: 0, right: 0 }, 1500, 'easeOutCubic', function () {
            moneyOpacity(); moneyInterval = setInterval(moneyOpacity, 3200);

            $('#column1').hover(function () {
                $('#column1 .columnInner').animate({ top: -170 }, 400, 'easeOutCubic');
                clearInterval(moneyInterval);
                $('#money').stop().animate({ top: -100 }, 200);

            }, function () {
                $('.columnInner').animate({ top: 0 }, 400, 'easeOutCubic');
                $('#money').stop().animate({ top: 0 }, 2200, 'easeOutBounce', function () { moneyOpacity(); moneyInterval = setInterval(moneyOpacity, 3200); });
            });
        });
    });
    $('#column2').delay(2000).animate({ top: 0 }, 1500, function () {
        $('#bionicman').show().animate({ bottom: 27 }, 3000, 'easeOutCubic');
        $('#aura').show().delay(3000).css({ 'opacity': '0.0' }).animate({ bottom: 10, opacity: 1 }, 1200, 'easeOutCubic', function () { auraOpacity(); auraInterval = setInterval(auraOpacity, 2000); });
        $('#orb1').show().delay(4000).animate({ bottom: '+= 50', opacity: 1 }, 1200, 'easeOutCubic');
        $('#orb2').show().delay(4200).animate({ bottom: '+= 50', opacity: 1 }, 1200, 'easeOutCubic');
        $('#orb3').show().delay(4400).animate({ bottom: '+= 50', opacity: 1 }, 1200, 'easeOutCubic');

        $('#column2').hover(function () {
            $('#column2 .columnInner').animate({ top: -170 }, 400, 'easeOutCubic');
        }, function () {
            $('.columnInner').animate({ top: 0 }, 400, 'easeOutCubic');
        });
    });


    $('#column3').delay(5000).animate({ top: 0 }, 1500, function () {
        $('#profile').show().animate({ left: 0 }, 2000);
        $('#closeddome').show().animate({ left: 0 }, 2000, function () {
            $('#shock').show();
            $('#closeddome').hide();
            $('#opendome').show();
        });

        //$('#spectrum').delay(2800).show().animate({ width: 390 }, 500, 'easeOutCubic');
        $('#greymatter').delay(2200).show().animate({ width: 390 }, 3500, 'easeOutCubic');

        $('#column3').hover(function () {
            $('#column3 .columnInner').animate({ top: -170 }, 400, 'easeOutCubic');
        }, function () {
            $('.columnInner').animate({ top: 0 }, 400, 'easeOutCubic');
        });

    });

});
