/*LiveServer: */
$(window).scroll(function(eventData) {
    if($(window).scrollTop() > ($(document).height() - $(window).height() - 100)) {
        if(!footer_bus_animating)
        animateFooterBus();     
    }
    });
var footer_bus_animating = false;
function jumping_bird_animation(){
    var step = 60;
    
    XMLTweets('tweets_temp', '/us/xml/tweets_config.xml');
    
    setTimeout(function() {
        $('#tweets .bird-1').jani({ frameWidth: 107, frameHeight: 60, speed: 80, totalFrames: 10, loop: false});    
        $('#tweets .bird-1').jani("play", false, function() {
            var right = parseInt($('#tweets .bird-1').css('right').split('px')[0]);
            $('#tweets .bird-1').css({'right':right+step+'px'});
            $('#tweets .bird-1').jani('reset');
            $('#tweets .bird-1').jani("play", false, function() {
                //var right = parseInt($('#tweets .bird-1').css('right').split('px')[0]);
                //$('#tweets .bird-1').css({'right':right+step+'px'});
                //$('#tweets .bird-1').jani('reset');
                //$('#tweets .bird-1').jani("play", false, function() {
                $('#tweets #tweets_container').animate({'top':'0px'}, 300, 'linear');
                $('#tweets .bird-1').css({'background':'url(/static/images/Structural-images/hoppingBird_final2.png) 0 0 no-repeat'});
                $('#tweets .bird-1').jani('reset');
                setTimeout(function() {
                    $('#tweets .bird-1').jani("play", false, function() {
                        var right = parseInt($('#tweets .bird-1').css('right').split('px')[0]);
                        $('#tweets .bird-1').css({'right':right-step+'px'});
                        $('#tweets .bird-1').jani('reset');
                        $('#tweets .bird-1').jani("play", false, function() {
                            var right = parseInt($('#tweets .bird-1').css('right').split('px')[0]);
                            $('#tweets .bird-1').css({'right':right-step+'px'});
                            $('#tweets .bird-1').jani('reset');
                            $('#tweets .bird-1').jani("play", false, function() {
                            });
                        });
                    });
                }, 500);
            });
        });
    }, 2000);
}

function small_bus_animation(){
    var wait_time = 3000;
    var first_move = 119;
    var move = 550;

    $('#bus_small .animation-1').jani('reset');
    $('#bus_small .animation-2').jani('reset');
    $('#bus_small .animation-3').jani('reset');
    
    $('#bus_small .animation-1').stop().show();
    $('#bus_small .animation-2').stop().hide();
    $('#bus_small .animation-3').stop().hide();
    
    $('#bus_small .animation-1').css({right: 0});
    $('#bus_small .animation-1').jani({ frameWidth: 94, frameHeight: 57, speed: 100, totalFrames: 20, loop: false});
    $('#bus_small .animation-1').jani("play", false, function() { 
        $('#bus_small .animation-1').animate({right: (first_move+131)+'px'}, (first_move+119)*6, 'linear', function() {
            $('#bus_small .animation-1').hide();
        $('#bus_small .animation-2').show();
            $('#bus_small .animation-2').css({'right': (first_move)+'px'});
            $('#bus_small .animation-2').animate({right: move+'px'}, move*6, 'linear', function() {
        $('#bus_small .animation-2').jani('stop');
        $('#bus_small .animation-2').hide();
        $('#bus_small .animation-3').show();
        $('#bus_small .animation-3').jani({ frameWidth: 240, frameHeight: 57, speed: 60, totalFrames: 16, loop: false});
        $('#bus_small .animation-3').jani('play');
            });
            $('#bus_small .animation-2').jani({ frameWidth: 225, frameHeight: 57, speed: 100, totalFrames: 4, loop: false});
            $('#bus_small .animation-2').jani('play', false, function() {
        $('#bus_small .animation-2').css({'background': 'url(/static/images/Structural-images/bus_flag_still2.png) no-repeat left top'});
        $('#bus_small .animation-2').jani({ frameWidth: 225, frameHeight: 57, speed: 100, totalFrames: 7});
        $('#bus_small .animation-2').jani('play', false, function() {} );
            });
        });
    });
}
function animateFooterBus() {
    footer_bus_animating = true;
    var wait_time = 3000;
    var first_move = 200;
    var second_move = 600;
    $('#bus .animation-1').jani('reset');
    $('#bus .animation-1').show();
    $('#bus .animation-1').css({'right':'0px'});
    $('#bus .animation-1').jani({ frameWidth: 156, frameHeight: 95, speed: 100, totalFrames: 20, loop: false});
    $('#bus .animation-1').jani("play", false, function() { 
    $('#bus .animation-2').jani('reset');
    $('#bus .animation-2').css({'background': 'url(/static/images/Structural-images/bus_flag_start.png) no-repeat left top', 'right':'0px'});
    $('#bus .animation-3').jani('reset');    
    $('#bus .animation-3').hide();    
        $('#bus .animation-1').animate({right: (first_move + 219)+'px'}, (first_move)*6, 'linear', function() {
            $('#bus .animation-2').show();
            $('#bus .animation-2').css({'right': first_move+'px'});
            $('#bus .animation-2').jani({ frameWidth: 375, frameHeight: 95, speed: 100, totalFrames: 4, loop: false});
                $('#bus .animation-1').hide();                                    
                $('#bus .animation-2').jani('play', false, function() {
                    $('#bus .animation-2').css({'background': 'url(/static/images/Structural-images/bus_flag_still.png) no-repeat left top'});
                    $('#bus .animation-2').jani({ frameWidth: 375, frameHeight: 95, speed: 100, totalFrames: 7});
                    $('#bus .animation-2').jani('play', false, function() {} );
                    setTimeout(function() {
                        $('#bus .animation-2').animate({right:second_move+'px'}, (second_move-first_move)*4, 'linear', function() {
                            $('#bus .animation-2').jani('stop');
                            $('#bus .animation-2').hide();
                            $('#bus .animation-3').css({'right': second_move+'px'});
                            $('#bus .animation-3').show();
                            $('#bus .animation-3').jani({ frameWidth: 400, frameHeight: 95, speed: 60, totalFrames: 16, loop: false});
                            $('#bus .animation-3').jani('play', false, function() {
                                footer_bus_animating = false;
                                });
                            });
                        }, wait_time);
                    });
        });
    });
}
function footer_building_animation(){
    $('#flash_footer_building').jani({ frameWidth: 87, frameHeight: 178, speed: 150, totalFrames: 15, loop: true});
    $('#flash_footer_building').jani("play", false, function() {});
}
function XMLTweets(tweetsContainer, XMLurl){
    sContainer = tweetsContainer;
    
    $('#' + tweetsContainer).jParse({
        parentElement: 'tweet',
        ajaxOpts: {url: XMLurl},
        elementTag: [''],
        output: '<div class="tweet">jpet00</div>',
        count: '#tweets_counter',
        callback: function() { XMLTweetsParseAgain('tweets_container', XMLurl); }
        });
}
function XMLTweetsParseAgain(container, XMLurl) {
    sContainer = container;
    container.innerHTML = '';
 
    var count = parseInt($('#tweets_counter').html());
    var rand = Math.floor(Math.random()*count);
    $('#' + container).jParse({
        parentElement: 'tweets',
        ajaxOpts: {url: XMLurl},
        elementTag: [{elem:'tweet', select:rand}],
        output: '<div class="tweet">jpet00</div>'
    });    
}

/** <HTML><HEAD><!-- PageID 2032 - published by Open Text Web Solutions 10 - 10.0.1.64 - 26863 --><title></title></HEAD><BODY></BODY></HTML> **/

