﻿var iTimer = 0;
var iCurrent = 1;
var iNext = 1;
var iChange = 5000;
var color1 = "#e8e9ff";
var color2 = "#AAAAAA"

var aLink = new Array()
aLink[0] = "/trilbytv/";
aLink[1] = "/justenjoy/";
aLink[2] = "/cool/";
aLink[3] = "/studio/";

function ChangeButton(sButton, bOn)
{
    var oButton = document.getElementById(sButton);
    if (bOn)
    {
        oButton.style.background = color2;
        oButton.style.color = color1;
    }
    else
    {
        oButton.style.background = color1;
        oButton.style.color = color2;
    } 
}

function SetAlpha(sButton)
{
    var oButton = document.getElementById(sButton);
    oButton.style.opacity = 0.7;
    oButton.style.filter = "alpha(opacity=70)";
}

function ChangeFront()
{    
    iCurrent = iNext;
    switch (iCurrent)
    {
        case 1:
            document.getElementById('frontmain').style.backgroundImage = "url(media/front/home_1.png)";
            ChangeButton('frontbutton1', true);
            ChangeButton('frontbutton2', false);
            ChangeButton('frontbutton3', false);
            ChangeButton('frontbutton4', false);
            break;
        case 2:
            document.getElementById('frontmain').style.backgroundImage = "url(media/front/home_2.png)";
            ChangeButton('frontbutton1', false);
            ChangeButton('frontbutton2', true);
            ChangeButton('frontbutton3', false);
            ChangeButton('frontbutton4', false);
            break;
        case 3:
            document.getElementById('frontmain').style.backgroundImage = "url(media/front/home_3.png)";
            ChangeButton('frontbutton1', false);
            ChangeButton('frontbutton2', false);
            ChangeButton('frontbutton3', true);
            ChangeButton('frontbutton4', false);
            break;
        case 4:
            document.getElementById('frontmain').style.backgroundImage = "url(media/front/home_4.png)";
            ChangeButton('frontbutton1', false);
            ChangeButton('frontbutton2', false);
            ChangeButton('frontbutton3', false);
            ChangeButton('frontbutton4', true);
            break;
    }
    
    iNext++;
    if (iNext > 4)
    {
        iNext = 1;
    }  
}

function StopFront(iButton)
{
    clearInterval(iTimer);
    iNext = iButton;
    ChangeFront();
}

function StartFront()
{
    iTimer = setInterval("ChangeFront()", iChange);
}

function RunFront()
{
    SetAlpha('frontbutton1');
    SetAlpha('frontbutton2');
    SetAlpha('frontbutton3');
    SetAlpha('frontbutton4');
    ChangeFront();
    iTimer = setInterval("ChangeFront()", iChange);
}

function BigLink()
{
    window.location = aLink[iCurrent-1];    
}

function SmallLink(i)
{
    window.location = aLink[i];    
}
RunFront();