$(document).ready(function(){
	$('.fancyflash').fancybox();
});
$(document).ready(function(){
	var quickcheckclasses = ['.no','.yes'];
	$('.quickcheck').data('answered',false);
	$('.quickcheck').find('.answer').hide();
	$('.quickcheck').find('input[name^=answer]').change(function(){
		if($(this).parents('ul.quickcheck').find('input[name^=answer]:checked').length===$(this).parents('ul.quickcheck').children('li').length){
			$(this).parents('ul.quickcheck').data('answered',true);
			var yesanswers = 0;
			$('input[name^=answer]:checked').each(function(i,e){
				if($(e).val() == 1) yesanswers++;
			});
			$('#mainly_yes,#mainly_no').hide();
			if(yesanswers >= ($('input[name^=answer]').length*.25)) $('#mainly_yes').fadeIn();
			else $('#mainly_no').fadeIn();
			$.post($(this).parents('form').attr('action'), $(this).parents('form').serialize(), function(data){
			});
		}
		$(this).parents('li').find('.answer').hide();
		$(this).parents('li').find('.answer'+quickcheckclasses[$(this).val()]).slideDown();	
	});
});
$(document).ready(function(){
	if($('#twitfeed').length){
		$('#twitfeed').css({height:100}).addClass('loading');
		jQuery.ajax({
			url: '/index.php?id=38',
			type:"GET",
			dataType: "html",
			complete: function(res, status){
				answer = $('<div>'+res.responseText+'</div>').hide();
				$('#twitfeed').css({height:''}).removeClass('loading').append(answer.fadeIn());
			}
		});
	}
	$('input.form_optional').each(function(i,e){
		if(!$(e).is(':checked')) $(e).parent().next('div.form_optional').hide();
	})
	$('input.form_optional').bind('click',function(){
		if($(this).is(':checked')) $(this).parent().next('div.form_optional').slideDown({queue:false});
		else $(this).parent().next('div.form_optional').slideUp({queue:false});
	})
});
