﻿
function hideAll() {
    $('.content_2').hide();
    $('a.content_2_link_AboutMyView').hide();
    $('a.content_2_link_myviewsite').hide();
    $('a.content_2_link_JoinMyView').hide();
    $('a.content_0_link_cati').hide();
    $('a.content_0_link_panel').hide();
    $('a.content_0_link_face2face').hide();
    $('.content_0').hide();
    $('.content_1').hide();
    $('a.myview').css({ 'background-position': '-1px 0px' });
    $('a.iview').css({ 'background-position': '0px 0px' });
    $('a.social_research').css({ 'background-position': '0px 0px' });
}

function showTab_0() {
      

    //show stuff for this tab
    $('.content_0').fadeIn(1000);
    $('a.iview').css({ 'background-position': '0px -57px' });
    


    //Slide out the tabs

    $('a.content_0_link_cati').show('slide', { direction: 'right' }, 500);
    $('a.content_0_link_panel').oneTime("200ms", function () {
        $(this).show('slide', { direction: 'right' }, 500);
    });
    $('a.content_0_link_face2face').oneTime("400ms", function () {
        $(this).show('slide', { direction: 'right' }, 500);
    });
}

function showTab_1() {

    //Show stuff for this tab
    $('.content_1').fadeIn(1000);
    $('a.social_research').css({ 'background-position': '0px -57px' });
    

}

function showTab_2() {
    
    //Show stuff for this tab
    $('.content_2').fadeIn(1000);
    $('a.myview').css({ 'background-position': '-1px -57px' });
  

    //Slide out the tabs
    $('a.content_2_link_AboutMyView').show('slide', { direction: 'right' }, 500);
    $('a.content_2_link_myviewsite').oneTime("200ms", function () {
        $(this).show('slide', { direction: 'right' }, 500);
    });
    $('a.content_2_link_JoinMyView').oneTime("400ms", function () {
        $(this).show('slide', { direction: 'right' }, 500);
    });
    
}



$(function () {

    /*
    $('#banner_content').css({
    'height': '308px'
    });
    */
    $('#navbar_container').show();
    $('#navbar_content').show();
    var i = 0;
    var numberOfItemsToCycle = 3;



    $('a.myview').click(function () {
        hideAll();
        $(document).stopTime('controlled_main');
        showTab_2();
    });

    $('a.social_research').click(function () {
        hideAll();
        $(document).stopTime('controlled_main');
        showTab_1();
    });

    $('a.iview').click(function () {
        hideAll();
        $(document).stopTime('controlled_main');
        showTab_0();
    });



    // lets start off the page with the first screen
    showTab_0();


    $(document).everyTime("9s", 'controlled_main', function () {

        if (i == 100) {
            i = 0;
        }

        // .content_x refers to both the image and the left side text that follows
        if (i % numberOfItemsToCycle == 0) {

            hideAll();
            showTab_1();


        }
        else if (i % numberOfItemsToCycle == 1) {
            hideAll();
            showTab_2();



        }

        else if (i % numberOfItemsToCycle == 2) {
            hideAll();
            showTab_0();


        }

        i++;
    }, 0);


});

