/*
 * Feature Carousel Script for Fireandflavor.com front page 
 */
 
var i = 0;
var j = 0;
var k = 0;

var countera = 1;
var counterb = 1;
var counterc = 1;


function buttons() {
        $(".button1").animate({marginTop: "-10px"}, 500).animate({marginTop: "-10px"}, 4000).animate({marginTop: "0px"}, 500);
        $(".button2").animate({marginTop: "0px"}, 5000).animate({marginTop: "-10px"}, 500).animate({marginTop: "-10px"}, 4000).animate({marginTop: "0px"}, 500);
        $(".button3").animate({marginTop: "0px"}, 10000).animate({marginTop: "-10px"}, 500).animate({marginTop: "-10px"}, 4000).animate({marginTop: "0px"}, 500);
        i = i + 1;
		if (i > (1)) {i = 0; counterc = counterc + 1;}
		if (counterc > 1) {clearInterval(showtime3);}
}
function slideSwitch() {

    var $active = $('.imgs img.active');
    if ( $active.length == 0 ) $active = $('.imgs img:last');
    var $next =  $active.next().length ? $active.next()
        : $('.imgs img:first');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
        j = j + 1;
		if (j > (2)) {j = 0; countera = countera + 1;}
		if (countera > 2) {
		$(".button1").animate({marginTop: "-10px"}, 500);
		clearInterval(showtime1);
		}

}

function slideSwitch2() {
    var $active = $('.imglinks li.active');
    if ( $active.length == 0 ) $active = $('.imglinks li:last');
    var $next =  $active.next().length ? $active.next()
        : $('.imglinks li:first');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
        k = k + 1;
		if (k > (2)) {k = 0; counterb = counterb + 1;}
		if (counterb > 2) {clearInterval(showtime2);}

}

function holla(){

	setTimeout("buttons()", 0);
    showtime1 = setInterval( "slideSwitch()", 5000 );
    showtime2 = setInterval( "slideSwitch2()", 5000 );
    showtime3 = setInterval("buttons()", 15000);
}
holla();

