var _cycleTimer;

function cycleEyecatcher() {
    var current = $("#eyecatcher > div:visible:first");
    var next = $("#eyecatcher > div:visible:first").next("div");
    
    if(next.length == 0) {
        next = $("#eyecatcher > div:first");
    }
    current.fadeTo('slow', 0, function() { $(this).hide(); });
    next.show().css('opacity', '0').fadeTo('slow', 1, function() {});
    _cycleTimer = window.setTimeout("cycleEyecatcher()", 5*1000);
}

function cycleTo(ident) {
    clearTimeout(_cycleTimer);
    $("#eyecatcher > div").stop().fadeTo('slow', 0, function() { $(this).hide(); });
    $("#eyecatcher > div."+ident).stop().show().css('opacity', '0').fadeTo('slow', 1, function() {});
    _cycleTimer = window.setTimeout("cycleEyecatcher()", 5*1000);
}

$(document).ready(function() {
    _cycleTimer = window.setTimeout("cycleEyecatcher()", 5*1000);
    
    $("#eyecatcher .vyber .ec1switch").click(function() {
        cycleTo("ec1");
        return false;
    });
     $("#eyecatcher .vyber .ec2switch").click(function() {
        cycleTo("ec2");
        return false;
    });
     $("#eyecatcher .vyber .ec3switch").click(function() {
        cycleTo("ec3");
        return false;
    });
});
