//rotator.js - parsed by php.

function start_rotate(){
 i_c = 0;
 i_n = 0;
 opac = 0;
 imgs = new Array();
 num = imgs.length;
 document.getElementById("top_intro").parentNode.removeChild(document.getElementById("top_intro"));
 if(imgs.length > 0) window.setTimeout("timer_rotate()",5000); //last flash frame
}

function timer_rotate(){
 if(!i_c || imgs.length == 1) i_n = imgs[0];
 else while(i_c == i_n) i_n = imgs[Math.round((num-1)*Math.random())];
 r_sub = document.createElement("img");
 r_sub.id = "r_sub";
 r_sub.src = "assets/events/"+i_n;
 opac = 0;
 opac_set(r_sub);
 document.getElementById("main").appendChild(r_sub);
 if(!i_c){
  r_top = document.createElement("img");
  r_top.id = "r_top";
  r_top.src = "assets/top_home.png";
  document.getElementById("main").appendChild(r_top);
 }
 opac = 100;
 opac_set(r_sub);
 //add nodes (a,img) -2
 if(!i_c) go_rotate();
 else window.setTimeout("go_rotate()",7000); //between rotations
}

function go_rotate(){
 if(opac > 0){
  opac -= 5;
  opac_set(document.getElementById("r_top"));
  window.setTimeout("go_rotate()",10);
 }
 else{
  document.getElementById("r_top").parentNode.removeChild(document.getElementById("r_top"));
  document.getElementById("r_sub").id = "r_top";
  document.getElementById("r_top").onclick=function onclick(event){window.location="events.html?event="+this.src.substring(this.src.lastIndexOf("/")+1,this.src.lastIndexOf("_"))};
  i_c = i_n;
  timer_rotate();
 }
}

function opac_set(img){
 if (img.style.opacity!=null) img.style.opacity = (opac/100) + .001;
 else if (img.style.MozOpacity!=null) img.style.MozOpacity = (opac/100) + .001;
 else if (img.style.filter!=null) img.style.filter = "alpha(opacity="+opac+")";
}