// This script uses scriptaculous & prototype libraries to fade between multiple divs.
//include both lines below for it to work:

/*<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js"></script>*/


// this array consists of the id attributes of the divs we wish to alternate between
var bannerIDs_to_fade = new Array("bg1", "bg2", "bg3", "bg4", "bg5");
/*var titleIDs_to_fade = new Array('title1', 'title2', "title3", "title4");
var bodyIDs_to_fade = new Array('body1', 'body2', "body3", "body4");*/

var treatmentIDs_to_fade = new Array("sidestory1", "sidestory2", "sidestory3", "sidestory4", "sidestory5", "sidestory6");

var banner_array_length = 5;
/*var title_array_length = 4;
var body_array_length = 4;*/
var treatment_array_length = 6;

// the number of seconds between swaps.  Default is five seconds.
var seconds = 6;
wait = seconds * 1000;//milliseconds

// the starting index in the above array.  It should be set to the value of the div which doesn't have the CSS Display property set to "none"
var i = 0;
/*var j = 0;
var k = 0;*/

//how much to dim the text 0.0 - 1.0
//var dimAmt = 0.4;

// the function that performs the fade
//-------------------------------------------------------------------------------------------

function swapFade_plus() {
        Effect.Fade(bannerIDs_to_fade[i], { duration:1, from:1.0, to:0.0 });
				Effect.Fade(titleIDs_to_fade[j], { duration:1, from:1.0, to:0.0 });
				Effect.Fade(bodyIDs_to_fade[k], { duration:1, from:1.0, to:dimAmt });
				i++;
				if (i == banner_array_length) i = 0;
				j++;
				if (j == title_array_length) j = 0;
				k++;
        if (k == body_array_length) k = 0;
				Effect.Appear(bannerIDs_to_fade[i], { duration:1, from:0.0, to:1.0 });
        Effect.Appear(titleIDs_to_fade[j], { duration:1, from:0.0, to:1.0 });
				Effect.Appear(bodyIDs_to_fade[k], { duration:1, from:dimAmt, to:1.0 });
}
//-------------------------------------------------------------------------------------------

function swapFade() {
        Effect.Fade(bannerIDs_to_fade[i], { duration:1, from:1.0, to:0.0 });
				i++;
				if (i == banner_array_length) i = 0;
				Effect.Appear(bannerIDs_to_fade[i], { duration:1, from:0.0, to:1.0 });
}
//-------------------------------------------------------------------------------------------

function swapTreatments() {
        Effect.Fade(treatmentIDs_to_fade[i], { duration:1, from:1.0, to:0.0 });
				i++;
				if (i == treatment_array_length) i = 0;
				Effect.Appear(treatmentIDs_to_fade[i], { duration:1, from:0.0, to:1.0 });
}
//-------------------------------------------------------------------------------------------


/*function swapFade_IE() {
        Effect.Fade(bannerIDs_to_fade[i], { duration:1, from:1.0, to:0.0 });
				Effect.Fade(titleIDs_to_fade[j], { duration:1, from:1.0, to:0.0 });
				i++;
				if (i == banner_array_length) i = 0;
				j++;
				if (j == title_array_length) j = 0;
				Effect.Appear(bannerIDs_to_fade[i], { duration:1, from:0.0, to:1.0 });
        Effect.Appear(titleIDs_to_fade[j], { duration:1, from:0.0, to:1.0 });
}*/

//-------------------------------------------------------------------------------------------

var LangIDs_to_fade = new Array("EN", "FR", "DE", "ES");
var lang_array_length = 4;

var lang_wait = 1000 * 3.75;
Lang_interval = 0;

function swapLangs() {
        Effect.Fade(LangIDs_to_fade[Lang_interval], { duration:0.2, from:1.0, to:0.0 });
				Lang_interval++;
				if (Lang_interval == lang_array_length) Lang_interval = 0;
				Effect.Appear(LangIDs_to_fade[Lang_interval], { duration:0.2, from:0.0, to:1.0 });
}




//-------------------------------------------------------------------------------------------
//EXECUTE:

setInterval('swapFade()', wait);
setInterval('swapLangs()', lang_wait);
setInterval('swapTreatments()', wait);
