var currSS = new Array();
var timerAdvance = 0;
var autoAdvance = 5000;
var slideShows = new Array();

function styleVal(e,p) {
	e=typeof e=='object'?e:$(e);
	return e.currentStyle?e.currentStyle[p]:document.defaultView.getComputedStyle(e,null).getPropertyValue(p)
}

function set(e,a,s,slideshow) {
	e=typeof e=='object'?e:$(e); var o=e.style.opacity||styleVal(e,'opacity'),
	d=a>o*100?1:-1; e.style.opacity=o; clearInterval(e.ai); e.ai=setInterval(function(){tw(e,a,d,s,slideshow)},20)
}

function tw(e,a,d,s,slideshow) {
	var o=Math.round(e.style.opacity*100);
	if (o==a) {
		clearInterval(e.ai);
		var old = document.getElementById('ss'+slideShows[slideshow]+'_pane_'+currSS[slideshow]);
		old.style.zIndex=0;
		currSS[slideshow]=e.num;
	} else {
		var n=o+Math.ceil(Math.abs(a-o)/s)*d; e.style.opacity=n/100; e.style.filter='alpha(opacity='+n+')';
	}
}

function ss_switch(num,slideshow) {
	clearTimeout(timerAdvance);
	if (slideShows.length == 0) slideShows.push('');
	if (!slideshow) slideshow=0;
	if (!currSS[slideshow]) currSS[slideshow] = 0;
	if (num == currSS[slideshow]) return;
	//alert(slideshow+') [ss'+slideShows[slideshow]+'_pane_'+currSS[slideshow]+']');
	var old = document.getElementById('ss'+slideShows[slideshow]+'_pane_'+currSS[slideshow]);
	old.style.zIndex=1;
	var oldlink = document.getElementById('ss'+slideShows[slideshow]+'_link_'+currSS[slideshow]);
	oldlink.className = 'ss_linkoff';
	var newlink = document.getElementById('ss'+slideShows[slideshow]+'_link_'+num);
	newlink.className = 'ss_linkon';
	var e = document.getElementById('ss'+slideShows[slideshow]+'_pane_'+num);
	e.num=num;
	e.style.opacity=0; e.style.filter='alpha(opacity=0)';
	e.style.zIndex=2;
	set(e, 100, 5, slideshow);
	timerAdvance = setTimeout('nextWindow()', autoAdvance);
} 

function nextWindow(num) {
	if (slideShows.length == 0) slideShows.push('');
	for(var i=0; i<slideShows.length; i++) {
		if (!currSS[i]) currSS[i] = 0;
		ss_switch(document.getElementById('ss'+slideShows[i]+'_pane_'+(currSS[i]+1))?currSS[i]+1:0, i);
	}
}

timerAdvance = setTimeout('nextWindow()', autoAdvance);

