﻿function $(obj){return document.getElementById(obj)}

var THUMBIMAGECOUNT = 3;
var curPage = Math.floor(currentSmallImgIndex / THUMBIMAGECOUNT);
function nextPic2() {
    if (curPage * THUMBIMAGECOUNT >= imgs.picCount() || curPage < 0) {
        return;
    }
    curPage++;
    ResetSmallImage();
}
function prePic2() {
    if (curPage * THUMBIMAGECOUNT >= imgs.picCount() || curPage < 0) {
        return;
    }
    curPage--;
    ResetSmallImage();
}
function ResetSmallImage() 
{
//debugger;
    if (curPage * THUMBIMAGECOUNT >= imgs.picCount() || curPage < 0) {
        return;
    }
    var fromIndex = curPage * THUMBIMAGECOUNT + 1;
    var toIndex = (curPage + 1) * THUMBIMAGECOUNT;
    toIndex = toIndex < imgs.picCount() ? toIndex : imgs.picCount();
    $("picIndexFrom").innerHTML = fromIndex;//显示页数范围的第一个数子
    $("picIndexTo").innerHTML = toIndex;//显示页数范围的最后一个数子
    
    if(imgs.get(fromIndex - 1)!=null)
    {
        $("photoList1").style.display="block";
        $("photoList1").src = imgs.get(fromIndex - 1).smallpic;//显示的三张图片的第一张图片
        $("photoList1").alt = imgs.get(fromIndex - 1).name+" 鼠标移动放大";//显示的三张图片的第一张图片的alt名称 
        $("photoList1Name").innerHTML = imgs.get(fromIndex - 1).name;//显示的三张图片的第一张图片的名称
        $("photoList1Name").title = imgs.get(fromIndex - 1).name+" 鼠标移动放大";//显示的三张图片的第一张图片的名称
    }
    else
    {
        $("photoList1").style.display="none";
        $("photoList1Name").innerHTML = "";//显示的三张图片的第一张图片的名称
    }
    if(imgs.get(fromIndex)!=null)
    {
        $("photoList2").style.display="block";
        $("photoList2").src = imgs.get(fromIndex).smallpic;//显示的三张图片的第二张图片
        $("photoList2").alt = imgs.get(fromIndex).name+" 鼠标移动放大";//显示的三张图片的第二张图片的alt名称
        $("photoList2Name").innerHTML = imgs.get(fromIndex).name;//显示的三张图片的第一张图片的名称
        $("photoList2Name").title = imgs.get(fromIndex).name+" 鼠标移动放大";//显示的三张图片的第一张图片的名称
    }
    else
    {
        $("photoList2").style.display="none";
        $("photoList2Name").innerHTML = "";//显示的三张图片的第一张图片的名称
    }
    if(imgs.get(fromIndex + 1)!=null)
    {
        $("photoList3").style.display="block";
        $("photoList3").src = imgs.get(fromIndex + 1).smallpic;//显示的三张图片的第三张图片
        $("photoList3").alt = imgs.get(fromIndex + 1).name+" 鼠标移动放大";//显示的三张图片的第三张图片的alt名称
        $("photoList3Name").innerHTML = imgs.get(fromIndex + 1).name;//显示的三张图片的第一张图片的名称
        $("photoList3Name").title = imgs.get(fromIndex + 1).name+" 鼠标移动放大";//显示的三张图片的第一张图片的名称
    }
    else
    {
        $("photoList3").style.display="none";
        $("photoList3Name").innerHTML = "";//显示的三张图片的第一张图片的名称
    }

    for (var i = 1; i <= THUMBIMAGECOUNT; i++) {
        if (currentSmallImgIndex + 1 == fromIndex + i - 1)
            $("photoList" + i).parentNode.parentNode.className = "current";
        else
            $("photoList" + i).parentNode.parentNode.className = "";
    }
    if (fromIndex == 1)
        $("preli2").style.visibility = "hidden";//向左滑动按钮
    else
        $("preli2").style.visibility = "visible";
    if (toIndex >= imgs.picCount())
        $("nextli2").style.visibility = "hidden";//向右滑动按钮
    else
        $("nextli2").style.visibility = "visible";
}
function ImgItem() {
    this.title = "";
    this.url = "";
    this.pic = "";
    this.smallpic = "";
    this.memo = "";
    this.width = 0;
    this.height = 0;
}
ImgItem.prototype = {
    toImgHTML: function() {
    },
    toAHTML: function() {
    }
}
function ImgItems() {
    this.Imgs = new Array();
    this.add = addImg;
    this.get = getImg;
    this.picCount = picCount;
    this.toLiHtml = toLiHtml;
    this.doDivHtml = doDivHtml;
    function addImg(item) {
        this.Imgs[this.Imgs.length] = item;
    }
    function getImg(i) {
        if (i < this.Imgs.length)
            return this.Imgs[i];
        else
            return null;
    }
    function picCount() {
        return this.Imgs.length;
    }
    function toLiHtml() {
    }
    function doDivHtml() {
    }
}
function PhotoList1Click()
{
//debugger;
    if (curPage * THUMBIMAGECOUNT >= imgs.picCount() || curPage < 0) {
        return;
    }
    
    var fromIndex = curPage * THUMBIMAGECOUNT + 1;
    var toIndex = (curPage + 1) * THUMBIMAGECOUNT;
    toIndex = toIndex < imgs.picCount() ? toIndex : imgs.picCount();
    if(imgs.get(fromIndex - 1) != null)
    {
        var picSize= imgs.get(fromIndex - 1).size;
        $("bigImage").src= imgs.get(fromIndex - 1).url;
        $("defaultText").innerHTML = imgs.get(fromIndex - 1).name+" 鼠标移动查看大图";
        $("defaultText").title = imgs.get(fromIndex - 1).name+" 鼠标移动查看大图";
        $("bigImage").alt = imgs.get(fromIndex - 1).name+" 鼠标移动查看大图";
        $("bigpic").src= imgs.get(fromIndex-1).url;
        
        loadaction(picSize);
    }
    
}
function PhotoList2Click()
{
//debugger;
    if (curPage * THUMBIMAGECOUNT >= imgs.picCount() || curPage < 0) {
        return;
    }
    var fromIndex = curPage * THUMBIMAGECOUNT + 1;
    var toIndex = (curPage + 1) * THUMBIMAGECOUNT;
    toIndex = toIndex < imgs.picCount() ? toIndex : imgs.picCount();
    if(imgs.get(fromIndex) != null)
    {
        var picSize= imgs.get(fromIndex).size;
        $("bigImage").src= imgs.get(fromIndex).url;
        $("defaultText").innerHTML = imgs.get(fromIndex).name+" 鼠标移动查看大图";
        $("defaultText").title = imgs.get(fromIndex).name+" 鼠标移动查看大图";
        $("bigImage").alt = imgs.get(fromIndex).name+" 鼠标移动查看大图";
        $("bigpic").src= imgs.get(fromIndex).url;
        loadaction(picSize);
    }
}
function PhotoList3Click()
{
//   debugger;
    if (curPage * THUMBIMAGECOUNT >= imgs.picCount() || curPage < 0) {
        return;
    }
    var fromIndex = curPage * THUMBIMAGECOUNT + 1;
    var toIndex = (curPage + 1) * THUMBIMAGECOUNT;
    toIndex = toIndex < imgs.picCount() ? toIndex : imgs.picCount();
    if(imgs.get(fromIndex + 1) != null)
    {
        var picSize= imgs.get(fromIndex + 1).size;
        $("bigImage").src= imgs.get(fromIndex + 1).url;
        $("defaultText").innerHTML = imgs.get(fromIndex + 1).name+" 鼠标移动查看大图";
        $("defaultText").title = imgs.get(fromIndex + 1).name+" 鼠标移动查看大图";
        $("bigImage").alt = imgs.get(fromIndex + 1).name+" 鼠标移动查看大图";
        $("bigpic").src= imgs.get(fromIndex + 1).url;
       loadaction(picSize);
    }
}
