﻿var currentLB = 0;
var oldLB=null;
var newLB = null;
var lbInterval;

function setLBFwd(lb) {
    switch (lb) {
        case 0:
            {
                oldLB = $('.sd-lb-core');
                newLB = $('.sd-lb-mobile');
                currentLB = 1;
                break;
            }
        case 1:
            {
                oldLB = $('.sd-lb-mobile');
                newLB = $('.sd-lb-online');
                currentLB = 2;
                break;
            }
        case 2:
            {
                oldLB = $('.sd-lb-online');
                newLB = $('.sd-lb-web');
                currentLB = 3;
                break;
            }
        default:
            {
                oldLB = $('.sd-lb-web');
                newLB = $('.sd-lb-core');
                currentLB = 0;
                break;
            }
    }
    return false;
}
function setLBBck(lb) {
    switch (lb) {
        case 0:
            {
                oldLB = $('.sd-lb-core');
                newLB = $('.sd-lb-web');
                currentLB = 3;
                break;
            }
        case 1:
            {
                oldLB = $('.sd-lb-mobile');
                newLB = $('.sd-lb-core');
                currentLB = 0;
                break;
            }
        case 2:
            {
                oldLB = $('.sd-lb-online');
                newLB = $('.sd-lb-mobile');
                currentLB = 1;
                break;
            }
        case 3:
            {
                oldLB = $('.sd-lb-web');
                newLB = $('.sd-lb-online');
                currentLB = 2;
                break;
            }
    }
    return false;
}

function loadEvents() {
//    $('.pagePanels').empty();
//    $.get('/AjaxContent/panels.htm', function (data) {
//        $('.pagePanels').append($('#evaluation', data));
//        $('.pagePanels').append($('#shared-diaries', data));
//        $('.pagePanels').append($('#online-bookings', data));
//        $('.pagePanels').append($('#mobile-access', data));
//    });
    $('#slider').easySlider({
        auto: true,
        continuous: true,
        pause: 8000,
        nextText:'',
        prevText:''
    });
        
//    $('.sd-lb-next').bind('click', function () {
//        LBForward();
//        reStartTimer();
//    });

//    $('.sd-lb-back').bind('click', function () {
//        LBBack();
//        reStartTimer();
//    });
//    startTimer();
}
function reStartTimer() {
    clearInterval(lbInterval);
    setTimeout('startTimer();', 12000);
}
function startTimer() {
clearInterval(lbInterval);
lbInterval = setInterval('LBForward();', 4000);
}

function LBForward() {
setLBFwd(currentLB);
        oldLB.fadeOut('slow');
        newLB.fadeIn('slow');
}
function LBBack() {
    setLBBck(currentLB);
    oldLB.fadeOut('slow');
    newLB.fadeIn('slow');
}

