﻿var topLeftNews = new Array();
var topLeftNewsTimer = null;
var topLeftNewsTimerCurrentIndex = 0;
var accordionTimer = null;
var accordionCurrentIndex = 0;
function topLeftNewsLinkOver(index, byTimer) {
    if (index > 4) {
        index = 0;
    }

    dTopLeftNewsSubject = $get("divTopLeftNewsSubject");
    dTopLeftNewsSubject.innerHTML = "<a href='" + topLeftNews[index][3] + "'>" + topLeftNews[index][0] + "</a>";

    imageTopLeftNewsImage = $get("imTopLeftNewsImage");
    imageTopLeftNewsImage.src = topLeftNews[index][1];

    dTopLeftNewsContent = $get("divTopLeftNewsContent");
    dTopLeftNewsContent.innerHTML = "<a href='" + topLeftNews[index][3] + "'>" + topLeftNews[index][2] + "</a>";

    linkTopLeftNewsImageLink = $get("aTopLeftNewsImageLink");
    linkTopLeftNewsImageLink.href = topLeftNews[index][3];

    imageTopLeftNewsButton = $get("imRedBox" + index);
    imageTopLeftNewsButton.src = "/Images/" + (index + 1) + "_over.jpg";

    if (byTimer) {
        topLeftNewsLinkRestore(index, true);
    }
    else {
        topLeftNewsLinkRestore(index, false);
        topLeftNewsTimerStop();
    }

    topLeftNewsTimerCurrentIndex = index + 1;
}

function topLeftNewsLinkRestore(index, startTimer) {

    for (i = 0; i < 5; i++) {
        if (i == index) {
            continue;
        }
        imageTopLeftNewsButton = $get("imRedBox" + i);
        imageTopLeftNewsButton.src = "/Images/" + (i + 1) + ".jpg";
    }

    if (startTimer) {
        topLeftNewsTimerStart();
    }
}

function topLeftNewsTimerStart() {
    topLeftNewsTimer = window.setTimeout("topLeftNewsLinkOver(topLeftNewsTimerCurrentIndex,true);", 4000);
}

function topLeftNewsTimerStop() {
    if (topLeftNewsTimer != null) {
        window.clearTimeout(topLeftNewsTimer);
    }
}

function changeAccordion(index) {
    if (index > 9) {
        index = 0;
    }

    $("#divAccordion").accordion("activate", index)

    accordionCurrentIndex = index + 1;

    accordionTimerStart();
}

function accordionTimerStart() {
    accordionTimer = window.setTimeout("changeAccordion(accordionCurrentIndex);", 4000);
}

function accordionTimerStop() {
    if (accordionTimer != null) {
        window.clearTimeout(accordionTimer);
    }
}

		
		
