﻿
var improvingImg = new Array();
improvingImg[0]="images/rise-fall-graphics/libya.png";//4.8
improvingImg[1]="images/rise-fall-graphics/syria.png"; //4.2
improvingImg[2]="images/rise-fall-graphics/burkina-faso.png";  //3.8               

var improvingCountry = new Array();
improvingCountry[0]="Libya";
improvingCountry[1]="Syria";
improvingCountry[2]="Burkina Faso";

var improvingChange = new Array();
improvingChange[0]="+4.8";
improvingChange[1]="+4.2";
improvingChange[2]="+3.8";

var decliningImg = new Array();
decliningImg[0]="images/rise-fall-graphics/zimbabwe.png";  //-6.7
decliningImg[1]="images/rise-fall-graphics/venezuela.png"; //-4.8
decliningImg[2]= "images/rise-fall-graphics/moldova.png"; //-3.0

var decliningCountry = new Array();
decliningCountry[0]="Zimbabwe";
decliningCountry[1]="Venezuela";
decliningCountry[2]="Moldova";

var decliningChange = new Array();
decliningChange[0]="-6.7";
decliningChange[1]="-4.8";
decliningChange[2]="-3.0";             


var imgIndex = 0;
var totalImages = improvingImg.length;//Note:improving/declining must be the same number          

function MM_setTextOfLayer(objId,x,newText) { //v9.0
     with (document) if (getElementById && ((obj=getElementById(objId))!=null))
    with (obj) innerHTML = unescape(newText);
}     

function cycleImages() {           
                                                       
    if (imgIndex == totalImages) 
    {  	                  
       imgIndex = 0;
    }

    document.improvingCountry.src=improvingImg[imgIndex];                    
    document.decliningCountry.src=decliningImg[imgIndex];
                        
    var tempStr = '';
    var shortName;
    
    shortName = improvingCountry[imgIndex];
    shortName = shortName.replace(' ','');
    var improvingText = '<a href="./Country/' + shortName + '">' + improvingCountry[imgIndex];
    improvingText = improvingText + '</a> (' + improvingChange[imgIndex] + ') is among the most improved.'                    
    
    shortName = decliningCountry[imgIndex];
    shortName = shortName.replace(' ','');
    var decliningText = '<a href="./Country/' + decliningCountry[imgIndex] + '">' + decliningCountry[imgIndex];
    decliningText = decliningText + '</a> (' + decliningChange[imgIndex] + ') is among the most declined.';
    
    MM_setTextOfLayer('improvingCountryText','',improvingText);
    MM_setTextOfLayer('decliningCountryText','',decliningText);
    // set the time below for length of image display
    // i.e., "4*1000" is 4 seconds
    setTimeout("cycleImages()", 5*1000);
    imgIndex++;
}

cycleImages();