function confirm_action(a){if(confirm(a)){return true}else{return false}}function confirm_location(b,a){if(confirm(b)){window.location=a}else{return false}}function cancel_edit(a){if(a==NULL){a="Are you sure you want to discard these changes?"}if(confirm(a)){javascript:history.back()}};




	// Process ajax validation & comment submission
	function add_comment() 
	{
		var c = $('#f-comment').val();
		var n = $('#f-name').val();
	
		$.ajax({
			url: '/poll/send_comment',
			cache: false,
			type: 'POST',
			data: { 'f-comment': c, 'f-name': n },
			dataType: 'json',
			success: function(data) {
				// if (data.success == 'true')
				// {
					$('#c-add').remove();
					$('#c-form').fadeOut(function(){
						$('#comments').append('<div id="c-msg">Thanks! Your comment may take a short time to appear while we review it.</div>');
						$('#comments').animate({
							height: 70
						}, function(){
							if (jQuery.browser.msie) {
								this.style.removeAttribute("filter");
							}
							$('#c-msg').fadeIn();
							$('#c-form').remove();
						});
					});
				// }
				// else
				// {
				// 	alert('There has been an error saving your comment. Please try again.');
				// }
			}
		});
		return false;
	}
		
	// Display characters left for comments
	var chars_allowed = 250;
	function text_limit()
	{
		var poll_length = $('#f-comment').val().length;
		var chars_remaining = chars_allowed - poll_length
		$('#char-count div').html(chars_remaining);
		if (chars_remaining < 0)
		{
			$('#f-submit').attr('src','/img/layout/comment-submit-disabled.gif');
			$('#f-submit').attr('disabled','disabled');
			$('#char-count div').css('background', '#ca0008');
		}
		else if (chars_remaining < 20)
		{
			$('#f-submit').attr('src','/img/layout/comment-submit.gif');
			$('#f-submit').attr('disabled','');
			$('#char-count div').css('background', '#ff8712');
		}
		else
		{
			$('#f-submit').attr('src','/img/layout/comment-submit.gif');
			$('#f-submit').attr('disabled','');
			$('#char-count div').css('background', '#8bcd45');
		}
	}
	
	// Get More comments
	function get_comments()
	{
		var offset = $('#recent_comments dd').length;
		var url = '/poll/get_comments/' + offset
		$.getJSON(url, function(json) {
			$.each(json.comments, function(i,comment){
				$('#recent_comments').append('<dt>&raquo;</dt><dd>' + comment.comment + '<span class="author">'+ comment.author +'</span></dd>');
			});
			
			// Remove the comments link if we've loaded all comments
			if (json.remove_link == 'true')
			{
				$('#load-more-comments').remove();
			}
		});
		return false;
	}