var slides;

window.addEvent('domready', function(){
	
	$(document.body).removeClass('noscript');
								
	Cufon.replace($$('#mainnav li a'), {hover: true});
	Cufon.replace($$('#subnav li a'), {hover: true});
	Cufon.replace($$('#content h2'));
	Cufon.replace($$('#viewer h2'));


	if($('sponsors_list') != null){
		var pagination_sponsors = $$('.pagination-sponsors li');
		var news = new noobSlide({
		    box: $('sponsors_list'),
			items: $$('#sponsors_list li'),
			size: 381,
			interval: 5000,
			autoPlay: true,
			mode: 'vertical',
			handles: pagination_sponsors,
			onWalk: function(currentItem,currentHandle){
				$$(this.handles).removeClass('active');
				$$(currentHandle).addClass('active');
			}
		});
		var sponsors = $$('div.sponsors');
	    sponsors.addEvent('mouseenter', function(event){news.stop();});
	    sponsors.addEvent('mouseleave', function(event){news.play(5000,'next',true);});

		/*news.addHandleButtons(pagination_sponsors);*/
		/* news.walk(0); */
	}	
	
	if($('downloads_list') != null){
	    var pagination_downloads = $$('#pagination-downloads li');
	    var downloads = new noobSlide({
			box: $('downloads_list'),
			items: $$('#downloads_list li .row'),
			size: 137,
			interval: 5000,
			autoPlay: false,
			mode: 'vertical',
			handles: pagination_downloads,
			onWalk: function(currentItem,currentHandle){
				$$(this.handles).removeClass('active');
				$$(currentHandle).addClass('active');
			}
		});
		/*downloads.addHandleButtons(pagination_downloads);*/
		/* downloads.walk(0); */
	}
	
	if($('future_conventions_list') != null){
		var pagination_conventions = $$('#pagination_conventions li');
		var futconv = new noobSlide({
			box: $('future_conventions_list'),
			items: $$('#future_conventions_list li'),
			size: 167,
			interval: 5000,
			autoPlay: false,
			mode: 'vertical',
			handles: pagination_conventions,
			onWalk: function(currentItem,currentHandle){
				$$(this.handles).removeClass('active');
				$$(currentHandle).addClass('active');
			}
		});
		/*futconv.addHandleButtons(pagination_conventions);*/
		/* futconv.walk(0); */
	}

/* tabbed table code */
	if ($$('ul .tabs') != null) {
	    var current; var tabs = $$('ul.tabs li');
	    tabs.each(function(tab, i){
		    tab.content = $(tab.getProperty('id')+"_content");
		    tab.disable = function(){tab.removeClass('active');tab.content.removeClass('active');}
		    tab.enable = function(){tab.addClass('active');tab.content.addClass('active');}
		    /* tab.getElement('a').removeProperty('href'); */
		    tab.addEvent('click', function(event){current.disable();tab.enable();current=tab;return false;});
		    if(tab.hasClass('active')) {current=tab;}
	    });
	}

	
	if($('viewer') != null){
		if($('fl_intro') != null || $('fl_intro_singapore') != null){
			slides = new viewer($$('#viewer div.viewer_slides img'),{mode:'alpha'});
		//	slides.play();	
		}
	}
	if($('fl_intro') != null){
		var fl = new Swiff('themes/birconv/bir_event_intro.swf', {container: $('fl_intro'), id:'fl_intro_swf', width: 960,height: 676, params: {wmode: 'transparent'}});
	}
	if($('fl_intro_singapore') != null){
		var fl = new Swiff('themes/birconv/bir_singapore_intro.swf', {container: $('fl_intro_singapore'), id:'fl_intro_swf', width: 960,height: 676, params: {wmode: 'transparent'}});
	}
	if($('fl_intro_munich') != null){
		var fl = new Swiff('themes/birconv/bir_munich_intro.swf', {container: $('fl_intro_munich'), id:'fl_intro_swf', width: 940,height: 354, params: {wmode: 'transparent'}});
	}
	if($('fl_intro_rome') != null){
		var fl = new Swiff('themes/birconv/bir_rome_intro.swf', {container: $('fl_intro_rome'), id:'fl_intro_swf', width: 940,height: 354, params: {wmode: 'transparent'}});
	}
	SqueezeBox.initialize();
	SqueezeBox.assign($$('a[rel=boxed]'), {
		size: {x: 500, y: 500}
	});
/*	SqueezeBox.assign($$('a[rel=boxed]'), {
	    size: {x: 425, y: 349},
			     ajaxOptions: {
				 method: 'get' // we use GET for requesting plain HTML (you can skip it, it is the default value)
			     }
	}); */
	
	
});
function onNext(){slides.next();}
function onPrevious(){slides.previous();}

// FLASH INTRO CALLBACKS
function onIntroReady(){
	// Hide Flash intro
	if($('fl_intro_singapore') != null){
		$('fl_intro_singapore').setStyles({height:'390px' , overflow: 'hidden'});
	}
	if($('fl_intro_munich') != null){
		$('fl_intro_munich').setStyles({height:'390px' , overflow: 'hidden'});
	}
	// Start slides
	slides.play();
}

