
function setupConfSlideshow() {
	var obj = {
		wait: 3000, 
		effect: 'fade',
		duration: 1000, 
		loop: true, 
		thumbnails: true,
		backgroundSlider: true,
		onClick: function(i){}
	}
	show = new SlideShow('slideshowContainer','slideshowThumbnail',obj);
	show.play();
}

function setupConfLinks() {

	var i = 0;	
	var divs = $( "conference" ).getElementsByTagName( "div" );
	for ( i = 0; i < divs.length; i++ ) {
		if ( divs[i].id.match( /conf[0-9]{4}/ ) ) {
			if ( isVisible( divs[i] ) ) {
				window.curView = divs[i].id.replace( "conf", "" );
				break;
			}
		}
	}

	var dt = new Date();
	var uls = getElement( "conference" ).getElementsByTagName( "ul" );
	for ( i = 0; i < uls.length; i++ ) {
		if ( hasElementClass( uls[i], "boxlinks" ) ) {
			var as = uls[i].getElementsByTagName( "a" );
			for ( var j = 0; j < as.length; j++ ) {
				as[j].onclick = function() {
					return showView( this.rel );
				}
			}
		} else if ( hasElementClass( uls[i], "controls" ) ) {
			var elem = uls[i].getElementsByTagName( "li" )[0];
			if ( elem == null )
				console.debug("couldn't find empty li");
			var li = document.createElement( "li" );
			var link = document.createElement( "a" );
			link.href = "javascript: void(0);";
			link.onclick = function() {
				show.play();
				return false;
			};
			link.appendChild( document.createTextNode( "Play" ) );
			li.appendChild( link );
			uls[i].replaceChild( li, elem );

			li = document.createElement( "li" );
			link = document.createElement( "a" );
			link.href = "javascript: void(0);";
			link.onclick = function() {
				show.stop();
				return false;
			};
			link.appendChild( document.createTextNode( "Stop" ) );
			li.appendChild( link );
			uls[i].appendChild( li );

			li = document.createElement( "li" );
			link = document.createElement( "a" );
			link.href = "javascript: void(0);";
			link.onclick = function() {
				show.previous();
				return false;
			};
			link.appendChild( document.createTextNode( "Previous" ) );
			li.appendChild( link );
			uls[i].appendChild( li );

			li = document.createElement( "li" );
			link = document.createElement( "a" );
			link.href = "javascript: void(0);";
			link.onclick = function() {
				show.next();
				return false;
			};
			link.appendChild( document.createTextNode( "Next" ) );
			li.appendChild( link );
			uls[i].appendChild( li );
		}
	}
}

window.initFuncs.push( setupConfLinks );
window.initFuncs.push( setupConfSlideshow );

function showView( which ) {
	var elem = getElement( "conf" + curView );
	if ( elem != null )
		setVisible( elem, false );

	curView = which;

	elem = getElement( "conf" + curView );
	if ( elem != null )
		setVisible( elem, true );
	return false;
}