function ImageRotation(id, dir, imgs, cwi, duration, delay) {

	var id = id;
	var dir = dir;
	var imgs = imgs;
	var cwi = cwi;
	var duration = duration;
	var delay = delay;


	this.startRotation = function() {
		preloadImage();
	}

	 var preloadImage = function() {
		if (imgs.length == cwi) {
			cwi = 0;
		}
		var objImage = document.createElement('img');
		objImage.style.display = 'none';
		objImage.setAttribute('id', id+'_ImgRotate_new');
		objImage.style.position = 'absolute';
		objImage.src = dir + imgs[cwi];
		document.getElementById(id).appendChild(objImage);

		rotateImages.delay(delay);

	}

	 var tidyUpImages = function() {
		if (divObj = document.getElementById(id+'_ImgRotate_next')) {
			$(id+'_ImgRotate_current').setAttribute('id', id+'_ImgRotate_old');
			$(id+'_ImgRotate_old').remove();
			divObj.setAttribute('id', id+'_ImgRotate_current');
		}
	}

	var rotateImages = function() {
		$(id + '_ImgRotate_new').setAttribute('id', id + '_ImgRotate_next');
		new Effect.Appear(id+'_ImgRotate_next', {duration: duration});
		new Effect.Fade(id+'_ImgRotate_current', {duration: duration});
		cwi++;
		/*now preload the next*/
		tidyUpImages.delay(duration);
		preloadImage();
	}

}

