if (top !== self && document.referrer.match(/digg\.com\/\w{1,8}/)) {
  top.location.replace(self.location.href);
}
if ($.support.leadingWhitespace) {
Cufon.replace('h1', {'hover': true, fontFamily: 'Myriad Pro'});
Cufon.replace('h2', {'hover': true, fontFamily: 'Myriad Pro'});
Cufon.replace('#navChimes li', {'hover': true, fontFamily: 'Myriad Pro'});
Cufon.replace('#subheader span', {fontFamily: 'Myriad Pro'});
Cufon.replace('.amp', { fontFamily: 'Minion Pro'});
}
$(function () {
	prepChimes();
});

function prepChimes() {
	$('#contentSecondary #poll form').submit(function () {
		submitPollForm(this.action);
		return false;		
	});
	$('#contentSecondary #poll form .action a').click(function () { getPollResults($('#contentSecondary #poll form').attr('action')); return false; });
	$('span.email').each(function () {
		var adr = this.innerHTML;
		adr = adr.replace(/ \[{0,1}(dot|period)\]{0,1} /gi,'.').replace(/ \[{0,1}at\]{0,1} /gi,'@');
		$(this).html('<a href="mailto:'+adr+'">'+adr+'</a>');
	});
}

function submitPollForm(pollurl) {
	$.ajax({
		type: 'POST',
		url: pollurl,
		dataType: 'json',
		data: {'choice': $('input[name="choice"]:checked').val()},
		success: function(data) {
			if (data.success) {
				getPollResults(pollurl);				
			}
		},
		error: function () {
			alert('error');
			$('#contentSecondary #poll form').submit();
		}
	});
}

function getPollResults(pollurl) {
	$('#contentSecondary #poll form').fadeOut('fast');
	$('#contentSecondary #poll').append('<ul id="pollResults" style="display: none;"></ul>');
	$.getJSON(pollurl.replace('vote/','results/'),
		function (data) {
			$('#pollResults').append(data.html).slideDown('fast');
		});	
}