﻿// JScript 檔
//對ie和firefox的兼容處理
function isIE(){ //ie? 
if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=1) 
    return true; 
else 
    return false; 
}

if(!isIE())
{
    HTMLElement.prototype.__defineSetter__
    (
        "innerText", 
        function(sText)
        {
            this.textContent=sText;
            //alert(1);
        } 
    ); 

    HTMLElement.prototype.__defineGetter__
    (
        "innerText",
        function ()
        {
            var anyString = "";
            var childS = this.childNodes;
            for(var i=0; i<childS.length; i++)
            {
                if(childS[i].nodeType==1)
                    anyString += childS[i].tagName=="BR" ? '"n' : childS[i].innerText;
                else if(childS[i].nodeType==3)
                    anyString += childS[i].nodeValue;
            }
            return anyString;
        }
    );
}

var photoshownum = 5;//一次顯示幾張縮圖
var photopageidx = 0;//顯示第幾頁的縮圖
function ShiftPhoto(imgobj,dir)
{
    if(strUrl.length>0 && strName.length>0)
    {
        if (dir=="0") {photopageidx--;}
        if (dir=="1") {photopageidx++;}        
        if (photopageidx < 0) photopageidx = 0; 
        if (photoshownum*photopageidx >= strUrl.length) photopageidx = photopageidx-1;
		//photo start number
        document.getElementById(imgobj.startnumid).innerText=photopageidx*photoshownum+1;
        if (photopageidx == 0)
        {
            document.getElementById(imgobj.upbtnid).disabled = true;
        }
        //photo end number
        document.getElementById(imgobj.endnumid).innerText=photopageidx*photoshownum+photoshownum;
        if(strUrl.length<=photopageidx*photoshownum+photoshownum)
        {
            document.getElementById(imgobj.endnumid).innerText=strUrl.length;
            document.getElementById(imgobj.downbtnid).disabled = true;
        }
        //img1
        ShowPhoto(imgobj.img1id,imgobj.a1id,photoshownum*photopageidx); 
		//img2
		if (photoshownum >= 2 )
		{ShowPhoto(imgobj.img2id,imgobj.a2id,photoshownum*photopageidx+1);}
		//img3
		if (photoshownum >= 3 )
        {ShowPhoto(imgobj.img3id,imgobj.a3id,photoshownum*photopageidx+2);}
		//img4
		if (photoshownum >= 4 )
        {ShowPhoto(imgobj.img4id,imgobj.a4id,photoshownum*photopageidx+3);}
		//img5
		if (photoshownum >= 5 )
        {ShowPhoto(imgobj.img5id,imgobj.a5id,photoshownum*photopageidx+4);}
        
    }    
} 

function ShowPhoto(imgid,aid,showidx)
{
    //<img src="...
    document.getElementById(imgid).src=strUrl[showidx];
    //<a href="...
    var tmpA = document.getElementById(aid);
    tmpA.href="";
    tmpA.rel="";
    tmpA.title="";
    if(strUrl[showidx]!=null)
    {
        tmpA.href=strUrl[showidx].replace("I.","B.");
        tmpA.rel="lightbox"; 
    } 
    if(strName[showidx]!=null)
    {
        tmpA.title=strName[showidx];
    } 
}

function ImgObject()
{
	this.startnumid = "";
	this.endnumid = "";
	this.downbtnid = "";
	this.upbtnid = "";
	this.img1id = "";
	this.img2id = "";
	this.img3id = "";
	this.img4id = "";
	this.img5id = "";
	this.a1id = "";
	this.a2id = "";
	this.a3id = "";
	this.a4id = "";
	this.a5id = "";	 
}
