﻿var curIdx = 0;
var intervalID = 0;

function hideAll() {
    var hideSpeed = "slow";
    $("#content_1").fadeOut(hideSpeed);
    $("#content_2").fadeOut(hideSpeed);
    $("#content_3").fadeOut(hideSpeed);
    $("#button_1").removeClass("on");
    $("#button_2").removeClass("on");
    $("#button_3").removeClass("on");
}

function showCurrent() {
    hideAll();
    $("#button_" + curIdx).addClass("on");
    $("#content_" + curIdx).fadeIn("slow");
}

function manualSelect(btn) {
    // If this button wasn't already "on", rotate the image
    clearInterval(intervalID);
    if (btn.className.indexOf(" on") == -1) {
        curIdx = btn.id.split("_")[1];
        showCurrent();
    }
}

function autoSelect() {
    curIdx = (curIdx % 3) + 1;
    showCurrent();
}

$(document).ready(function() {
    autoSelect();
    intervalID = setInterval("autoSelect()", 6000); // New image every 6 seconds

	$(".fullCarousel").pngfix();
$(".halfCarousel").pngfix();
});