﻿$(document).ready(function () {
    function centercontent() {
        var windowheight = $(window).height();
        var offset = Math.round((windowheight - 572) / 2 - 30);
        $('#landing').css('top', offset + 'px');
    };

    centercontent();

    $(window).resize(function () {
        centercontent();
    });

    var numberOfObjects = 11;
    var count = 1;
    var startPos_a = -71;
    var startPos_b = -30;
    var offset = 288;


    function animateObjects() {

        var shift_a = startPos_a - (offset * count);
        var shift_b = startPos_b - (offset * count);
        var a = shift_a + "px" + " " + "0px";
        var b = shift_b + "px" + " " + "0px";

        $('#objects').animate({
            backgroundPosition: a
        }, 400, function () {
            if (count >= numberOfObjects - 1) {
                $('#objects').css('background-position', '-71px 0');
            } else {

            }
        });

        $('#objects_bubble').animate({
            backgroundPosition: b
        }, 400, function () {
            if (count >= numberOfObjects - 1) {
                count = 1;
                $('#objects_bubble').css('background-position', '-30px 0');
            } else {
                count++
            }
        });

        //alert(a);
    };

    var int = setInterval(animateObjects, 2000);

    $('#landing').click(function () {
        //alert("hello");
        $('#message').fadeToggle("fast");
    });
});
