/* ::: Pierre Potvin -- NetSphere Solutions -- http://www.netspheresolutions.com ::: */

// -- exclusive stories --

function esNavTo(storyIndex) {
    intStoryIndex = storyIndex;
    updateExclusiveStory();
}

function esNavPrev() {
    intStoryIndex--;
    if (intStoryIndex < 1)
        intStoryIndex = intExclusiveStoryCount;
        
    updateExclusiveStory();
}

function esNavNext() {
    intStoryIndex++;
    if (intStoryIndex > intExclusiveStoryCount)
        intStoryIndex = 1;
        
    updateExclusiveStory();
}

function updateExclusiveStory() {
    var story = exclusiveStories[intStoryIndex - 1];
    
    var aESLink1 = document.getElementById('aESLink1');
    var imgESPicture = document.getElementById('imgESPicture');
    var divESPhotoCredits = document.getElementById('divESPhotoCredits');
    var aESLink2 = document.getElementById('aESLink2');
    var divESLead = document.getElementById('divESLead');
    var ESLogo = document.getElementById('ESLogo');
	var divESProgramme = document.getElementById('divESProgramme');
	var divESComment = document.getElementById('divESComment');
	
    aESLink1.href = story.URL;
    if (story.imagePath == '/')
        imgESPicture.src = 'images/tvg2-es-no-pic.gif';
    else
        imgESPicture.src = '../images/' + story.imagePath;

    divESPhotoCredits.innerHTML = story.photoCredits;
    aESLink2.href = story.URL;
    aESLink2.innerHTML = story.headline;
    divESLead.innerHTML = story.lead;
    ESLogo.innerHTML = story.logo;
	divESProgramme.innerHTML = story.programme ;
	divESComment.innerHTML = story.comment ;
  
    for (var i = 1; i <= intExclusiveStoryCount; i++) {
        var aES = document.getElementById('aES' + i.toString());
        if (i == intStoryIndex)
            aES.className = 'aESActive';
        else
            aES.className = 'aESInactive';
    }
}

function pushExclusiveStory(headline, lead, URL, imagePath, photoCredits, logo, programme, comment) {
    var story = new Object();
    story.headline = headline;
    story.lead = lead;
    story.URL = URL;
    story.imagePath = imagePath;
    story.photoCredits = photoCredits;
    story.logo = logo;
    story.programme = programme;
    story.comment = comment;
    exclusiveStories.push (story);
}

var itvESAutoNav;
function launchESAutoNav() {
    itvESAutoNav = setInterval (esNavNext, 4500);
}

function quitESAutoNav() {
    clearInterval (itvESAutoNav);
}

