// slideShowSpeed (milliseconds)
var slideShowSpeed = 6000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
var Pic = new Array();

Pic[0] = 'images/top/gen_09_lr.jpg';
Pic[1] = 'images/top/gen_11_lr.jpg';
Pic[2] = 'images/top/gen_13_lr.jpg';
Pic[3] = 'images/top/gen_14_lr.jpg';
Pic[4] = 'images/top/gen_15_lr.jpg';
Pic[5] = 'images/top/gen_16_lr.jpg';
Pic[6] = 'images/top/gen_24_lr.jpg';
Pic[7] = 'images/top/gen_28_lr.jpg';
Pic[8] = 'images/top/gen_29_lr.jpg';
Pic[9] = 'images/top/gen_36_lr.jpg';
Pic[10] = 'images/top/gen_42_lr.jpg';
Pic[11] = 'images/top/gen_44_lr.jpg';
Pic[12] = 'images/top/gen_48_lr.jpg';
Pic[13] = 'images/top/gen_49_lr.jpg';
Pic[14] = 'images/top/gen_51_lr.jpg';
Pic[15] = 'images/top/gen_60_lr.jpg';
Pic[16] = 'images/top/gen_64_lr.jpg';
Pic[17] = 'images/top/gen_66_lr.jpg';
Pic[18] = 'images/top/gen_67_lr.jpg';
Pic[19] = 'images/top/gen_78_lr.jpg';
Pic[20] = 'images/top/gen_83_lr.jpg';
Pic[21] = 'images/top/gen_90_lr.jpg';
Pic[22] = 'images/top/gay_03_lr.jpg';
Pic[23] = 'images/top/gay_08_lr.jpg';

var s = 0 ;
var t = 0 ;
var d = 0 ;
var preLoad = new Array();
var p = Pic.length;
var n = Math.random() * p ;
var j = Math.round(n) ;
for (i = 0; i < p; i++) {
	preLoad[i] = new Image();
	preLoad[i].src = Pic[i];
}
stopit1 = new Image();
stopit1.src = 'images/stop1.gif';
stopit2 = new Image();
stopit2.src = 'images/stop2.gif';
stopit3 = new Image();
stopit3.src = 'images/blank.gif';

function runSlideShow() {
	if (s==1) { 
		// break if stopanim
		return ; 
	}
	if (document.cookie.indexOf("noanim=")!=-1) {
		// if noanim cookie
		j1 = j ;
		if (j1 > (p - 1)) { j1 = 0; }
		j2 = j1 + 1 ;
		if (j2 > (p - 1)) { j2 = 0; }
		j3 = j2 + 1 ;
		if (j3 > (p - 1)) { j3 = 0; }
		j4 = j3 + 1 ;
		if (j4 > (p - 1)) { j4 = 0; }
		document.images.stopimg.src = stopit3.src; 
		document.images.stopimg.alt = ""; 
		document.images.stopimg.title = ""; 
		document.images.top1.src = preLoad[j1].src;
		document.images.top2.src = preLoad[j2].src;
		document.images.top3.src = preLoad[j3].src;
		document.images.top4.src = preLoad[j4].src;
		return ;
	}
	else {
		// slideshow
		if (document.all) {
			document.images.top1.style.filter="blendTrans(duration=2)";
			document.images.top1.style.filter="blendTrans(duration=crossFadeDuration)";
			document.images.top1.filters.blendTrans.Apply();
			document.images.top2.style.filter="blendTrans(duration=2)";
			document.images.top2.style.filter="blendTrans(duration=crossFadeDuration)";
			document.images.top2.filters.blendTrans.Apply();
			document.images.top3.style.filter="blendTrans(duration=2)";
			document.images.top3.style.filter="blendTrans(duration=crossFadeDuration)";
			document.images.top3.filters.blendTrans.Apply();
			document.images.top4.style.filter="blendTrans(duration=2)";
			document.images.top4.style.filter="blendTrans(duration=crossFadeDuration)";
			document.images.top4.filters.blendTrans.Apply();
		}
		j1 = j ;
		if (j1 > (p - 1)) { j1 = 0; j = 0 ; }
		j2 = j1 + 1 ;
		if (j2 > (p - 1)) { j2 = 0; }
		j3 = j2 + 1 ;
		if (j3 > (p - 1)) { j3 = 0; }
		j4 = j3 + 1 ;
		if (j4 > (p - 1)) { j4 = 0; }
		document.images.top1.src = preLoad[j1].src;
		document.images.top2.src = preLoad[j2].src;
		document.images.top3.src = preLoad[j3].src;
		document.images.top4.src = preLoad[j4].src;
		d = d + 1 ;
		if ( Math.round(d/2) == d/2 ) {
			d1 = 600 ;
			d2 = 400 ;
			d3 = 200 ;
			d4 = 0 ;
		}
		else {
			d4 = 600 ;
			d3 = 400 ;
			d2 = 200 ;
			d1 = 0 ;
		}
		if (document.all) {
			setTimeout('document.images.top1.filters.blendTrans.Play()',d1);
			setTimeout('document.images.top2.filters.blendTrans.Play()',d2);
			setTimeout('document.images.top3.filters.blendTrans.Play()',d3);
			setTimeout('document.images.top4.filters.blendTrans.Play()',d4)
		}
		j = j + 4;
		t = setTimeout('runSlideShow()', slideShowSpeed);
	}
}

function stopanim() {
	document.cookie = "noanim=1" ;
	document.images.stopimg.src = stopit3.src; 
	document.images.stopimg.alt = ""; 
	document.images.stopimg.title = ""; 
	s = 1 ;
}

function stopover(roll) {
	if(document.images.stopimg.src!=stopit3.src) {
		if(roll==1){
			document.images.stopimg.src = stopit1.src ;
		}
		else {
			document.images.stopimg.src = stopit2.src ;
		}
	}
}