  
/**
 * change the opacity for different browsers
 */
function change_opacity(opacity, id) {
  var object = document.getElementById(id).style;
  object.opacity = (opacity / 100);
  object.MozOpacity = (opacity / 100);
  object.KhtmlOpacity = (opacity / 100);
  object.filter = "alpha(opacity=" + opacity + ")";
} 



/**
 * set up the slideshow
 */

function run_slideshow() {
  // preload images
  var images_p = new Array();
  for (i=0; i<document.slideshow_images.length; i++) {
	var image_p = new Image();
    count_p = 0;
    image_p.src = document.slideshow_images[i];
	image_p.onload = check_preload;
	images_p.push(image_p);
  }
}

function check_preload() { 
  count_p++; 
  if (count_p == document.slideshow_images.length) {
    document.slideshow_count = 1;
    setInterval(slideshow_transition, 4500);
  }
}
  
function slideshow_transition() {
  blend_image('slideshow', 'slideshow-image', document.slideshow_images[document.slideshow_count], 1500);
  if (document.slideshow_count == document.slideshow_images.length-1) {
	document.slideshow_count = 0;
  }
  else {
	document.slideshow_count++
  }
}


/**
 * fade into another image
 */
function blend_image(divid, imageid, imagefile, msec) {
  var speed = Math.round(msec/100);
  var timer = 0;

  //set the current image as background
  document.getElementById(divid).style.backgroundImage = 'url(' + document.getElementById(imageid).src + ')';

  //make image transparent
  change_opacity(0, imageid);

  //make new image
  document.getElementById(imageid).src = imagefile;

  //fade in image
  for (i=0; i<=100; i++) {
    setTimeout('change_opacity(' + i + ",'" + imageid + "')", (timer * speed));
    timer++;
  }

}


function follow_link() {
  p = document.slideshow_count == 0 ? document.slideshow_images.length-1 : document.slideshow_count-1;
  //alert(document.slideshow_image_links[p]);
  if (document.slideshow_image_links[p].indexOf('//kiconcerts') > 0 || document.slideshow_image_links[p].indexOf('//www.kiconcerts') > 0) {
    window.location.href = document.slideshow_image_links[p];
  }
  else if (document.slideshow_image_links[p].indexOf('//') > 0) {
    window.open(document.slideshow_image_links[p], 'new');
  }
  return "#";
}

