 
function initImages(sets, pics, path, name) {
  var pic = getImages();
  var today = new Date();
  var month = today.getMonth() + 1;
  var set = (month % sets) + 1;

  if (month == 5){
	  name = "month";
	  set = month;
  }
  for(i=0; i<pic.length; i++) {
     imgObj = document.getElementById(pic[i]);
     no = (set * 10) + i + 1;
     imgObj.src = path + name + no + ".jpg";
        setOpacity(imgObj, 0);
        imgObj.style.visibility = "visible";
  }

  imgObj = document.getElementById("imageLoad");
  if (imgObj != null){
	  imgObj.style.visibility = "hidden";
  }

  fade(pic[0], 0, "", 100);
  setTimeout("nextImage(0)", 5*1000);
}

function nextImage(imageIndex) {
  var pic = getImages();
  
  idOut = pic[imageIndex];
  imageIndex++;
  if (imageIndex > pic.length - 1) {
    imageIndex = 0;
  }
  idIn = pic[imageIndex];

  fade(idIn, 0, idOut, 100);
  setTimeout("nextImage("+imageIndex+")", 6*1000);
}

function fade(idIn, opacityIn, idOut, opacityOut) {
        objIn = document.getElementById(idIn);
        objOut = document.getElementById(idOut);
		if (opacityIn <= 100) {
			setOpacity(objIn, opacityIn);
			if (objOut != null){
			   setOpacity(objOut, opacityOut);
			}
			opacityIn += 5;
			opacityOut -= 5;
			window.setTimeout("fade('"+idIn+"', "+opacityIn+", '"+idOut+"', "+opacityOut+")", 100);
		} 
}
function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

