/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$(document).ready(function(){

    $('#logoback').css('background-color', $('.content:first').css('background-color'));
    
    $(window).scroll(function () {
        detectPosition();
    });
});

function detectPosition()
{
    var elements = [];
    var windowTop = parseInt($(window).scrollTop()) + 80;

    $.each($('.content'), function(i, val){
        var elementTop = $(this).offset().top;
        if (elementTop <= windowTop)
        {
            elements[i] = $(this).css('background-color');
        };
    });

    if(elements.length != 0)
    {
        elements.reverse();
        $('#logoback').stop().animate({backgroundColor: elements[0]}, 500);
    }
}