﻿
var contentCount;
var imageArray = new Array();

function showContent(menu, index)
{
    for (var i = 0; i <= contentCount; i++)
    {
        $("#div" + i).hide();
    }

    $("#div" + index).show();
    $(menu).siblings().attr("class", "sideMenu");
    $(menu).attr("class", "sideMenuSelected");
}

function showImage(index)
{
    $("#img1").attr("src", "Images/butoon_slider.png");
    $("#img2").attr("src", "Images/butoon_slider.png");
    $("#img3").attr("src", "Images/butoon_slider.png");
    $("#img4").attr("src", "Images/butoon_slider.png");

    $("#img" + index).attr("src", "Images/butoon_slider_on.png");

    $("#imgMain").fadeOut(200, function()
    {
        $("#imgMain").attr("src", imageArray[index].src);
    }).fadeIn(200);

    $("#aMain").attr("href", "Activities.aspx?id=" + index);
}

function querySt(ji)
{
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++)
    {
        ft = gy[i].split("=");
        if (ft[0] == ji)
        {
            return ft[1];
        }
    }
}

function slideSwitch(index)
{
    var $active = $('#slideshow' + index + ' IMG.active');

    if ($active.length == 0) $active = $('#slideshow' + index + ' IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next = $active.next().length ? $active.next()
        : $('#slideshow' + index + ' IMG:first');

    // uncomment the 3 lines below to pull the images in random order

    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function()
        {
            $active.removeClass('active last-active');
        });
    }

    function sleep(milliseconds)
    {
        var start = new Date().getTime();
        for (var i = 0; i < 1e7; i++)
        {
            if ((new Date().getTime() - start) > milliseconds)
            {
                break;
            }
        }
    }
