$(document).ready(function(){
	
	/*
	FANCYBOX
	*/
	$('#promos .promoset a').fancybox({
		'width':699,'height':423,
		'autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe','overlayColor':'#000','overlayOpacity':'0.8','padding':8
	});
	$("#go-apply").fancybox({
		'width':702,'height':'95%',
		'autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe','overlayColor':'#000','overlayOpacity':'0.8','padding':4
	});
	
	/*
	LOCALBROWSER
	*/
	$('#localbrowser .local-menu a:not(.sel)').live('click',function(){
		new_map = $(this).attr('href').replace('#','');
		$('#localbrowser .local-menu a').removeClass('sel');
		$(this).addClass('sel');
		$('#localbrowser .local-menu .map-arrow').animate({marginLeft:$(this).attr('arrow'),'easing':'easeOutExpo'},'200');
		$('#localbrowser .local-map').fadeOut('500',function(){
			$(this).attr('map',new_map).fadeIn('500');
		});
		$('#block .block-desc:visible').fadeOut('500',function(){
			$('#block .block-desc[map="'+new_map+'"]').fadeIn('500');
		});
		return false;
	});
	
	/*
	TICKER
	*/
	$('#ticker p:not(:first-child)').hide();
	var i=0;
	setInterval(function(){
		$('#ticker p').eq(i).fadeOut(300,function(){
			if($(this).next().html() == null){
				i=0;
				$('#ticker p').eq(i).fadeIn(300);
			}else{
				i++;
				$(this).next().fadeIn(300);
			}
		});
	},3000);
	
	/*
	EVENT SHOW
	*/
	var cur_showcase=0,showcase_int=400;
	$('#event-showcase .event-show').eq(cur_showcase).fadeIn(showcase_int);
	si_showcase = setInterval(function(){
		$('#event-showcase .event-show').eq(cur_showcase).fadeOut(showcase_int,function(){$(this).removeClass('sel')});
		cur_showcase++;
		if(cur_showcase>3) cur_showcase=0;
		$('#page-footer .footer-nav li').removeClass('sel').eq(cur_showcase).addClass('sel');
		$('#event-showcase .event-show').eq(cur_showcase).fadeIn(showcase_int,function(){$(this).addClass('sel')});
	},4000);
	$('#page-footer .footer-nav li').click(function(){
		clearInterval(si_showcase);
		$('#event-showcase .event-show').eq(cur_showcase).fadeOut(showcase_int,function(){$(this).removeClass('sel')});
		$('#event-showcase .event-show').eq($(this).index()).fadeIn(showcase_int,function(){$(this).addClass('sel')});
		$('#page-footer .footer-nav li').removeClass('sel').eq($(this).index()).addClass('sel');
		cur_showcase=$(this).index();
		return false;
	});
});
