
// --------------- PUB -----------
var prevAd = 1;
var maxAd = 0;
var adTimer = null;
var autoMove = true;
var adSpeed = 25000; // timing between 2 images
var adTimer = setTimeout("moveAd()", adSpeed);

function adStop() {
    autoMove = true;
    toggleAdPlay();
}

function doClickAd(id) {
    adStop();
    doMoveAd(id);
}

function doMoveAd(id) {
    document.getElementById('home_ad_'+prevAd).className= 'hidden';
    document.getElementById('home_ad_'+id).className= '';
    document.getElementById('button_ad_'+prevAd).className= 'button_up';
    document.getElementById('button_ad_'+id).className= 'button_down';
    prevAd = id;
    if (adTimer != null) clearTimeout(adTimer);
    if (autoMove) adTimer = setTimeout("moveAd()", adSpeed); 
    return false;
}

function moveAd() {
    id = prevAd + 1;
    if (id > maxAd) id = 1;
    doMoveAd(id);
}

function doAdPrev() {
    adStop();
    id = prevAd - 1;
    if (id <= 0) id = maxAd;
    doMoveAd(id);
}

function doAdNext() {
    adStop();
    moveAd();
}

function toggleAdPlay() {
    if (autoMove) {
        if (adTimer != null) clearTimeout(adTimer);
        adTimer = null;
        autoMove = false;
        document.getElementById("button_play").src="/images/navig/button_play.gif";
    } else {
        adTimer = setTimeout("moveAd()", adSpeed); 
        autoMove = true;
        document.getElementById("button_play").src="/images/navig/button_pause.gif";
    }
}

// --------------- /PUB -----------


