var hT, sT, prev, prevTimer, cur, curTimer, curTarget, globalTimer, globalTimeout, over;

window.onload = function()
{
    globalTimeout = 6000;
    equipmentMenu = document.getElementById('equipment');
    if (!equipmentMenu) return false;
    globalTimer = setTimeout('Wait()', globalTimeout);
}

function processInputEvents(input, defaultValue, event)
{
    if (event == 'focus')
    {
        if (input.value == defaultValue) {
            input.value = '';
        }
    }
    else if (event == 'blur')
    {
        if (input.value == '') {
            input.value = defaultValue;
        }
    }
}

function Show(imgId)
{
    var obj = document.getElementById(imgId);
    var x = 1;
    
    if (!prev) 
    {
        prev = document.getElementById('item_1');
    }
    
    if (prev != obj)
    {
        prev.style.opacity = 0;
        prev.style.filter='alpha(opacity='+0*100+')';
        clearTimeout(prevTimer);
    }
    var lis = document.getElementsByClassName(prev.id);
    cleanActiveClass(lis[0]);
    var lis = document.getElementsByClassName(imgId);
    putActiveClass(lis[0]);
    
    prev = obj;
    op = (obj.style.opacity)?parseFloat(obj.style.opacity):parseInt(obj.style.filter)/100;
    if(op < x) {
        clearTimeout(prevTimer);
        op += 0.1;
        obj.style.opacity = op;
        obj.style.filter='alpha(opacity='+op*100+')';
        prevTimer=setTimeout('Show(\''+imgId+'\')',30);
    }
}

function Hide(imgId) {
    var obj = document.getElementById(imgId);
    var x = 0;
    op = (obj.style.opacity)?parseFloat(obj.style.opacity):parseInt(obj.style.filter)/100;
    if(op > x) {
        clearTimeout(sT);
        op -= 0.1;
        obj.style.opacity = op;
        obj.style.filter='alpha(opacity='+op*100+')';
        hT=setTimeout('Hide(\''+imgId+'\')',10);
    }
}

function putActiveClass(li)
{
    a = li.getElementsByTagName('a');
    a[0].className = 'active';
}

function cleanActiveClass(li)
{
    a = li.getElementsByTagName('a');
    a[0].className = '';
}

function Wait()
{
    if (globalTimer)
    {
        clearTimeout(globalTimer);
    }
    if (over)
    {
        return setTimeout('Wait()', globalTimeout);
    }
    return showNextItem();
}

function showNextItem()
{
    itemList = document.getElementById('equipment');
    lis = itemList.getElementsByTagName('li');
    activeLink = itemList.getElementsByClassName('active')[0];
    currentLi = activeLink.parentNode.parentNode;
    for (i=0;i<lis.length;i++)
    {
        if ((lis[i] == currentLi) && (i>=3))
        {
            prev = document.getElementById(activeLink.parentNode.parentNode.className);
            Show(lis[0].className);
            return globalTimer = setTimeout('Wait()', globalTimeout);
        }
    }
    
    nextLi = nextObject(currentLi);
    if (nextLi)
    {
        Show(nextLi.className);
    }
    else
    {
        prev = document.getElementById(activeLink.parentNode.parentNode.className);
        Show(lis[0].className);
    }
    return globalTimer = setTimeout('Wait()', globalTimeout);
}

function nextObject(currentObject) 
{
    var n = currentObject;
    do n = n.nextSibling;
    while (n && n.nodeType != 1);
    return n;
}



