function myPPT(id)
{
    this._id=id;
    
    this._mainImageID = this._id + "_mainImage"; 
    this._mainLinkID = this._id + "_mainLink"; 
    this._mainTextID = this._id + "_Text";
      
    this._listID = this._id + "_List";
    
    
    this._currentIndex = $(this._id + "_h_currentIndex").value;  
	this._timer = $(this._id + "_h_timer").value;
	
	this._arrImgs= $(this._id + "_h_imgURLs").value.split("|-|");
	this._arrUrls= $(this._id + "_h_linkURLs").value.split("|-|");
	this._arrTexts= $(this._id + "_h_linkTexts").value.split("|-|");
	
	
	this._itemCount = 4;
	this._timeDuration = 3;  // 自动切换时间，秒为单位。0为不自动切换。
	this._isPause = $(this._id + "_h_pause").value;   // 是否处于暂停状态（鼠标悬停可考虑暂停）
	this._isTransition = isIE;
	
	this.setTimer = function(strTime) {$(this._id + "_h_timer").value=strTime;}
	this.setPausse = function(isPause) {$(this._id + "_h_pause").value=isPause;}
	this.setIndex = function(nextIndex) {$(this._id + "_h_currentIndex").value=nextIndex;}
	this.setTextLink = function(text,link){ $(this._mainTextID).href=link;$(this._mainTextID).innerHTML=text;}
	
	
	this.swich = function(index)
	{
	    var img=$(this._mainImageID);
	    
	    if(isIE)
	    {	    
	        // 随机选择样式切换方式
	        var now=new Date(); 
	        var rndNumber = now.getSeconds() % 23;
	
            img.filters.item(0).Transition=rndNumber;
            img.filters.item(0).Apply();
        }
 
	    if(index==0)  // 自动切换
	    {
	        //检查是否暂停中
	        if(this._isPause == "true") return;
	        
	        // 检查时间
	        
	        var timeMark;
	        timeMark = Date.parse(this._timer);
	        var curTime = new Date();
	        
	        if((curTime-timeMark) < (this._timeDuration*1000) ) return;
	        
	        // 检查序列
	        index=this._currentIndex.valueOf();
	        if(index > this._itemCount.valueOf()) index = 1;
	        

	    }
	    
	        // 更换图片及其链接
	        img.src = this._arrImgs[index-1];
	        $(this._mainLinkID).href = this._arrUrls[index-1];
	        
	        // 更换下方文字及链接
	        $(this._mainTextID).href = this._arrUrls[index-1];
	        $(this._mainTextID).innerHTML =  this._arrTexts[index-1];
	        
	        
	        this.setTimer((new Date).toString());    // 设置时间
	        this.setTextLink(this._arrTexts[index-1],this._arrUrls[index-1]);
	        

	        if(isIE) img.filters.item(0).Play();
	    
	    	
	    // 设置图片列表样式
	    
	    // 设置时间
	    this.setTimer((new Date()).toString());// 设置时间
	    
	    
	    // 设置当前序号
	    index++;
	    this.setIndex(index);
	    
	    
	}
	
	this.init = function()    // 初始化
	{   
	    this.setTimer((new Date()).toString());// 设置时间
	    
	    // 设置列表图片
	    for(var i=0; i<4;i++)
	    {
	        var a = document.createElement("A");
	        a.href="javascript:pptImageSwith(" + (i+1).toString() + ");"
	        
	        var smallImg = document.createElement("img");
	        smallImg.src = this._arrImgs[i];
	        
	        a.appendChild(smallImg);
	        
	        $(this._listID).appendChild(a);
	    }
	}
}


function pptImageSwith(index)
{
    var iPPT=new myPPT("ppt1");
    iPPT.swich(index);
}


