﻿var hrotate_elems = [];
var hrotate_index = 0;

function hrotate_init() {
	var i=0;
	for (var i=0; i< $('hrotate').childNodes.length;i++) {
		var elem = $('hrotate').childNodes[i];
		if (typeof elem.style != 'undefined' && typeof elem.src != 'undefined') {
			hrotate_elems.push(elem);
		}
	}
	if (hrotate_elems.length > 1) setInterval(hrotate_next, 4000);
}

function hrotate_next() {
	Effect.Fade(hrotate_elems[hrotate_index], { duration: 2.0 });
	hrotate_index = (hrotate_index+1) % hrotate_elems.length;
	Effect.Appear(hrotate_elems[hrotate_index], { duration: 2.0 });
}

var newsflash_index = 0;
var newsflash_max = 0;

function load() {
	hrotate_init();
	var nf = $('newsflash');
	if (nf != null) {
		newsflash_max = nf.childNodes.length;
		if (newsflash_max > 1) {
			setInterval(newsflash_next, 5000);
			while (typeof nf.childNodes[newsflash_index].style == 'undefined') {
				newsflash_index = (newsflash_index+1) % newsflash_max;
			}
		}
	}
}

function newsflash_next() {
	var nf = $('newsflash');
	new Effect.Fade(nf.childNodes[newsflash_index]);
	do {
		newsflash_index = (newsflash_index+1) % newsflash_max;
	} while (typeof nf.childNodes[newsflash_index].style == 'undefined');
	Effect.Appear(nf.childNodes[newsflash_index], { delay: 0.5 });
	// Effect.Pulsate(nf.childNodes[newsflash_index], { pulses: 1, duration: 0.5, from: 0.5 });
}

Shadowbox.init();

