﻿var ContentHeight = 230;
var TimeToSlide = 250.0;

var openAccordion = '';

function runAccordion(index) {
    var nID = "Accordion" + index + "Content";
    if (openAccordion == nID)
        nID = '';

    setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide + ",'" 
        + openAccordion + "','" + nID + "'," + index + ")", 33);
    
    openAccordion = nID;
}

function animate(lastTick, timeLeft, closingId, openingId, index) {
    var curTick = new Date().getTime();
    var elapsedTicks = curTick - lastTick;

    var opening = (openingId == '') ? null : document.getElementById(openingId);
    var closing = (closingId == '') ? null : document.getElementById(closingId);

    var id = index;
    
    if (timeLeft <= elapsedTicks) 
    {
        if (opening != null) 
        {
            if (openingId == 'Accordion1Content') 
            {
                opening.style.height = (ContentHeight - 100) + 'px';
                ddCategoryDown('1');
            }
            
            else if (openingId == 'Accordion2Content') 
            {
                opening.style.height = ContentHeight + 'px';
                ddCategoryDown('2');
            }

            else if (openingId == 'Accordion3Content') 
            {
                opening.style.height = (ContentHeight - 80) + 'px';
                ddCategoryDown('3');
            }

            else if (openingId == 'Accordion4Content') 
            {
                opening.style.height = (ContentHeight - 80) + 'px';

                ddCategoryDown('4');
            }

            else if (openingId == 'Accordion5Content') 
            {
                opening.style.height = (ContentHeight - 50) + 'px';

                ddCategoryDown('5');
            }
            
            else if (openingId == 'Accordion6Content') 
            {
                opening.style.height = (ContentHeight + 100) + 'px';

                ddCategoryDown('6');
            }

            else if (openingId == 'Accordion7Content') 
            {
                opening.style.height = (ContentHeight - 150) + 'px';

                ddCategoryDown('7');
            }

            else if (openingId == 'Accordion8Content') 
            {
                opening.style.height = (ContentHeight + 100) + 'px';

                ddCategoryDown('8');
            }
            
            else 
            {
                opening.style.height = ContentHeight + 'px';
            }
            
        }

        if (closing != null) 
        {
            closing.style.display = 'none';
            closing.style.height = '0px';
        }
        
        return;
    }

    timeLeft -= elapsedTicks;
    var newClosedHeight = Math.round((timeLeft / TimeToSlide) * ContentHeight);

    if (opening != null)
    {
        if (opening.style.display != 'block')
            opening.style.display = 'block';
        opening.style.height = (ContentHeight - newClosedHeight) + 'px';

    }

    if (closing != null)
        closing.style.height = newClosedHeight + 'px';

    setTimeout("animate(" + curTick + "," + timeLeft + ",'"
      + closingId + "','" + openingId + "')", 33);

    ddCategory();
    selectionIconHide();
}

function ddCategoryDown(num) 
{
    var projectArrow = 'ProjectArrow';
    var projectArrowD = 'ProjectArrowDown';
    var projectArrowUp = document.getElementById(projectArrow + num );
    var projectArrowDown = document.getElementById(projectArrowD + num);

    projectArrowUp.style.visibility = 'hidden';
    projectArrowDown.style.visibility = 'visible';
}


function ddCategory() 
{
    var projectArrow = document.getElementById('ProjectArrow1');
    var projectArrowDown = document.getElementById('ProjectArrowDown1');
    var projectArrow2 = document.getElementById('ProjectArrow2');
    var projectArrowDown2 = document.getElementById('ProjectArrowDown2');
    var projectArrow3 = document.getElementById('ProjectArrow3');
    var projectArrowDown3 = document.getElementById('ProjectArrowDown3');
    var projectArrow4 = document.getElementById('ProjectArrow4');
    var projectArrowDown4 = document.getElementById('ProjectArrowDown4');
    var projectArrow5 = document.getElementById('ProjectArrow5');
    var projectArrowDown5 = document.getElementById('ProjectArrowDown5');
    var projectArrow6 = document.getElementById('ProjectArrow6');
    var projectArrowDown6 = document.getElementById('ProjectArrowDown6');
    var projectArrow7 = document.getElementById('ProjectArrow7');
    var projectArrowDown7 = document.getElementById('ProjectArrowDown7');
    var projectArrow8 = document.getElementById('ProjectArrow8');
    var projectArrowDown8 = document.getElementById('ProjectArrowDown8');

    projectArrow.style.visibility = 'visible';
    projectArrowDown.style.visibility = 'hidden';
    projectArrow2.style.visibility = 'visible';
    projectArrowDown2.style.visibility = 'hidden';
    projectArrow3.style.visibility = 'visible';
    projectArrowDown3.style.visibility = 'hidden';
    projectArrow4.style.visibility = 'visible';
    projectArrowDown4.style.visibility = 'hidden';
    projectArrow5.style.visibility = 'visible';
    projectArrowDown5.style.visibility = 'hidden';
    projectArrow6.style.visibility = 'visible';
    projectArrowDown6.style.visibility = 'hidden';
    projectArrow7.style.visibility = 'visible';
    projectArrowDown7.style.visibility = 'hidden';
    projectArrow8.style.visibility = 'visible';
    projectArrowDown8.style.visibility = 'hidden';
}


function selectionIconHide() 
{
    var selectedProjectIcon = document.getElementById('SelectedProject');
        
    selectedProjectIcon.style.visibility = 'hidden';
}


function selectionIconShow(num) 
{
    var selectedProjectIcon = document.getElementById('SelectedProject');

    var browser = navigator.appName;
    var b_version = navigator.appVersion;
    var version = parseFloat(b_version);

    if (num == 1) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 135;
        }
        else
        {
            topLocation = 135 - 15;
        }
    }
    else if (num == 2) 
    {
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 170;
        }
        else
        {
            topLocation = 170 - 15;
        }
    }
    else if (num == 3) 
    {
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 212;
        }
        else
        {
            topLocation = 212 - 15;
        }
    }
    else if (num == 4) 
    {
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 189;
        }
        else
        {
            topLocation = 189 - 23;
        }
    }
    else if (num == 5) 
    {
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 238;
        }
        else
        {
            topLocation = 238 - 23;
        }
    }
    else if (num == 6) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 287;
        }
        else
        {
            topLocation = 287 - 23;
        }
    }
    else if (num == 7) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 329;
        }
        else
        {
            topLocation = 329 - 23;
        }
    }
    else if (num == 8) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 236;
        }
        else
        {
            topLocation = 236 - 30;
        }
    }
    else if (num == 9) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 278;
        }
        else
        {
            topLocation = 278 - 30;
        }
    }
    else if (num == 10) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 312;
        }
        else
        {
            topLocation = 312 - 30;
        }
    }
    else if (num == 11) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 340;
        }
        else
        {
            topLocation = 340 - 30;
        }
    }
    else if (num == 12) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 280;
        }
        else
        {
            topLocation = 280 - 35;
        }
    }
    else if (num == 13) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 322;
        }
        else
        {
            topLocation = 322 - 35;
        }
    }
    else if (num == 14) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 358;
        }
        else
        {
            topLocation = 358 - 35;
        }
    }
    else if (num == 15) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 385;
        }
        else
        {
            topLocation = 385 - 35;
        }
    }
    else if (num == 16) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 333;
        }
        else
        {
            topLocation = 333 - 40;
        }
    }
    else if (num == 17) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 398;
        }
        else
        {
            topLocation = 398 - 40;
        }
    }
    else if (num == 18) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 454;
        }
        else
        {
            topLocation = 454 - 40;
        }
    }
    else if (num == 19) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 380;
        }
        else
        {
            topLocation = 380 - 50;
        }
    }
    else if (num == 20) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 430;
        }
        else
        {
            topLocation = 430 - 50;
        }
    }
    else if (num == 21) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 472;
        }
        else
        {
            topLocation = 472 - 50;
        }
    }
    else if (num == 22) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 514;
        }
        else
        {
            topLocation = 514 - 50;
        }
    }
    else if (num == 23) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 556;
        }
        else
        {
            topLocation = 556 - 50;
        }
    }
    else if (num == 24) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 590;
        }
        else
        {
            topLocation = 590 - 50;
        }
    }
    else if (num == 25) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 618;
        }
        else
        {
            topLocation = 618 - 50;
        }
    }
    else if (num == 26) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 646;
        }
        else
        {
            topLocation = 646 - 50;
        }
    }
    else if (num == 27) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 412;
        }
        else
        {
            topLocation = 412 - 53;
        }
    }
    else if (num == 28) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 472;
        }
        else
        {
            topLocation = 472 - 60;
        }
    }
    else if (num == 29) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 528;
        }
        else
        {
            topLocation = 528 - 60;
        }
    }
    else if (num == 30) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 576;
        }
        else
        {
            topLocation = 576 - 60;
        }
    }
    else if (num == 31) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 612;
        }
        else
        {
            topLocation = 612 - 60;
        }
    }
    else if (num == 32) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 639;
        }
        else
        {
            topLocation = 639 - 60;
        }
    }
    else if (num == 33) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 674;
        }
        else
        {
            topLocation = 674 - 60;
        }
    }
    else if (num == 34) 
    {   
        if(browser == 'Microsoft Internet Explorer')
        {
            topLocation = 716;
        }
        else
        {
            topLocation = 716 - 60;
        }
    }
    
    selectedProjectIcon.style.visibility = 'visible';
    selectedProjectIcon.style.top = topLocation + 'px';
}


