/*
	<style>
		ul.briask-iss {position:relative;list-style:none;list-style-image:none;margin:0px auto;padding:0px;overflow:hidden;border:none;background:none;}
		ul.briask-iss li {list-style:none;margin:0px;padding:0px;border:none;background:none;}
		ul.briask-iss li a {margin:0px;padding:0px;border:none;background:none;}
		ul.briask-iss li a img {display:none;position:absolute;padding:0px;top:0;left:0;border:none;background:none;}
		ul.briask-iss li img {display:none;position:absolute;top:0;padding:0px;left:0;border:none;background:none;}
	</style>
	<ul id="image-cycle20" class="briask-iss" style="width:700px;height:402px">
		<li><img src="/styles/shopvac/teasers/shop-teaser-1.jpg" alt="" /></li>
		<li><img src="/styles/shopvac/teasers/shop-teaser-2.jpg" alt="" /></li>
		<li><img src="/styles/shopvac/teasers/shop-teaser-3.jpg" alt="" /></li>
		<li><img src="/styles/shopvac/teasers/shop-teaser-4.jpg" alt="" /></li>
	</ul>
	<script type="text/javascript">
		var imageCyclePics20 = [0];
		var imageCycleInstance20 = new imageCycle(20,0,8000,75, imageCyclePics20);
	</script>
*/
function imageCycle(idModule, random, picInterval, transDelay, picArray) {
	this.picRandom = random;
	this.picInterval = picInterval;
	this.transDelay = transDelay;
	this.picArray = picArray;

	this.curPic = 0;
	this.nextPic = 0;
	this.numPics = 0;
	this.curOpacity = 99
	this.nextOpacity = 0;

	this.idModule = idModule;

	this.initISS();
}

imageCycle.prototype.initISS=function() {
	if (!document.getElementById || !document.createElement) return;
	this.picArray[0] = document.getElementById("image-cycle"+this.idModule).getElementsByTagName("img");
	this.numPics = this.picArray[0].length ;
	for(i = 0; i < this.picArray[0].length; i++) {
			this.picArray[0][i].opacity = 0;
			this.picArray[0][i].style.MozOpacity = .0;
			this.picArray[0][i].style.filter = "alpha(opacity=0)";
		}
	if (this.picRandom == 1) { this.issNextPic(); }
	this.picArray[0][this.nextPic].style.display = "block";
	this.picArray[0][this.nextPic].style.opacity = .99;
	this.picArray[0][this.nextPic].style.MozOpacity = .99;
	this.picArray[0][this.nextPic].style.filter = "alpha(opacity=" + (.99*100) + ")";
	setTimeout("imageCycleInstance"+this.idModule+".issShow()", this.picInterval);
}

imageCycle.prototype.issShow=function() {
	this.issNextPic();
	this.curOpacity = 100, this.nextOpacity = 0;
	setTimeout("imageCycleInstance"+this.idModule+".issTransition()", this.transDelay);
}
imageCycle.prototype.issNextPic=function() {
	if (this.picRandom == 0) { if(this.curPic < (this.numPics - 1)) { this.nextPic = this.curPic + 1; } else { this.nextPic = 0; }
	} else { do { now = new Date(); var rndPic = Math.ceil(this.numPics * Math.random(this.idModule)) - 1; } 	while (this.curPic == rndPic) this.nextPic = rndPic; }
}
imageCycle.prototype.issTransition = function () {
	this.picArray[0][this.curPic].style.opacity = this.curOpacity/100;
	this.picArray[0][this.curPic].style.MozOpacity = this.curOpacity/100;
	this.picArray[0][this.curPic].style.filter = "alpha(opacity=" + (this.curOpacity) + ")";
	this.picArray[0][this.nextPic].style.opacity = this.nextOpacity/100;
	this.picArray[0][this.nextPic].style.MozOpacity = this.nextOpacity/100;
	this.picArray[0][this.nextPic].style.filter = "alpha(opacity=" + (this.nextOpacity) + ")";
	this.picArray[0][this.nextPic].style.display = "block";
	if (this.curOpacity > 0) { this.curOpacity -= 4; this.nextOpacity += 4; setTimeout("imageCycleInstance"+this.idModule+".issTransition()", this.transDelay); } else { this.picArray[0][this.curPic].style.display = "none"; this.curPic = this.nextPic; setTimeout("imageCycleInstance"+this.idModule+".issShow()", this.picInterval); }
}