// JavaScript Document

// higlighthTV()
// permet de changer :
// 1 - l'image dans la tele - right column - selon l'id du lien en over passé en parametre : elem
// 2 - changer la classe du lien 

var hotes = [
    {id:'anim_andre-robitaille',     pic:'/images/right_tv_2.jpg'},
    {id:'anim_anne-marie-withenshaw',pic:'/images/right_tv_4.jpg'},
    {id:'anim_liza-frulla',          pic:'/images/right_tv_1.jpg'},
    {id:'anim_marc-cassivi',         pic:'/images/right_tv_3.jpg'}
];

var stopSelecting = false;
var selectedHote = null;
var pageHote = null;    

window.addEvent('domready',function (){
    hotes.each(function(hote){
        // Set event actions to hote object
        $(hote.id).addEvents({
            'mouseover': function(){
                higlighthTV(hote);
            },
            'mouseout': function(){
                higlighthTV(pageHote);
            },
            'click': function(){
                stopSelecting = true;
            }
        });

        // Set dom element to hote object
        hote.dom = $(hote.id);

        // Set the page's hote -> classMame is selected on load
        if(hote.dom.className == 'select'){
            pageHote = hote;
            selectedHote = hote;
        }
    });
});

function higlighthTV(hote) {
    if(!stopSelecting){
        // Unselect selected element
        if(selectedHote)
            selectedHote.dom.className = 'unselect';

        // Select element
        document.getElementById('hotesImgSelected').src = hote.pic;
        hote.dom.className = 'select';
        selectedHote = hote;
    }
}
