/**
 * 
 */




function SlideShow(){

    this.ID = document.getElementById(arguments[0]);
    this.Parent = document.getElementById(arguments[1]);
	this.inputarry = new Array(arguments[2][0],arguments[2][1],arguments[2][2],arguments[2][3]);
    if (!(this.ID || this.Parent)) {
        alert("您要进行SlideShow的\"" + arguments[0] + "\"初始化错误\r\n请检查ID设置是否正确!");
        this.ID = -1;
        return;
    }
	this.picarry = new Array(arguments[3][0],arguments[3][1],arguments[3][2],arguments[3][3]);
    if (typeof arguments[4] == "number") 
        this.IntTimeStep = arguments[4];
    if (typeof arguments[5] == "number") 
        this.IndexFlag = arguments[5];
    if (typeof arguments[6] == "number") 
        this.DelayTime = arguments[6];
    
    if (this.DelayTime <= 0) 
        this.DelayTime = 5000;
    
    this.curOpacity = 0;
	
	this.timerhandle = null;
    
    this.IsIe = (window.ActiveXObject) ? true : false;
    
    /**
     *
     *change from 5:0.05 to 20:0.2 by GF 080602
     *
     */
    this.IntAlphaStep = (this.IsIe) ? 20 : 0.2;
    
    if (this.IsIe) {
        this.ID.style.cssText += "FILTER: alpha(opacity=100);";
    }
    else {
        this.Parent.style.opacity = 1;
    }
    
    if (arguments.length >= 4) 
        this.Start();
}

SlideShow.prototype.Start = function(){
    if (this.ID == -1) 
        return;
    if (this.IntTimeStep > 1000) 
        this.IntTimeStep = 1000;
    if (this.IndexFlag > 4) 
        this.IndexFlag = 1;
    if (this.DelayTime < 0) 
        this.DelayTime = 500;
    
    var ssobj = this;
    var hrefarry = new Array(this.inputarry[0],this.inputarry[1],this.inputarry[2],this.inputarry[3]);
	var picsarry = new Array(this.picarry[0],this.picarry[1],this.picarry[2],this.picarry[3]);
	var tempobj = document.createElement("img");
	tempobj.style.display = "none";
	tempobj.src = picsarry[1];
    var obj = this.ID;
    var parobj = this.Parent;
    var IF = this.IndexFlag;
	
	if(ssobj.timerhandle){
		clearTimeout(ssobj.timerhandle);
	}
    
    ssobj.Switch = function(){
		
		if(ssobj.IsIe){
			ssobj.ID.filters.alpha.opacity = 0;
		}else{
			ssobj.Parent.style.opacity=0;
			ssobj.curOpacity = 0;
		}
    
        switch (IF) {
            case 1:{
                ssobj.ID.src = picsarry[0];
				ssobj.Parent.href = hrefarry[0];
				tempobj.src = picsarry[1];
                break;
            }
            case 2:{
                ssobj.ID.src = picsarry[1];
				ssobj.Parent.href = hrefarry[1];
				tempobj.src = picsarry[2];
                break;
            }
            case 3:{
                ssobj.ID.src = picsarry[2];
				ssobj.Parent.href = hrefarry[2];
				tempobj.src = picsarry[3];
                break;
            }
            case 4:{
                ssobj.ID.src = picsarry[3];
				ssobj.Parent.href = hrefarry[3];
				tempobj.src = picsarry[0];
                break;
            }
            default:
                {
                    ssobj.ID.src = picsarry[0];
					ssobj.Parent.href = hrefarry[0];
					tempobj.src = picsarry[1];
                    break;
                }
        }
        
        ssobj.setObjOpen();
    }
	
	ssobj.setObjOpen = function(){
		
		if(ssobj.timerhandle){
			clearTimeout(ssobj.timerhandle);
		}
		
		if (ssobj.IsIe) {
            ssobj.ID.filters.alpha.opacity += ssobj.IntAlphaStep;
            if (ssobj.ID.filters.alpha.opacity < 100) {
                ssobj.timerhandle = setTimeout(ssobj.setObjOpen, ssobj.IntTimeStep);
            }
            else {
                ssobj.timerhandle = setTimeout(ssobj.Switch, ssobj.DelayTime);
                if (ssobj.timerhandle) {
                    if (IF++ >= 4) 
                        IF = 1;
                }
            }
        }
        else {
            ssobj.curOpacity += ssobj.IntAlphaStep;
            ssobj.Parent.style.opacity = ssobj.curOpacity;
            if (ssobj.curOpacity < 1) {
                ssobj.timerhandle = setTimeout(ssobj.setObjOpen, ssobj.IntTimeStep);
            }
            else {
                ssobj.timerhandle = setTimeout(ssobj.Switch, ssobj.DelayTime);
                if (ssobj.timerhandle) {
                    if (IF++ >= 4) 
                        IF = 1;
                }
            }
        }
	}
    
    setTimeout(ssobj.Switch, 50);
}
