var visible = true;
var running = false;

function ecoflash() {
    running = true;
    if (visible) {
        $('#ecoflash').animate({
            opacity: 0.4,
            //filter: 'alpha(opacity=\'40\')',
            width: '-=6',
            left: '+=3',
            top: '+=3'
        }, 1000, function() {
            ecoflash();
        });
        visible = false;
    }
    else {
        $('#ecoflash').animate({
            opacity: 1,
            //filter: 'alpha(opacity=\'100\')',
            width: '+=6',
            left: '-=3',
            top: '-=3'
        }, 1000, function() {
            ecoflash();
        });
        visible = true;
    }
}
function ecoflashstop() {
    running = false;
    $('#ecoflash').stop();
    /*$('#ecoflash').css('opacity', 1)
                  .css('width', 158)
                  .css('height', 181)
                  .css('left', 480)
                  .css('top', 60);*/
    visible = true;
}

$(document).ready(function() {
    $('<img />')
    .attr('src', 'images/logo-ecoelle-lampeggio.png')
    .load(function(){
        ecoflash();
    });
    $('a.linkint').live('click', function() {
        var link = $(this).attr('href')+'?id=7';
        var aa = $(this);
        $.get(link, function(html) {
            $('#content').html(html);
            if (!running) ecoflash();
        });
        return false;
    });

    $('a.linkecoelle').live('click', function() {
        var link = $(this).attr('href');
        var aa = $(this);
        $.get(link, function(html) {
            $('#wrapper').append(html);
            //$('#box-ecoelle').slideDown();
            $('#box-ecoelle').fadeIn();
            ecoflashstop();
        });
        return false;
    });
    
    $('a.ecoellechiudi').live('click', function() {
        //$('#box-ecoelle').slideUp(function() {
        $('#box-ecoelle').fadeOut(function() {
            $(this).remove();
            if (!running) ecoflash();
        });
        return false;
    });
});

