//note - uses external data - imageroll.js - loaded above here
//note - script initiated by body tag onload attribute
//note - uses stylesheet #img_roll
// tjallen
//note - new controls and preloading zone 5-17-2009

//test for IE
var browsertype = "none"
if (navigator.appName == "Microsoft Internet Explorer"){
	browsertype = "IE"}else{}

//load the right filter for IE
function filtImg(){
if (browsertype=="IE"){
	rollimg.style.filter += "progid:DXImageTransform.Microsoft.Pixelate(MaxSquare=6)";}else{}
}

//image roll starting places
var speed = 5000;
var rollimgstatus = 1;
var lastone =  roll.length-1;

//main function
function imageview(){

if(rollimgstatus > (lastone)){rollimgstatus = 0}

if (browsertype=="IE"){
	
	// ie - pixellate
	rollimg.filters[0].apply();
	document.images.rollimg.src = roll[rollimgstatus];
	rollimg.filters[0].play();
	
	calctop = 73 + (rollimgstatus * 34);
	calctop = calctop.toString() + "px";
	timer6a = setTimeout('document.getElementById("indicator").style.top=calctop;',500);
	timer6b = setTimeout('document.getElementById("img_text").innerHTML = rolltext[rollimgstatus];',800);
	timer6b = setTimeout('rollimgstatus = rollimgstatus + 1;',1000);
	
	
	}else{
	// all other browsers - javascript css opacity change
	timer1 = setTimeout('document.images.rollimg.style.opacity=.8;',1);
	timer2 = setTimeout('document.images.rollimg.style.opacity=.6;',100);
	timer3 = setTimeout('document.images.rollimg.style.opacity=.4;',200);
	timer4 = setTimeout('document.images.rollimg.style.opacity=.2;',300);
	timer5 = setTimeout('document.images.rollimg.style.opacity=0;',400);
	
	timer6 = setTimeout('document.images.rollimg.src = roll[rollimgstatus];',450);
	timer6d = setTimeout('document.getElementById("img_text").innerHTML = rolltext[rollimgstatus];',450);
	
	calctop = 82 + (rollimgstatus * 34);
	calctop = calctop.toString() + "px";
	timer6e = setTimeout('document.getElementById("indicator").style.top=calctop;',445);

	timer7 = setTimeout('document.images.rollimg.style.opacity=.2;',500);
	timer8 = setTimeout('document.images.rollimg.style.opacity=.4;',600);
	timer9 = setTimeout('document.images.rollimg.style.opacity=.6;',700);
	timer10 = setTimeout('document.images.rollimg.style.opacity=.8;',800);
	timer11 = setTimeout('document.images.rollimg.style.opacity=1.0;',900);
	
	timer12 = setTimeout('rollimgstatus = rollimgstatus + 1;',1000);

}

myTimer2 = setTimeout("imageview()",speed);
}

//controls
function clicklight(akchun){
if(akchun=="stop"){clearTimeout(myTimer2);stopLight("red");}
if(akchun=="slow"){clearTimeout(myTimer2);stopLight("yellow");speed = 9000;myTimer2 = setTimeout("imageview()",1500);}
if(akchun=="go")  {clearTimeout(myTimer2);stopLight("green"); speed = 5000;myTimer2 = setTimeout("imageview()",100);}

if(akchun=="0"){clearTimeout(myTimer2);stopLight("red");document.images.rollimg.src = roll[0];document.getElementById("img_text").innerHTML = rolltext[0];pointMe(0);rollimgstatus = 1;}
if(akchun=="1"){clearTimeout(myTimer2);stopLight("red");document.images.rollimg.src = roll[1];document.getElementById("img_text").innerHTML = rolltext[1];pointMe(1);rollimgstatus = 2;}
if(akchun=="2"){clearTimeout(myTimer2);stopLight("red");document.images.rollimg.src = roll[2];document.getElementById("img_text").innerHTML = rolltext[2];pointMe(2);rollimgstatus = 3;}
if(akchun=="3"){clearTimeout(myTimer2);stopLight("red");document.images.rollimg.src = roll[3];document.getElementById("img_text").innerHTML = rolltext[3];pointMe(3);rollimgstatus = 4;}
if(akchun=="4"){clearTimeout(myTimer2);stopLight("red");document.images.rollimg.src = roll[4];document.getElementById("img_text").innerHTML = rolltext[4];pointMe(4);rollimgstatus = 5;}
if(akchun=="5"){clearTimeout(myTimer2);stopLight("red");document.images.rollimg.src = roll[5];document.getElementById("img_text").innerHTML = rolltext[5];pointMe(5);rollimgstatus = 0;}
}

function pointMe(where){
calctop = 82 + (where * 34);
if (browsertype=="IE"){calctop = 73 + (where * 34);}
calctop = calctop.toString() + "px";
document.getElementById("indicator").style.top=calctop;
}

function stopLight(color){
if(color=="off")   {document.getElementById("img_roll_light").src="http://sdite.org/images/14.gif";}
if(color=="red")   {document.getElementById("img_roll_light").src="http://sdite.org/images/16.gif";}
if(color=="yellow"){document.getElementById("img_roll_light").src="http://sdite.org/images/17.gif";}
if(color=="green") {document.getElementById("img_roll_light").src="http://sdite.org/images/18.gif";}

}



