$(document).ready(function() {
	$('#nav li').removeClass('hover');
	$('#nav li ul li:odd').addClass('even');
	$('#nav li ul li:first-child').addClass('first-child');
	$('#nav li ul li.alt:odd').removeClass('even');
	$('#nav li ul li.alt:odd').addClass('alt-even');
	
	$('#nav li').hover(
  		function () {
    		$('ul', this).show();
		},
  		function () {
    		$('ul', this).hide();
  		}
	);
	
	$('.post:even').addClass('even');
	$('.post:odd').addClass('odd');
	
    
	$("#poll").ajaxForm({
		type: "POST",
		url: $("#poll").attr("action"),
	    success: updatePoll
 	});
 	
	updatePollGraph();
	
	$("a[rel=fancybox]").fancybox({
		'transitionIn'		: 'fadeIn',
		'transitionOut'		: 'fadeOut',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
});

function updatePoll() {
	location.reload();
}

function updatePollGraph() {
 	var max = $("#poll").attr("class");
	
	$("#poll div").attr('style', function() {
		return "width: " + ($(this).attr('class') / max * 100 / 2) + "%";
	});
}
