﻿
// JScript 文件

function PhotoGallery(pObject,sDiv,tDiv,cClass,uClass){
        this.photo=null;
        this.showDiv=null;
        this.txtDiv=null;
        this.current="";
        this.unCurrent="";
        this.txtTag="ulContent_";
     }
     PhotoGallery.prototype.changePhoto=function(){
     
        for (var i=0; i < this.photo.parentNode.parentNode.childNodes.length; i++) {
            var oNode = this.photo.parentNode.parentNode.childNodes[i];
            if (oNode.id == this.photo.parentNode.id) {
                oNode.className = this.current;
                var tempNode=oNode;
                var j = 50;
                var myI = window.setInterval(function(){
                    j++;
                    //if(i>=0)
                    //    tempNode.firstChild.style.filter = "Alpha(Opacity="+ i +")"
                    //else 
                    if(j<=100)
                        tempNode.style.filter = "Alpha(Opacity="+ j +")"
                    else
                        window.clearInterval(myI);
                },10)
            } else if (oNode.className == this.current) {
                oNode.className = this.unCurrent;
                //oNode.firstChild.style.filter = "Alpha(Opacity=100)"
            }
        }
        var attChilds = this.showDiv.childNodes; 
        var i = 0; 
        while(attChilds[i].nodeType!=1 && i<=attChilds.length) i++; 
        var oImg =attChilds[i];
        oImg.removeAttribute("width");
        oImg.removeAttribute("height");
        //oImg.width=160;
        //oImg.height=158;
        if(oImg.filters)
            oImg.filters[0].Apply();
        //oImg.src=this.photo.src.replace(/_Thumb/, "");
        oImg.src=this.photo.src.replace(/_index/, "");
        oImg.alt=this.photo.alt;
        oImg.setAttribute("ref",this.photo.getAttribute("ref"));
        if(oImg.filters){
            iTrans = Math.floor (  Math.random( ) * (12+1 ) ) ;// 动态变换的方式有12种
            oImg.filters[0].transition =   iTrans  ;
            oImg.filters[0].Play(2);
        }
        
        var txtTagId=this.txtTag+this.photo.className;
        this.txtDiv.innerHTML=document.getElementById(txtTagId).outerHTML;
     }

    /**
     * 初始化
     * pObject 当前展示图片
     * sDiv    大图展示DIV-id
     * tDiv    文字说明DIV-id
     * cClass  当前展示样式
     * uClass  非活动缩微图样式
     */
     PhotoGallery.prototype.init=function(pObject,sDivId,tDivId,cClass,uClass){
        this.photo=pObject;
        this.showDiv=document.getElementById(sDivId);
        this.txtDiv=document.getElementById(tDivId);
        this.current=cClass;
        this.unCurrent=uClass;
        this.changePhoto();
     }



