
//====================================================================================================================
//¹ö¶¯Í¼Æ¬
//====================================================================================================================
var _DivMain,_DivMain,_TblImage,_TdMain,_TdSub,_Speed;

function SetImageRolling(ID,Title,Path,DivMain,TblImage,TdMain,TdSub,OnImgClick,RSpeed)
{
    _DivMain = document.getElementById(DivMain);
    _TblImage = document.getElementById(TblImage);
    _TdMain = document.getElementById(TdMain);
    _TdSub = document.getElementById(TdSub);    
    _Speed = RSpeed;
    ShowImage(ID,Title,Path,OnImgClick);
    SetRolling();
}

function ShowImage(ID,Title,Path,OnImgClick)
{
    var k,i;
    var tmp;  
    
    var tbl = _TblImage; 
    var tr = tbl.insertRow(-1);
         	        
    for(k=0;k<2;k++)
      for(i=0;i<ID.length;i++)
      {
             if(ID[i]=="") continue;
	         	         
             td = document.createElement("<td style='cursor:hand;' onclick='javascript:" + OnImgClick + "(" + ID[i] + ")'>");
             tmp = "<img src='" + Path[i] + "' width='120' height='90' border=1 title='" +  decodeURI(Title[i]) + "'>";
             td.innerHTML = tmp;
             tr.appendChild(td);			        
             
             td = document.createElement("<td>");
             tmp = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
             td.innerHTML = tmp;
             tr.appendChild(td);	
      } 
}

function SetRolling()
{
    var speed = _Speed;    
    _DivMain.onmouseover = function(){clearInterval(Mar)};
    _DivMain.onmouseout = function(){Mar = setInterval(Marquee,speed)};
    _TdSub.innerHTML = _TdMain.innerHTML;
    Mar = setInterval(Marquee,speed);
}
function Marquee()
{
   if( _TdSub.offsetWidth - _DivMain.scrollLeft <= 0 )
       _DivMain.scrollLeft -= _TdMain.offsetWidth;
   else
       _DivMain.scrollLeft++;
}



//====================================================================================================================
//Í¼Æ¬ÂÖ»»
//====================================================================================================================
function CLASS_Change_Images()
{    
    this.Doc = window.document;
    this._ID = new Array();
    this._Title = new Array();
    this._Path = new Array();
    this._Speed = 5000;
    this._Step = -1;
    this._CurID = 0;
    this._Time = ""; 
    this._Mar = null;
}
CLASS_Change_Images.prototype.SetData = function(ID,Title,Path)
{
    this._ID = ID;
    this._Title = Title;
    this._Path = Path; 
}
CLASS_Change_Images.prototype.SetCtrl = function(ImgForm,InfoForm)
{
    this._ImgForm = this.Doc.getElementById(ImgForm);
    this._InfoForm = this.Doc.getElementById(InfoForm);
}
CLASS_Change_Images.prototype.SetSpeed = function(k){     
    var t = this._Speed;
    try { 
        t = praseInt(k); 
    } catch(e){}
    this._Speed = 10000;
} 

CLASS_Change_Images.prototype.Stop = function()
{
    if(this._Mar != null)
       clearInterval(this._Mar);
}
CLASS_Change_Images.prototype.Start = function()
{    
    var self = this;    
    
    if(this._ID.length <=0 ) return;
    
    this._Time = this.getTimeNow();
    this.Stop();
    this.StartChange();
    
    this._Mar = setInterval(function(){ self.StartChange();},self._Speed);
    
    var Img = this._ImgForm;
    Img.onclick = function(){  
        self.ShowDetail();  
    }       
    Img.onmouseover = function() {clearInterval(self._Mar)};
    Img.onmouseout = function() {
       self._Mar = setInterval(function(){ self.StartChange();},self._Speed);
    };
    
    if (this._InfoForm == null) return;
    
    var Info = this._InfoForm;
    Info.style.cursor = "hand";
    Info.onclick = function(){  
        self.ShowDetail();  
    }       
    Img.onmouseover = function() {clearInterval(self._Mar)};
    Img.onmouseout = function() {
       self._Mar = setInterval(function(){ self.StartChange();},self._Speed);
    };
}

CLASS_Change_Images.prototype.StartChange = function()
{   
    if(this._ID.length == 0) return ;
    
    this._Step = (this._Step < (this._ID.length - 1)) ? (this._Step + 1):0;
    this.OnChange(this._Step);    
    /*
    var str = "";
    var i = 0;
    for(i = 0;i<this._ID.length;i++)
    {
        str += "\n" + this._ID[i] + " " + this._Path[i];         
    }
    alert(this._Time + " length:" + this._ID.length + " Index:" + this._Step + " pic:" + this._Path[this._Step] + str);
    */
    this.ChangeImage(this._ImgForm,this._ID[this._Step],this._Path[this._Step]);
    this.ChangeTitle(this._InfoForm,this._ID[this._Step],this._Title[this._Step]);
}

CLASS_Change_Images.prototype.ChangeTitle = function(InfoForm,NewID,NewTitle)
{     
    if(InfoForm == null) return;
    InfoForm.innerHTML = NewTitle;
}

CLASS_Change_Images.prototype.ChangeImage = function(ImgForm,NewImageID,NewImagePath)
{
    //Í¼Æ¬½¥±ä    
    ImgForm.style.filter = "blendTrans()";
    if (this.Doc.all){ImgForm.filters.blendTrans.apply();}
    if (this.Doc.all){ImgForm.filters.blendTrans.play();}
    //ImgForm.style.filter = "revealTrans()";    
    //ImgForm.filters.revealTrans.apply();
    //ImgForm.filters.revealTrans.play();
    
    ImgForm.style.cursor = "hand";
    ImgForm.src = NewImagePath;
    
    this._CurID = NewImageID;
        
} 
CLASS_Change_Images.prototype.ShowDetail = function()
{
    this.OnClick(this._CurID);
}     
CLASS_Change_Images.prototype.ShowImageByIndex = function(k)
{   
    if (k > (this._ID.length - 1)) return;    
    this._Step = k - 1;
    this.StartChange();
}
CLASS_Change_Images.prototype.OnClick = function(k)
{
}
CLASS_Change_Images.prototype.OnChange = function(k)
{
}

CLASS_Change_Images.prototype.getTimeNow = function()
{
    var time = new Date()
    var hour = time.getHours()
    var minute = time.getMinutes()
    var second = time.getSeconds()
    return hour + ":" + minute + ":" + second;
}

