/**
 * Community.js
 * - requires jQuery
 **/

function Community_answerQuestion(questionId){
	//retrieve user answer
	var answer = $('input[name=question_answer]:checked').val();
	
	if(answer){
		$.post($('#HEADERPATH').val()+'community/index.php',{func:'Community_submitAnswer',Question:questionId,Answer:answer},function(){
			$('#we-want-to-know').load($('#HEADERPATH').val()+'community/index.php',{func:'Community_displayQuestion'},function(){
				Community_setLinks();
				$('#view-results-link').click();
			});
		});
	}
}


function Community_viewResults(questionId){
	$.post($('#HEADERPATH').val()+'community/index.php',{func:'Community_displayResults',Question:questionId},function(d){
		$('#we-want-to-know-results').html(d);
	});
}

$(document).ready(function(){
	Community_setLinks();
	if($('#view-results-link').length>0){
		$('#view-results-link').attr('href','#');
	}
});

function Community_setLinks(){
	$('#view-results-link').colorbox({fixedWidth:'500',fixedHeight:'500',inline:true,href:"#we-want-to-know-results"});
}

