﻿    var looking = "STILL LOOKING FOR";
    var well = "WELL...";
    var count = 0;

    $(document).ready(function () {

        count = 0;
        if ($('#cloud').is(':visible') || $('#news').is(':visible'))
            setTimeout("animateLooking()", 150);
        else
            animateMobile();
    });
    function animateLooking() {
        if (count < looking.length) {

            if ($.browser.msie && $.browser.version < 8) {
                
                $('#looking').hide();
                $('#looking').html(looking);
                $('#looking').fadeIn(function () {
                    animateW();
                });
            }
            else {
                $('#looking').append(looking[count]);
                count++;
                setTimeout("animateLooking()", 150);
            }
        }
        else {
            animateW();
        }
    }

    function animateW() {
    $('#block_w').show();
    $('#block_w').animate({
    width: 132,
    height: 140,
    marginTop: 60,
    marginLeft: 63
    }, 1000, function () {
    animateM();
    });
}
function animateW2() {
$('#block_w').animate({
width: 42,
height: 45
}, 1000, function () {
$('#more_w').fadeIn();
});
}

function animateM() {
$('#block_m').show();
$('#block_m').animate({
width: 132,
height: 140,
marginTop: 60,
marginLeft: 197
}, 1000, function () {
animateD();
});
}
function animateM2() {
$('#block_m').animate({
width: 42,
height: 45,
marginTop: 107
}, 1000, function () {
animateM3();
});
}
function animateM3() {
$('#block_m').animate({
marginLeft: 63
}, 200, function () {
$('#more_m').fadeIn();
});
}

function animateD() {
$('#block_d').show();
$('#block_d').animate({
width: 132,
height: 140,
marginTop: 60,
marginLeft: 331
}, 1000, function () {
animateS();
});
}
function animateD2() {
$('#block_d').animate({
width: 42,
height: 45,
marginTop: 154
}, 1000, function () {
$('#well').fadeOut();
animateD3();
});
}
function animateD3() {
$('#block_d').animate({
marginLeft: 63
}, 300, function () {
$('#more_d').fadeIn(function() {       
setTimeout("animateComplete()", 1000);
});
});
}

function animateS() {
$('#block_s').fadeIn(function () {
setTimeout("animateQ()", 800);
});
}

function animateQ() {
$('#question').show();
count = 0;
setTimeout("animateWell()", 500);
}

function animateWell() {
if (count < looking.length) {
$('#well').append(well[count]);
count++;
setTimeout("animateWell()", 150);
}
else {
    $('#found').fadeIn();
    $('#well').html(well);
            
setTimeout("animateBlocks()", 3000);
}
}

function animateBlocks()
{
animateW2();
animateM2();
animateD2();
$('#block_s, #question, #looking, #well, #found').fadeOut();
}

function animateComplete()
{
$('#block_w').animate({
marginTop: 45
}, 600);
$('#more_w').animate({
marginTop: 46
}, 600);
$('#block_d').animate({
marginTop: 169
}, 600);        
$('#more_d').animate({
marginTop: 170
}, 600);

}

function animateMobile() {

}
