var itemsCount = 3;
var aTopBannerHref = new Array("/jsp/products/concerto/home.jsp","/jsp/developers.jsp","/jsp/solutions/soa_solution.jsp")
var aTopBannerAlt = new Array("Devel. Management","Developers","QA - E2E Testing")
var aImgBannerSrc = new Array("/jsp/clipart/homepage/10/banner-DevMan-off.jpg","/jsp/clipart/homepage/10/banner-Devel-off.jpg","/jsp/clipart/homepage/10/banner-QA-off.jpg");
var aImgSwtSrc = new Array("/jsp/clipart/homepage/10/Icons-DevMan-off.gif","/jsp/clipart/homepage/10/Icons-Devel-off.gif","/jsp/clipart/homepage/10/IconsQA-off.gif","/jsp/clipart/homepage/10/Icons-DevMan-on.gif","/jsp/clipart/homepage/10/Icons-Devel-on.gif","/jsp/clipart/homepage/10/IconsQA-on.gif","/jsp/clipart/homepage/10/Icons-DevMan-over.gif","/jsp/clipart/homepage/10/Icons-Devel-over.gif","/jsp/clipart/homepage/10/IconsQA-over.gif");
var aImgBanner = new Array();
var aImgSwt = new Array();
for (i = 0; i < itemsCount; i++) {
    aImgBanner[i] = new Image();
    aImgBanner[i].src = aImgBannerSrc[i];
    aImgSwt[i] = new Image(); //version on
    aImgSwt[i].src = aImgSwtSrc[i]; //version on
    aImgSwt[i+itemsCount] = new Image(); //version off
    aImgSwt[i+itemsCount].src = aImgSwtSrc[i+itemsCount]; //version off
    aImgSwt[2*itemsCount+i] = new Image(); //version over
    aImgSwt[2*itemsCount+i].src = aImgSwtSrc[2*itemsCount+i]; //version over
}

function addTimer()
{
    timer = setTimeout("nextBanner(true)", 5000);
}

function delTimer()
{
    if (timer) {
        clearTimeout(timer);
    }
}

function nextBanner()
{
    nextBanner(false);
}


function nextBanner(bTimer)
{
    switchTop(currIdx+1, bTimer);
}

function switchMouseOvers(targetIdx)
{
    var aswTarget=document.getElementById("aswt"+targetIdx);
    if (aswTarget) {
        aswTarget.onmouseover="";
        aswTarget.onmouseout="";
    }
    var aswCurr=document.getElementById("aswt"+currIdx);
    if (aswCurr) {
        //maybe should be getElementById instead of name.src?
        aswCurr.onmouseover=new Function("swt"+currIdx+".src='"+ aImgSwtSrc[2*itemsCount+currIdx]+"'");
        aswCurr.onmouseout=new Function("swt"+currIdx+".src='"+ aImgSwtSrc[currIdx]+"'");
    }
}

function switchTop(targetIdx, bTimer)
{
    delTimer();
    if (targetIdx == currIdx) {
        return;
    }

    if ((targetIdx >= itemsCount) || (targetIdx < 0)) {
        targetIdx = 0
    }
    switchMouseOvers(targetIdx);
    document.getElementById("swt"+currIdx).src = aImgSwtSrc[currIdx];
    document.getElementById("swt"+targetIdx).src = aImgSwtSrc[targetIdx+itemsCount];
    document.getElementById("banner1").src = aImgBannerSrc[targetIdx];
    var area1 = document.getElementById("top_area1");
    if (area1) {
        area1.href=aTopBannerHref[targetIdx];
        area1.alt=aTopBannerAlt[targetIdx];
    }
    currIdx=targetIdx
    if (bTimer) {
        addTimer();
    }
}
