// JavaScript Document
function roll_pic(pic, linkurl,title) { 
this.pic = pic; 
this.linkurl = linkurl; 
this.title = title;
this.icon=null;
this.image = new Image()
this.image.src =  pic;
};

var roll_pics = new Array();

var roll_pic_img;   
var roll_pic_link;   
var roll_pic_title;

var theTimer = null;   
var curNum = 0;   
var isIE = navigator.userAgent.toUpperCase().indexOf("MSIE") > 0;
if (isIE){
	isIE = navigator.userAgent.toUpperCase().indexOf("MSIE 6.0") < 0;
}
var opa;   
var opaTimer = null;   
var lastNum=0;
  
function start(){  
	roll_pic_img = document.getElementById("r_img");
	roll_pic_link = document.getElementById("r_link");   
	roll_pic_title = document.getElementById("r_title"); 
	roll_pic_list  = document.getElementById("r_list");
	str_list = "";
	for(i=0; i<roll_pics.length; i++){
		str_list += "<a href=# onmouseover='javascript:nextPic("+i+");'>"+(i+1)+"</a>";
	}
	roll_pic_list.innerHTML = str_list;
	
	icons = roll_pic_list.getElementsByTagName("A");
	for(i=0; i<icons.length; i++){
		roll_pics[i].icon = icons[i];
	}

    play(); 
}   


       
function playEffect(){    
    if (isIE){    
        roll_pic_img.filters[0].apply();    
        roll_pic_img.filters[0].play();   
    } else {   
        opa = 0.3;   
        roll_pic_img.style.opacity = opa;   
        clearInterval(opaTimer);   
        opaTimer = setInterval("changeOpacity()",60);   
    }   
}   
  
function changeOpacity(){   
    if(opa < 1){   
        opa += 0.1;   
    }   
    roll_pic_img.style.opacity = opa;   
}   
  
function changePic(){   
    clearTimeout(theTimer);   
    curNum = 100;   
    nextPic();   
}   
  
function nextPic(n){

	clearTimeout(theTimer);
	lastNum = curNum;
	if (isNaN(n)){
		curNum =curNum+1;
		if (curNum>=roll_pics.length){
			curNum=0;
		}
	}else{
		if(curNum==n){
			return;
			}
		curNum =n;
	}
    playEffect();   
    play(curNum);   
}    
  
function play(n){  
	
    if(!n) n = 0;   
    roll_pic_img.src = roll_pics[n].image.src;
	roll_pic_link.target = "_blank";
	roll_pic_link.href = roll_pics[n].linkurl;
	if (roll_pics[n].linkurl == "" || roll_pics[n].linkurl == "#"){
		roll_pic_link.target = "_self";
	}
	roll_pic_title.innerHTML = roll_pics[n].title;
	roll_pics[lastNum].icon.className="";
	
	roll_pics[n].icon.className="on";
	roll_pic_img.style.display = "";  
    theTimer = setTimeout("nextPic()",3000);   
}   


