$(document).ready(function() {
	$("#reactieErrorMsg").hide();
	$("#reactieSuccesMsg").hide();
});

function AddReactie(sModule, sID) {

	$("#naam").attr('disabled','disabled');
	$("#bericht").attr('disabled','disabled');
	$("#submit").attr('disabled','disabled');
	
	bodyContent = $.ajax({
		url: documentRoot + "task/ajax/reacties.php",
		global: false,
		type: "POST",
		data: ({
			module: sModule,
			gid: sID,
			bericht: $('#bericht').val(),
			naam: $('#naam').val()			
			}),
		dataType: "json",
		async:false,
		success: function(json){
			
			if(json.succes=='true') {
				$("#reactieSuccesMsg").html(json.message);
				
				$("#addreactiehier").append(''
				+'<div class="reactie" id="this_add_'+json.item.grid+'">'
				+'	<div class="userinfo">'
				+'		<img src="'+documentRoot+'cmsstorage/images/leden/thumbs_medium/'+json.item.l_afbeelding+'" alt="'+json.item.gr_naam+'" title="'+json.item.gr_naam+'" width="100px" /> <br />'
				+'		'+json.item.gr_link+''
				+'	</div>'
				+'	<div class="reactiecontent">'
				+'		<div class="reactie_header">Een paar seconden geleden geplaatst</div>'
				+'		<div class="reactie_inhoud">'+json.item.gr_inhoud+'</div>'
				+'	</div>'
				+'</div>');				
				
				$('#this_add_'+json.item.grid).hide();
				$('#this_add_'+json.item.grid).show('slow');
				
				$("#reactieErrorMsg").hide();
				$("#reactieSuccesMsg").show('slow');
			}
			else {
				$("#naam").attr('disabled','');
				$("#bericht").attr('disabled','');
				$("#submit").attr('disabled','');
			
				$("#reactieErrorMsg").html(json.message);
				$("#reactieErrorMsg").show('slow');
				$("#reactieSuccesMsg").hide();
			}
		}
	}).responseText;
	
	return false;
}

function AddBeoordeling(sModule, sID, score) {
	
	bodyContent = $.ajax({
		url: documentRoot + "task/ajax/reacties.php",
		global: false,
		type: "POST",
		data: ({
			module: sModule,
			gid: sID,
			score: score			
			}),
		dataType: "json",
		async: false,
		success: function(json){
			
			if(json.succes=='true') {
				$("#youtuberating").html('<ul class="rating '+json.message+'star"></ul>');
			}
			else {
				//$("#youtuberating").html('<ul class="rating '+json.message+'star"></ul>');
			}
		}
	}).responseText;
	
	return false;
}
