
function hansapostPoll(webFormId) {
	$.ajax({
		type: 'get',
		url: context + '/poll/' + jawexSessionPath,
		data:{
			webFormId: webFormId
		},
		success: function(data) {
			if(data.success == true) {
				var hansapostPoll = document.getElementById('hansapostPoll');
				hansapostPoll.innerHTML = data.data;
				
				$('#hansapostPollForm ul li input').change(function(){
					removeTipsyError('#hansapostPollForm');
				});
			} else {
				$('#hansapostPoll').parent().remove();
			}
		}
	});
}

function hansapostPollAnswer(webFormId) {
	
	var selected = $('#hansapostPollForm ul li input:checked').size();
	
	if(selected == 0) {
		$('#hansapostPollForm').addClass('toolErrorE').attr('title', $('#pollNoAnswer').val());
		tipsyErrorE('#hansapostPollForm');
	}else {
		
		var webFormItemId = $('#hansapostPollForm ul li input:checked').val();
		
		$.ajax({
			type: 'post',
			data:{
				webFormId: webFormId,
				webFormItemId: webFormItemId
			},
			url: context + '/poll/' + jawexSessionPath,
			success: function(data) {
				if(data.success == true) {
					var hansapostPoll = document.getElementById('hansapostPoll');
					hansapostPoll.innerHTML = data.data;
				} 
			}
		});
	}
}

function hansapostPollResults(webFormId) {
	$.ajax({
		type: 'post',
		data:{
			webFormId: webFormId
		},
		url: context + '/poll-results/' + jawexSessionPath,
		success: function(data) {
			if(data.success == true) {
				var hansapostPoll = document.getElementById('hansapostPoll');
				hansapostPoll.innerHTML = data.data;
			} 
		}
	});
}



