﻿var currentIndex = 0;
var maxIndex = 3;

hideAllContent();
Move(0, 0);

function MoveForwards() {

    if (currentIndex == maxIndex) {
        var newIndex = 0;
    }
    else {
        var newIndex = currentIndex + 1;
    }
    Move(currentIndex, newIndex);
}

function MoveBackwards() {

    if (currentIndex == 0) {
        var newIndex = maxIndex;
    }
    else {
        var newIndex = currentIndex - 1;
    }
    Move(currentIndex, newIndex);
}

function Move(previousIndex, newIndex) {

    hideContent(previousIndex);
    showContent(newIndex);
    getTab(previousIndex).removeClass();
    getTab(newIndex).addClass('selected');

    var sash = $('div#sash');
    sash.removeClass();
    
    switch (newIndex) {
        case 0:
            sash.css('background-color', '#8dc63f');
            break;
        case 1:
            sash.css('background-color', '#fcb040');
            break;
        case 2:
            sash.css('background-color', '#f1592a');
            break;
        case 3:
            sash.css('background-color', '#bf1e2e');
            break;
        case 4:
            sash.css('background-color', '#662d91');
            break;
        case 5:
            sash.css('background-color', '#00aeef');
            break;
    }

    currentIndex = newIndex;
}


function getTab(index) {
    return $('ul#nav').children("li:eq(" + index + ")");
}

function getContent(index) {
    return $('div#sashParent').children("div:eq(" + index + ")");
}

function hideAllContent() {
    $('div#sashParent').children('.sashContent').hide();
    return false;
}

function showContent(index) {
    $('div#sashParent').children("div:eq(" + index + ")").show();
}

function hideContent(index) {
    $('div#sashParent').children("div:eq(" + index + ")").hide();
}
