$(document).ready(function() {
	$('#what #faqOverlay, #what #faq #faqText, #becomeASponsor, #becomeASponsor .text').hover(function() {
		$('#what #faqOverlay').animate({opacity: 0.2}, 250);
	}, function() {
		$('#what #faqOverlay').animate({opacity: 0}, 250);
	})
	
	$('#becomeASponsor, #becomeASponsor .text').hover(function() {
		$('#becomeASponsor #overlay').animate({opacity: 0.2}, 250);
	}, function() {
		$('#becomeASponsor #overlay').animate({opacity: 0}, 250);
	})
	
	// crossfade images FAQ section
	var timer = setInterval(fadeImage, 5000);
	var images = 3;
	var src = 'images/faq/faq_';
	
	function fadeImage() {
		var prevImage = $('#faq img').attr('src');
		prevImage = parseFloat(prevImage.substr(-5, 1));
		
		if(prevImage >= images) prevImage = 0;
		prevImage = prevImage + 1;
		
		var nextImage = '<img src="' + src + parseInt(prevImage) + '.jpg" />';
		
		// create new image
		$(nextImage).insertAfter($('#faq img').eq(0)).hide();
		
		// fade out last image
		$('#faq img').eq(0).fadeOut(2000, function() {
			$(this).remove();
		});
		$('#faq img').eq(1).fadeIn(2000);
	}
	
	// schedule sections
	$('.session .info').hide();
	$('.session').click(function() {
		if($(this).children('.title').hasClass('open')) {
			$(this).children('.title').removeClass('open');
		} else {
			$(this).children('.title').addClass('open');
		}
		$(this).children('.info').slideToggle();
	});
	
	if($.browser.mozilla) { 
		bodyelem = $("body, html");
	} else{ 
		bodyelem = $("body");
	}
			
	// menu
	$('a[href^="#"]').click(function(event) {
		var pos = parseInt($($(this).attr('href')).position().top);
		
		$("body, html, document").animate({scrollTop: pos}, 'slow');
		
		event.preventDefault();
	});
	
	// faq
	$('#faqList').toggle();
	$('#readFAQ').click(function(event) {
		//$('#faqList').css('height', $('#faqList').height() + 'px');
		
		//var pos = $("body, html, document").scrollTop();
		
		$('#faqList').slideToggle('slow');
		
		event.preventDefault();
	});
})
