// JScript source code
var STP=new Array();   //static show picture time spam
var FTP=new Array();   //fading out time spam
var Tstep=new Array();   //every step time spam
var TotalStep=new Array();  //total steps for one picture
var Trans=new Array();  

var opacityValues = new Array();  //intial the first step, more than 100, igore the transparent 
var maxLinks =new Array();
var startValue = 1;
var cdiv=new Array();
var maxHeight=new Array();
var maxWidth=new Array();

//test feild
//testval=document.getElementById("txtS");  
//testC=document.getElementById("txtC");
isIE = false; 
navVer = navigator.appVersion; 
ver = parseFloat(navVer); 
IEPos = navVer.indexOf('MSIE'); 
	    if (IEPos !=-1) { 
  	        isIE = true; 
  	        ver = parseFloat(navVer.substring(IEPos+5,navVer.indexOf(';',IEPos))); 
	    }
isIE5up = (isIE && ver >= 5);

function jjump(location,numc)
{    
    //alert(numc);
    clearTimeout(Trans[location]);
    if(numc>1){
        cdiv[location]=numc-1;   
    }
    else
    {
        cdiv[location]=maxLinks[location];
    }
    
    for (i=1;i<=maxLinks[location];i++){
          document.getElementById('link' + location +'_'+ i ).style.zIndex = 200-i;
          if(i>cdiv[location])
          {
           setTransparent(i,TotalStep[location],location);
          }
         else
         {
            setTransparent(i,0,location);
         } 
          	                 
    }
    opacityValues[location] = 1 ;
    Trans[location]= setTimeout("nextImage("+cdiv[location] + "," + location +")",Tstep[location]);
} 

function setTransparent(adiv,tVal,location)  //set the transparent of a div
    {
     if(isIE5up){
            document.getElementById('link'+ location + '_'+adiv).filters[0].opacity = tVal;                   
        }else{
            document.getElementById('link'+ location + '_'+adiv).style.MozOpacity = tVal/100;         		   
		    document.getElementById('link'+ location + '_'+adiv).style.opacity  = tVal/100;
		    document.getElementById('link'+ location + '_'+adiv).style.KhtmlOpacity = tVal/100;
        }
    
    }
function isPause(location){
    if(document.getElementById("img" +location + "_pause").src.indexOf("pause_on.gif")>0)
    {
        return true;
    }else
    {
        return false;
    }
}
function jpause(location){
    if(maxLinks[location]==null){return false;}
     clearTimeout(Trans[location]);
    if(isPause(location))
    {
        document.getElementById("img" +location + "_pause").src="images/core/pause.gif"; 
        Trans[location]= setTimeout("nextImage("+cdiv[location] + "," + location +")",Tstep[location]);      
    }
    else
    {       
        document.getElementById("img" +location + "_pause").src="images/core/pause_on.gif";       
    }
}

function jcontinue(location){
        if(maxLinks[location]==null){return false;}
        clearTimeout(Trans[location]);    
        document.getElementById("img" +location + "_pause").src="images/core/pause.gif";         
        Trans[location]= setTimeout("nextImage("+cdiv[location] + "," + location +")",Tstep[location]);
}


	

function jback(location){
    clearTimeout(Trans[location]);   
    document.getElementById('link' + location +'_'+ cdiv[location] ).style.zIndex=200-cdiv[location];
    setTransparent(cdiv[location],100,location);
    if(cdiv[location]>1){
        cdiv[location]=cdiv[location]-1;
        document.getElementById('link' + location +'_'+ cdiv[location]).style.zIndex=200-cdiv[location];
        setTransparent(cdiv[location],100,location);

         opacityValues[location] =TotalStep[location];
    }
    else{      
        cdiv[location]=maxLinks[location]-1;
        opacityValues[location] =1;
    }
   
    //testC.value=opacityValue + "," + cdiv;   
    Trans[location]= setTimeout("nextImage("+cdiv[location]+ "," + location +")",Tstep[location]);
    
}

function jnext(location){
    clearTimeout(Trans[location]);
    setTransparent(cdiv[location],0,location);    
    opacityValues[location] =1 ;     
    Trans[location]= setTimeout("nextImage("+cdiv[location] + "," + location +")",Tstep[location]);
    
}
    
function nextImage(value,location){
    cdiv[location]=value;     
    opacityValues[location] =opacityValues[location] - 1;
    //document.getElementById("txtC").value=value + "," + opacityValues[1] + "," +cdiv[1]; 
    if(opacityValues[location]<= 25){
        setTransparent(value,opacityValues[location]*4,location);			
    }
    
    if (opacityValues[location] == 0){   
        document.getElementById('link' + location +'_'+ value).style.zIndex = 100-value; 
        opacityValues[location] = TotalStep[location]; 
        value= value+1;
        if (value>maxLinks[location]){
        value=1;            
        }
        cdiv[location]=value;
        if (value==1){
            for (i=1;i<=maxLinks[location];i++){
                 document.getElementById('link' + location +'_'+ i ).style.zIndex = 200-i;
                 setTransparent(i,100,location);	
                 
            }
        }
        if (value==maxLinks[location]){   
            //alert(value);         
            for (i=1;i<maxLinks[location];i++){
                document.getElementById('link' + location +'_'+ i ).style.zIndex = 100-i;
                               
             }
             setTransparent(1,100,location); 
        }        
		
		
	}
    if(!isPause(location))
    {
	    Trans[location]= setTimeout("nextImage("+value + "," + location +")",Tstep[location]);
	}
}
   function startFad(location,STPvalue, FTPvalue){
        clearTimeout(Trans[location]);
        //alert(location+ "," + STPvalue + "," + FTPvalue);
        maxHeight[location]=0;
        STP[location]=STPvalue;
        FTP[location]=FTPvalue;
        Tstep[location]=FTP[location]/25;  //every step time spam
        TotalStep[location]=(FTP[location]+STP[location])/Tstep[location];  //total steps for one picture
        cdiv[location]=0;   
        opacityValues[location] = TotalStep[location];     
        maxLinks[location]=document.getElementById(location + "_maxval").value;
        for(i=1;i<=maxLinks[location];i++){
            if(document.getElementById('link' + location +'_'+ i).offsetHeight>maxHeight[location])
            {
            maxHeight[location]=document.getElementById('link' + location +'_'+ i).offsetHeight;
            maxWidth[location]=document.getElementById('link' + location +'_'+ i).offsetWidth;
            }
        }
        for(i=1;i<=maxLinks[location];i++){
            if(location==1)
            {
            document.getElementById('link' + location +'_'+ i).style.height=maxHeight[location]+ "px";
            }
            else
            {
            document.getElementById('link' + location +'_'+ i).style.height="300px";
            }
            //alert(document.getElementById('link' + location +'_'+ i).style.height);
        }
        if(document.getElementById('num' + location +'_bar')!=null)
        {
            document.getElementById('num' + location +'_bar').style.width=maxLinks[location]*35 + "px";
        }
        
        Trans[location]= setTimeout("nextImage("+startValue + "," + location + ")",Tstep[location]);
       
    }
