var itemsCount = 3;
var aTopBannerHref = new Array("/jsp/products/concerto/alm.jsp","/jsp/products/parasoft_test.jsp","/jsp/products/virtualize_splash.jsp")
var aTopBannerAlt = new Array("Devel. Management","Developers and QA","DevOps")
var aImgBannerSrc = new Array("/jsp/clipart/pl/11/bL.jpg","/jsp/clipart/pl/11/bM.jpg","/jsp/clipart/pl/11/bR.jpg");
var aImgSwtSrc = new Array("/jsp/clipart/pl/11/swtL_off.gif","/jsp/clipart/pl/11/swtM_off.gif","/jsp/clipart/pl/11/swtR_off.gif","/jsp/clipart/pl/11/swtL_on.gif","/jsp/clipart/pl/11/swtM_on.gif","/jsp/clipart/pl/11/swtR_on.gif","/jsp/clipart/pl/11/swtL_over.gif","/jsp/clipart/pl/11/swtM_over.gif","/jsp/clipart/pl/11/swtR_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)", 7000);
}

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) {
        var currSwt = document.getElementById("swt"+currIdx);
        if (currSwt) {
            aswCurr.onmouseover=new Function("document.getElementById('swt'+"+currIdx+").src='"+aImgSwtSrc[2*itemsCount+currIdx]+"'");
            aswCurr.onmouseout=new Function("document.getElementById('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();
    }
}

