﻿var maxLeftValueForDivFlyingBalloon = 200, maxTopValueForDivFlyingBalloon = 400;
function moveDivFlyingBalloon(xPosition, yPosition)
{
    new Effect.Move(
                        'divFlyingBalloon',
                        {
                            x: xPosition,
                            y: yPosition,
                            mode: 'absolute',
                            duration: 3.0,
                            afterFinish: function()
                            {
                                xPosition = Math.floor(Math.random() * maxLeftValueForDivFlyingBalloon) + getScrollCoordinatesX();
                                yPosition = Math.floor(Math.random() * maxTopValueForDivFlyingBalloon) + getScrollCoordinatesY();
                                
                                moveDivFlyingBalloon(xPosition, yPosition);
                            }
                        }
                    );
}

addLoadEvent(
                function()
                {
                    new Effect.Parallel(
                    [
                        new Effect.Move(
                                            'divBGHomePage',
                                            {
                                                x: getLeftSpaceForCentering('divBGHomePage'),
                                                y: getTopSpaceForCentering('divBGHomePage'),
                                                mode: 'absolute',
                                                sync: true,
                                                afterFinish: function(effect)
                                                {
                                                    new Effect.Move(
                                                                        'divFlyingBalloon',
                                                                        {
                                                                            x: effect.options['x'] + 30,
                                                                            y: effect.options['y'] + 30,
                                                                            mode: 'absolute',
                                                                            afterFinish: function()
                                                                            {
                                                                                var randomXPosition = Math.floor(Math.random() * (getClientWidthValue() - 200)) + getScrollCoordinatesX();
                                                                                var randomYPosition = Math.floor(Math.random() * (getClientHeightValue() - 300)) + getScrollCoordinatesY();

                                                                                setTimeout("moveDivFlyingBalloon(" + randomXPosition + ", " + randomYPosition + ");", 2000);
                                                                            }
                                                                        }
                                                                    );
                                                }
                                            }
                                        ),
                        new Effect.Move(
                                            'divBlastLogoLink',
                                            {
                                                x: getLeftSpaceForCentering('divBGHomePage'),
                                                y: getTopSpaceForCentering('divBGHomePage'),
                                                mode: 'relative',
                                                sync: true
                                            }
                                        ),
                        new Effect.Move(
                                            'divKampanyaSonu',
                                            {
                                                x: getLeftSpaceForCentering('divBGHomePage'),
                                                y: getTopSpaceForCentering('divBGHomePage'),
                                                mode: 'relative',
                                                sync: true
                                            }
                                        )
                    ]);

                    window.onresize = function()
                    {
                        new Effect.Parallel(
                        [
                            new Effect.Move(
                                                'divBGHomePage',
                                                {
                                                    x: getLeftSpaceForCentering('divBGHomePage'),
                                                    y: getTopSpaceForCentering('divBGHomePage'),
                                                    mode: 'absolute',
                                                    sync: true
                                                }
                                            ),
                            new Effect.Move(
                                                'divBlastLogoLink',
                                                {
                                                    x: getLeftSpaceForCentering('divBGHomePage') - getElementActualLeft('divBGHomePage'),
                                                    y: getTopSpaceForCentering('divBGHomePage') - getElementActualTop('divBGHomePage'),
                                                    mode: 'relative',
                                                    sync: true
                                                }
                                            ),
                            new Effect.Move(
                                                'divKampanyaSonu',
                                                {
                                                    x: getLeftSpaceForCentering('divBGHomePage') - getElementActualLeft('divBGHomePage'),
                                                    y: getTopSpaceForCentering('divBGHomePage') - getElementActualTop('divBGHomePage'),
                                                    mode: 'relative',
                                                    sync: true
                                                }
                                            )
                        ]);
                    };
                }
            );