﻿// JScript File
var selectedObj;
var timeDelay = 10000;
var timer;
var curPos = 0;
var timerActive = true;

var imgUrls = new Array('/Downloads.aspx',
                '',
                '/Movies/Default.aspx',
                '/QuiiQHA.aspx');
                
var imgMessages = new Array('New release 1.1 of QUiiQ MOVIES is now available',
                'Trully a Digital Experience',
                'Powerfull Home Cinema',
                'Your Digital Lifestyle');

function initHilites()
{
    selectObj(document.getElementById('shot0'), 0);
    //timer = setTimeout("selectObj(document.getElementById('shot1'), 1)", timeDelay);
}

function startStopTimer(ctrl)
{
    if(timerActive)
    {
        ctrl.src = "images/play.png";
        ctrl.alt = "Click to play";
        
        if(timer)
        {
            clearTimeout(timer);
            timer = null;
        }

        timerActive = false;
    }
    else
    {
        var next = curPos + 1;
        if(next > 3)
            next = 0;

        var crtlName = "shot" + next;
        
        ctrl.src = "images/stop.png";
        ctrl.alt = "Click to pause";
        timerActive = true;
        timer = setTimeout("selectObj(document.getElementById('" + crtlName + "'), " + next + ")", timeDelay);
    }
}

function selectObj(obj, val)
{
    if(timer)
        clearTimeout(timer);

    if(obj != selectedObj)
    {
        var tr = obj.parentNode;
        
        var i = 0;
        for(i = 0; i < tr.childNodes.length; i++)
        {
            if(tr.childNodes[i].className == 'shot_hilite')
                tr.childNodes[i].className = 'shot';
        }
        
        for(i = 0; i < 4; i++)
        {
            var img = document.getElementById('image' + i);
            if(i == val)
                img.style.visibility = 'visible';
            else img.style.visibility = 'hidden';
        }
        
        var msgCtrl = document.getElementById('hilite_message');
        
        //msgCtrl.innerText = imgMessages[val];
        
        //<div id="hilite_message" class="auto_hilite_ctrl_message"></div>
        //msgCtrl.innerHTML = '<a class="auto_hilite_ctrl_text" href="' + imgUrls[val] + '">' + imgMessages[val] + '</a>';
        obj.className = 'shot_hilite';
        selectedObj = obj;
        curPos = val;
    }
    
    if(timerActive)
    {
        var next = curPos + 1;
        if(next > 3)
            next = 0;

        var crtlName = "shot" + next;

        timer = setTimeout("selectObj(document.getElementById('" + crtlName + "'), " + next + ")", timeDelay);
    }/**/
}

function gotoUrl()
{
    var url = imgUrls[curPos];
    
    if(url == '')
        return;
    
    try
    {
        window.navigate(url);
    }
    catch(ex)
    {
        window.location = url;
    }
}