﻿var HomeAnim = function() {

    $("#text1-home-slide1").hide();
    $("#text1-home-slide2").hide();

    var slide2 = function() {
        var handIn = function() {
            $("#hand-home-slide2").animate({ "margin-top": "0px" }, 1500,
                function() {
                    $("#text1-home-slide2").fadeIn(700,
                function() { $("#text1-home-slide2").delay(3000).fadeOut(700, handOut); })
                });
            $("#hand-home-slide2").rotate({ angle: 190, animateTo: 0, duration: 2000 });
        }

        var handOut = function() {
            $("#hand-home-slide2").animate({ "margin-top": "600px" }, 1000, slide1);
            $("#hand-home-slide2").delay(300).rotate({ angle: 0, animateTo: 90, duration: 3000 });
            $("#phone1-home-slide1").css("margin-left", "600px");
        }
        handIn();
    }

    var slide1 = function() {
        var textIn = function() {
            $("#text1-home-slide1").fadeIn(700, function() { $("#text1-home-slide1").delay(3000).fadeOut(700, phoneOut); });
        }

        $("#phone1-home-slide1").animate({ "margin-top": "30px", "margin-left": "0px" }, 3000, textIn);
        $("#phone1-home-slide1").rotate({ angle: -270, animateTo: 0, duration: 3600 });

        var phoneOut = function() {
            $("#phone1-home-slide1").animate({ "margin-top": "-600px", "margin-left": "-400px" }, 1500, slide2);
            $("#phone1-home-slide1").delay(300).rotate({ angle: 0, animateTo: -100, duration: 3000 });
        }
    }

    slide1();

}
