// JavaScript to fade between images
var img_array=new Array();
img_array[0]="/events/cat112.jpg";
img_array[1]="/events/event2728.jpg";
img_array[2]="/events/event2729.jpg";
img_array[3]="/events/cat94.jpg";

var steps=25;			// How many steps would you like for fading?. Max is 100, min is 1.
var gap=60;			// How long would you like the delay between each frame (in 1/1000 ths of a second)? Min is 1, max should be no more than 10000 (10 seconds).
var show_img_gap=4300;		// How long would you like to show the image for before it starts to fade out again.
var hide_img_gap=60;		// How long would you like to hide the image for before it starts to fade in again.

steps=(steps<1 || steps>100)?15:Math.round(steps);
gap=(gap<1)?75:Math.round(gap);
show_img_gap=(show_img_gap<1)?75:Math.round(show_img_gap);
hide_img_gap=(hide_img_gap<1)?75:Math.round(hide_img_gap);

function controler_of_fade(){

  n=0;
  m=0;
  img_num=0;
  fading="in";
  fade();

}

function fade(){

  document.getElementById("fader").src=img_array[img_num];

  m=Math.round(n/steps*100);

//  m=Math.round(Math.pow((n/steps*Math.pow(100,(1/2))),2));		// Uncomment the beginning of this line for a different fade effect. It will spend more time faded in than faded out.

  document.getElementById("fader").style.filter="alpha(opacity="+m+")";	// IE fade.
  document.getElementById("fader").style.MozOpacity=m/100;		// Gecko fade.
  document.getElementById("fader").style.Opacity=m/100;			// Standards fade.

  n+=(fading=="in")?1:(-1);

  if(n==steps+1){
    n-=2;
    fading="out";
    setTimeout("fade()",show_img_gap);
  }
  else if(n==0){
    fading="in";
    img_num++;
    if(img_num==img_array.length){img_num=0;}
    setTimeout("fade()",hide_img_gap);
  }
  else{
    setTimeout("fade()",gap);
  }

}

