// The Srlde show JavaScript 2009/02/25  KBS
var myImages = new Array(        //配列にlotate するファイル名をセット 
    "./sld/sld01.html",   //旧英領ベテラン講師
    "./sld/sld02.html",   //英会話上達ノウハウ
    //"./sld/sld03.html",
    //"./sld/sld04.html",
    //"./sld/sld05.html",
    //"./sld/sld06.html",
    //"./sld/sld07.html",
    //"./sld/sld08.html",
    //"./sld/sld09.html",
    //"./sld/sld10.html",
    "./sld/sld00.html"    //英会話上達の道(最初)
);

var index = 0;
var intervalTime = 30000;  //切替間隔 msec
var timer;                //setIntervalの識別子
var isSliding;            //1=スライド中

function nextImage(image, caption) {    //setInterval Function 
    //--- debug lilne to show length and index
    //document.getElementById('strX2').innerHTML = "index =" + index + "<br>";
    //document.getElementById('strX').innerHTML = myImages.length;
    if ( index >= myImages.length ) {
        index = 0; 
    }
    document.getElementById(caption).src = myImages[index++];  //画像,htmlファイル名をセット
}

function goPreviousImage() {    //setInterval Function 
    caption = 'imageBoxCaption';
    index--;
    if ( index < 0) {
        index = myImages.length - 1; 
    }
    document.getElementById(caption).src = myImages[index];  //画像,htmlファイル名をセット
}


function goNextImage() {    //setInterval Function 
    caption = 'imageBoxCaption';
    index++;
    if ( index >= myImages.length) {
        index = 0; 
    }
    document.getElementById(caption).src = myImages[index];  //画像,htmlファイル名をセット
}


function startSlideShow() {  //領域 id="imageBox"    id="imageBoxCaption">
    timer = setInterval( "nextImage('imageBox', 'imageBoxCaption')", intervalTime );
    isSliding = 1; //自動上映中 //領域 id="slideState"
    //document.getElementById('slideState').innerHTML = "stop";
    document.getElementById('slideState').innerHTML = 
    "<img src='./sld/images/stop_button.gif' style='border:0;width:123px;height:20px;margin:5 0 0 0;'>"; //border='0' width='123' height='20px'> ";
    document.getElementById('slidePrevi').innerHTML = "";
    document.getElementById('slideNext').innerHTML = "";
    //No sound line
    //javascript:ring.src='piyo.wav';
   //window.navigator.ring.src='piyo.wav';
}

function stopSlideShow() {
    clearInterval(timer);
    isSliding = 0;        // 領域id="slideState"
    //document.getElementById('slideState').innerHTML = "start";
    document.getElementById('slideState').innerHTML = 
    "<img src='./sld/images/start_button.gif'  style='border:0;width:123px;height:20px;margin:-3 0 0 0;'>"; //border='0' width='123' height='20px'>";
    document.getElementById('slidePrevi').innerHTML = 
    "<img src='./sld/images/previous_button.gif' style='border:0;width:20px;height:18px;margin:2 0 5 -60;'>";     //border='0' width='20px' height='18px' style='margin:0 0 5 -60'>";
    document.getElementById('slideNext').innerHTML = 
    "<img src='./sld/images/next_button.gif' style='border:0;width:20px;height:18px;margin:2 0 5 -30;'>";      //border='0' width='20px' height='18px' style='margin:0 0 5 -30'> ";
    index = index - 1;
    if ( index < 0) {
        index = myImages.length - 1; 
    }
}

function setIntervalTime(time) {
    intervalTime = time;
}

function toggleSlideShow() {
    if ( isSliding ) {
        stopSlideShow();
    } else {
        startSlideShow();
    }
}

function restartSlideShow() {
    stopSlideShow();
    startSlideShow();
}

function changeSlideShowInterval(time) {
    setIntervalTime(time);
    restartSlideShow();
}

function onInit() {  //スタート関数
    //setIntervalTime(intervalTime);
    setIntervalTime(intervalTime);
    startSlideShow();
}
