/**
 * ModelInfo.js
 * Provides various DOM functionality for the Model Info section.
 * Dependencies: ATC.js, prototype.js, AC_QuickTime.js, swfobject.js, video_player.js
 */

// Create namespace for the class
ATC.createNamespace('ATC.cs.research.mi');

// Class ModelInfo
ATC.cs.research.mi.ModelInfo = function() {
    ;
};

// Count how many vehicles have been checked
ATC.cs.research.mi.ModelInfo.prototype.switchPhotoTabs = function(tabVal) {

    document.getElementById('photo-display-table').style.display = 'none';
    if( document.getElementById('exterior-360-container') != null ) {
        document.getElementById('exterior-360-container').style.display = 'none';
    }
    if( document.getElementById('interior-360-container') != null ) {
        document.getElementById('interior-360-container').style.display = 'none';
    }

    if(tabVal=='photos') {
        stopStartSlideShow();
        document.getElementById('photo-display-table').style.display = 'block';
    } else if(tabVal=='360-exterior') {
        stopStartSlideShow('stop');
        document.getElementById('exterior-360-container').style.display = 'block';
//        window.setTimeout(showExterior, 1000);
    } else {
        stopStartSlideShow('stop');
        document.getElementById('interior-360-container').style.display = 'block';
//        window.setTimeout(showInterior, 1000);
    }
};

function showExterior()
{
//    QT_ShowController('exterior360');
}

function showInterior()
{
//    QT_ShowController('interior360');
}

// change the color-preview photo shown as the user mouses over a swatch
ATC.cs.research.mi.ModelInfo.prototype.showColorImage = function( index, colorName, colorSrc ) {
    document.getElementById('color-change').src = colorSrc;

    var nameNode = document.getElementById('color-name');
    nameNode.removeChild(nameNode.firstChild);
    nameNode.appendChild(document.createTextNode(colorName));

    var lengthArray = document.getElementById("color-swatch-container").getElementsByTagName("img");
    var length = lengthArray.length;

    for( var i = 0; i<length; i++ ) {
        if(document.getElementById('color-' + i) != null)
        {
            if( i == index ) {
                document.getElementById('color-' + i).src = '/img/research/mir/color-hilite.gif';
            } else {
                document.getElementById('color-' + i).src = '/img/research/mir/color-hilite-hidden.gif';
            }
        }
        else{ length++; }
    }
}

// switches tabs on the model overview page
ATC.cs.research.mi.ModelInfo.prototype.switchOverviewTabs = function(tabVal) {
    if(tabVal=='videos') {

        document.getElementById('photo-tab').style.display = 'none';
        document.getElementById('video-tab').style.display = 'block';


    } else {

        document.getElementById('video-tab').style.display = 'none';
        document.getElementById('photo-tab').style.display = 'block';

        // TODO: find out why this crashes firefox

    }
}

