$(document).ready(function()
	{
		$("#rightpoll_error").hide();
		$("#rightpoll_message").hide();
		$("#rightpoll_comment").hide();
		
		$('#rightpoll_submit').click(function () { 
			//NO AJAX correctPollRequest();
			
			//post to poll page
			$("#rightpoll_frm").submit();
		});
	}
);




function correctPollRequest(){
	
		var poll;
		
		poll = $("input[@name=rightpoll_answer]:checked").val();
		
		$("#rightpoll_error").hide();
		
		h = $('#homebox-content-box1').height();
		
		if(poll == undefined){
			$("#rightpoll_error").show();
		}else{
			$.ajax({
				type: "POST",
				url: "/ajax/poll.php",
				data: 	"answer=" + poll + "&id=" + $('#rightpoll_id').val(),
				success: function(url){
					
					arrValues = url.split(":");
						 $.each(
						 arrValues,
							 function( intIndex, objValue ){
							 	
									$.ajax({
										type: "POST",
										url: "/ajax/poll_result.php",
										data: 	"id=" + objValue+ "&pollid=" + $('#rightpoll_id').val(),
										success: function(url){
							 				$('#answers-feedback-bar-'+objValue+" span").text(url+"%");
							 				$('#answers-feedback-bar-'+objValue).width(0);
							 				$('#answers-feedback-bar-'+objValue).animate({'width': url+'%'}, "slow");
										}
									});	
									
									$("#rightpoll_answersvoted").show();					 		
									$("#rightpoll_frm").hide();					 		
									$("#btn_poll_stem").hide();					 		
									$("#rightpoll_message").show();		
									
									

						 	}
						 );
				}
				
			});
			
			$.ajax({
				type: "POST",
				url: "/ajax/poll_comment.php",
				data: 	"id=" + poll,
				success: function(url){
					$("#rightpoll_comment").html(url);
					$("#rightpoll_comment").show();
					
					
												h2 = $('#homebox-content-box1').height();
												h3 = (h2-h)+80;
												
												var cssObj = {
											        "padding-top": h3
											      }
												
												$('#footerWrapper').css(cssObj);
					
				}
			});	
			
		}
		return false;  
}

