var currentimg = 1;
var numimages = 3;
function fadein(img_num) {
  var theObj = document.getElementById('img'+img_num);
	theObj.alpha = 0;
	theObj.style.opacity = 0.0;
	theObj.style.filter = 'alpha(opacity=0)';
  theObj.style.display = 'block';
	fadein2(img_num);
}
function fadein2(img_num) {
	var theObj = document.getElementById('img'+img_num);
	var value = theObj.alpha + 2;
	theObj.alpha = value;
	theObj.style.opacity = (value / 100);
	theObj.style.filter = 'alpha(opacity='+value+')';
	if (value < 99) {
		setTimeout('fadein2("'+img_num+'")', 40);
	}
  else {
    setTimeout('switchimg()', 4000);
    currentimg = currentimg % numimages + 1;
  }
}
function fadeout(img_num) {
	var theObj = document.getElementById('img'+img_num);
	theObj.alpha = 100;
	theObj.style.opacity = 1.0;
	theObj.style.filter = 'alpha(opacity=100)';
	fadeout2(img_num);
}
function fadeout2(img_num) {
	var theObj = document.getElementById('img'+img_num);
	var value = theObj.alpha - 2;
	theObj.alpha = value;
	theObj.style.opacity = (value / 100);
	theObj.style.filter = 'alpha(opacity='+value+')';
	if (value > 1) {
		setTimeout('fadeout2("'+img_num+'")', 40);
	}
}
function switchimg() {
  var nextimg = currentimg % numimages + 1;
  fadeout(currentimg);
  fadein(nextimg);
}
function msieinit(num) {
  numimages = num;
	var obj = document.getElementById('img1');
	obj.alpha = 100;
	obj.style.filter = 'alpha(opacity=100)';
  for (i=2; i<=num; i++) {
    obj = document.getElementById('img'+i);
    obj.alpha = 0;
    obj.style.filter = 'alpha(opacity=0)';
  }
  
  setTimeout('switchimg()', 4000);
}

