// START WIDGET JS
function clickerer(numer,stopperer) {
	if (numer > $('toter').value) { numer = 1; } // loop back to first image if last image ID reached in automated animation
	var older = parseInt($('curer').value); // grab currently displayed image
	if (numer != older) { // if new image ID is not the same as currently displayed ID
		new Effect.Opacity("pager"+numer, {duration:.25,from:0,to:0.999999}); // fadeIn new image
		if ($('linker'+numer).value != 'window.open("","","");' && $('linker'+numer).value != 'window.location=""') {
			$('banCont2').setAttribute('onclick',$('linker'+numer).value); // reset page link to location of current link
			$('banCont2').style['cursor'] = 'pointer';
		} else {
			$('banCont2').setAttribute('onclick',''); // reset page link to location of current link
			$('banCont2').style['cursor'] = 'default';
		}
		if ($('titler'+numer).value != '') {
			$('banCont2').setAttribute('title',$('titler'+numer).value); // reset page title to location of current link
		} else {
			$('banCont2').setAttribute('title',''); // reset page title to location of current link
		}
		$('curer').value = numer; // reset current image ID to new ID
	}
	if (stopperer == undefined) { // continue automatic loop if stopper variable was not passed by user
		fadeOuter = setTimeout('autoTranser()',speeder); // loop back to fadeOut current image and start loop over
	} else { // if user triggered stopper with click
		// clear all timeouts and timeout variables to stop automation
		clearTimeout(fadeOuter);
		clearTimeout(fadeIner);
		fadeOuter = 0;
		fadeIner = 0;
	}
}

function autoTranser(numer,stopperer) {
	var older = parseInt($('curer').value); // grab currently displayed image ID
	if ((numer != undefined && numer != older) || numer == undefined) { // make sure that same image not clicked on twice in a row
		new Effect.Opacity("pager"+older, {duration:.25,from:1.0,to:0}); // fade current image
	}
	var newNumer = older + 1; // increment image ID for sequential animation
	if (numer == undefined && stopperer == undefined) { // if animation is automatic
		fadeIner = setTimeout('clickerer('+newNumer+')',500); // send sequential image ID to fadeIn
	} else { // if image was chosen by user
		fadeIner = setTimeout('clickerer('+numer+',"true")',500); // send user image ID & stopper variable to fadeIn
	}
}

var speeder = 5000; // speed in miliseconds (1000 = 1s)
var fadeIner = 0; // define fadeIn
var fadeOuter = 0; // define fadeOut
clearTimeout();
clearTimeout(fadeIner);
clearTimeout(fadeOuter);
Event.observe(window, 'load',
	function() {
		var fadeOuter = setTimeout('autoTranser()',speeder); // begin transitions automatically
	}
);
// END WIDGET JS
