﻿function ImageShow() {
    this.img = new Image();
    this.href = "";
    this.tagHTML = ""; //在切换按钮中显示的内容，默认显示所在集合的索引数字。
    this.description = "";
    this.title = "";
}

function ImageArrayPush(imgSrc, imgAlt, href, tagHTML, desc, title) {
    var img = new ImageShow();
    img.img.src = imgSrc;
    img.img.alt = imgAlt;
    img.href = href;
    if (tagHTML != null)
        img.tagHTML = tagHTML;
    if (desc != null)
        img.description = desc;
    if (title != null)
        img.title = title;
    imageShows.push(img);
}

var showIndex = 0;
function ImageShowStart() {
    //if (startIndex == 0) { startIndex = 1; } //如果第一次执行startIndex=1，表示已经执行过一次了。
    //else 
    if (document.all)//document.all仅IE6/7认识，firefox不会执行此段内容
    {
        document.getElementById("ShowImage").filters[0].Apply(); //将滤镜应用到对像上
        document.getElementById("ShowImage").filters[0].Play(duration = 2);    //开始转换
        document.getElementById("ShowImage").filters[0].Transition = 23; //转换效果
    }

    document.getElementById("ShowImage").src = imageShows[showIndex].img.src;
    document.getElementById("ShowImageLinkHref").href = imageShows[showIndex].href;
    if (document.getElementById("ImageShowTitle") != null && imageShows[showIndex].title != null)
        document.getElementById("ImageShowTitle").innerHTML = imageShows[showIndex].title;
    if (document.getElementById("ImageShowDesc") != null && imageShows[showIndex].description != null)
        document.getElementById("ImageShowDesc").innerHTML = imageShows[showIndex].description;
    //替换ALT
    for (var i = 0; i < imageShows.length; i++) {
        document.getElementById("imageTagLink" + i).className = '';     //将下面黑条上的所有链接变为未选中状态
    }
    document.getElementById("imageTagLink" + showIndex).className = 's';      //将当前页面的ID设置为选中状态
    
    showIndex++;
    //alert(showIndex); 
    if (showIndex >= imageShows.length) 
    { 
        showIndex = 0;
    }    //如果ID大于总图片数量。则从头开始循环
    clearTimeout(timeouter);
    timeouter = setTimeout('ImageShowStart()', timeout);    //在4秒后重新执行ImageShowStart()方法.
}
function ChangeImageShow(n)//点击黑条上的链接执行的方法。
{


    showIndex = n; //当前页面的ID等于传入的N值,
    window.clearInterval(timeouter); //清除用于循环的timeouter
    //重新执行ImageShowStart();但ImageShowStart()内所调用的图片ID已经在此处被修改,会从新ID处开始执行.
    ImageShowStart();
}