$( function(){

	var theCount = $("#status-field-char-counter").html();

	$("#status").charCounter(theCount, {
	container: "#status-field-char-counter",
	format: "%1",
	delay: 30
	});
	
	
	$( '.vote' ).click( function(){
								 
        var theAnswerID = $(".Poll_Answer:checked").val();
		var thePollID = $("input#x_poll_poll_id").val();
		var theUserID = $('input#x_poll_user_id').val();
		var checkCookie = $("input#x_checkCookie").val();
		
		$('.pol-answers').html('<div align="center"><br><br><img src="/assets/images/vote-loader.gif" border="0"/><br><br><b>casting vote - please wait...</b><br><br><br></div>');
		
		
		$(".pol-answers").load("/api/pol/vote_results", {x_answer_id: theAnswerID, x_poll_id: thePollID, x_user_id: theUserID, x_checkCookie: checkCookie}, function(){
		   //$('.item-center-top').prepend('<div class="item-top-status-msg">Your vote has been submitted!</div>');
		 });
								 
	return false;
    });

	$( '.viewresults' ).click( function(){
								 
		var thePollID = $("input#x_poll_poll_id").val();
		
		$('.pol-answers').html('<div align="center"><br><br><img src="/assets/images/vote-loader.gif" border="0"/><br><br><b>getting results - please wait...</b><br><br><br></div>');
		
		
		$(".pol-answers").load("/api/pol/just_results", {x_poll_id: thePollID}, function(){
		   //$('.item-center-top').prepend('<div class="item-top-status-msg">Your vote has been submitted!</div>');
		 });
								 
	return false;
    });



	
	
	
});

