// JavaScript Document
// (C) 2002 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header.
// Extended by Federico Calvo


// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 4000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 4;

// Set the relative path to the images

if(!imgPath) var imgPath="images/stages/" 


var Picture = new Array(); // don't change this
var Caption = new Array(); // don't change this
var BrandedPictures = new Array('_ExpressAbandon.jpg','_ExpressBliss.jpg','_ExpressChildhood.jpg','_ExpressImpulse.jpg','_ExpressSeduction.jpg','_ExpressSpirit.jpg','_ExpressVibe.jpg')


// Dynamically create image name array based on NrImg 
// which is defined in the page where the rotator will be used.
for(var i=0;i<NrImg;i++){
	Picture[i] = imgPath+'Image'+(i+1)+'.jpg';	
}

//scramble Image Array
for (n=0;n<NrImg;n++){
	rndNr = (Math.random() * (NrImg-1)) +1
	rndNr = parseInt((rndNr-1),10);
	tmp = Picture[n];
	Picture[n] = Picture[rndNr];
	Picture[rndNr]=tmp;
}
//scramble Branded Images Array
for (s=0;s<BrandedPictures.length;s++){
	rndBNr = (Math.random() * (BrandedPictures.length-1)) +1
	rndBNr = parseInt((rndBNr-1),10);
	tmp = BrandedPictures[s];
	BrandedPictures[s] = BrandedPictures[rndBNr];
	BrandedPictures[rndBNr]=tmp;
}


// =====================================
// Do not edit anything below this line!
// =====================================

var tss;
var iss;
var jss = 0;
var counterBranded = 0;
var overallTotal = NrImg+BrandedPictures.length;
var counterOverall = 0 

var preLoad = new Array();
for (iss = 0; iss < NrImg; iss++){	
	//generate images
	preLoad[iss] = new Image();
	preLoad[iss].src = Picture[iss];
}

function runVisitorsSlideShow(){
	if (document.all){
		document.images.PictureBox.style.filter="blendTrans(duration=2)";
		document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
		document.images.PictureBox.filters.blendTrans.Apply();
	};
		
	if(counterOverall%3==0){
		document.images.PictureBox.src = imgPath+BrandedPictures[counterBranded];
		if (document.all) document.images.PictureBox.filters.blendTrans.Play();
		counterBranded = counterBranded + 1;
		if (counterBranded >= (BrandedPictures.length))	counterBranded=0;
	}else{
		document.images.PictureBox.src = preLoad[jss].src;
		if (document.all) document.images.PictureBox.filters.blendTrans.Play();
		jss = jss + 1;
		if (jss >= (NrImg))	jss=0;
	}
	counterOverall=counterOverall+1;
	if (counterOverall >= (overallTotal))	counterOverall=0;
	tss = setTimeout('runSlideShow()', SlideShowSpeed);
}

function runRegularSlideShow(){
	if (document.all){
		document.images.PictureBox.style.filter="blendTrans(duration=2)";
		document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
		document.images.PictureBox.filters.blendTrans.Apply();
	}
	document.images.PictureBox.src = preLoad[jss].src;
	if (document.all) document.images.PictureBox.filters.blendTrans.Play();
	jss = jss + 1;
	if (jss >= (NrImg))	jss=0;
	tss = setTimeout('runSlideShow()', SlideShowSpeed);
}

function runSlideShow(){
	var url=window.location.toString().toLowerCase();
	if((url.indexOf('/visitors/')>0) || (url.indexOf('/about/')>0) ){
		if((url.indexOf('search')<=0) && (url.indexOf('accommodations.aspx') <= 0) && (url.indexOf('attractions.aspx') <= 0) && (url.indexOf('arts_culture.aspx') <= 0) && (url.indexOf('calendar.aspx') <= 0) && (url.indexOf('dining.aspx') <= 0) && (url.indexOf('familyfun.aspx') <= 0) && (url.indexOf('gay.asp') <= 0) && (url.indexOf('golf.asp') <= 0) && (url.indexOf('neighborhoods.aspx') <= 0) && (url.indexOf('nightlife.aspx') <= 0) && (url.indexOf('onthewater.aspx') <= 0) && (url.indexOf('shopping.aspx') <= 0) && (url.indexOf('spas.aspx') <= 0) && (url.indexOf('sports.aspx') <= 0) && (url.indexOf('tourmiami.aspx') <= 0) && (url.indexOf('transportation.aspx') <= 0) && (url.indexOf('site_map_attractions.asp') <= 0) && (url.indexOf('listings.aspx') <= 0)   ){
			
			runVisitorsSlideShow();
		}
		
	}else{
		runRegularSlideShow();
	}
}
