// based on http://visitmix.com/labs/glimmer/samples/sequence.html

jQuery(function ($) {
    var timer;
    function button1_click(event) {
        $(".slide").css("visibility", "hidden");
        $("#image1").css("visibility", "visible");
        $("#image1").css("opacity", "0");
        $("#image1").animate({
            "opacity": 1
        },
        300, "linear", null);
        clearTimeout(timer);
        timer = setTimeout(eval("button2_click"), "5000");
        $("#image1").animate({
            "opacity": 1
        },
        300, "linear", null);
    }

    function button2_click(event) {
        $(".slide").css("visibility", "hidden");
        $("#image2").css("visibility", "visible");
        $("#image2").css("opacity", "0");
        $("#image2").animate({
            "opacity": 1
        },
        300, "linear", null);
        clearTimeout(timer);
        timer = setTimeout(eval("button1_click"), "5000");
        $("#image2").animate({
            "opacity": 1
        },
        300, "linear", null);
    }


    function OnLoad(event) {
        clearTimeout(timer);
        timer = setTimeout(eval("button2_click"), "5000");
    }

    $('#button1').bind('click', button1_click);

    $('#button2').bind('click', button2_click);


    OnLoad();

});